Activates the device. For playback devices this begins playback. For capture devices it begins
recording.
Starts the device. For playback devices this begins playback. For capture devices it begins recording.
For a playback device, this will retrieve an initial chunk of audio data from the client before
returning. The reason for this is to ensure there is valid audio data in the buffer, which needs
to be done _before_ the device begins playback.
Use `ma_device_stop()` to stop the device.
This API waits until the backend device has been started for real by the worker thread. It also
waits on a mutex for thread-safety.
Do not call this in any callback.
Parameters
----------
pDevice (in)
A pointer to the device to start.
Return Value:
MA_SUCCESS if successful; any other error code otherwise.
Thread Safety: SAFE
It's safe to call this from any thread with the exception of the callback thread.
Return Value
------------
MA_SUCCESS if successful; any other error code otherwise.
Callback Safety: UNSAFE
It is not safe to call this inside any callback.
Thread Safety
-------------
Safe. It's safe to call this from any thread with the exception of the callback thread.
Callback Safety
---------------
Unsafe. It is not safe to call this inside any callback.
Remarks
-------
For a playback device, this will retrieve an initial chunk of audio data from the client before returning. The reason for this is to ensure there is valid
audio data in the buffer, which needs to be done before the device begins playback.
This API waits until the backend device has been started for real by the worker thread. It also waits on a mutex for thread-safety.
Do not call this in any callback.
See Also
--------
ma_device_stop()
*/
ma_result ma_device_start(ma_device* pDevice);
/*
Puts the device to sleep, but does not uninitialize it. Use ma_device_start() to start it up again.
Stops the device. For playback devices this stops playback. For capture devices it stops recording.
This API needs to wait on the worker thread to stop the backend device properly before returning. It
also waits on a mutex for thread-safety. In addition, some backends need to wait for the device to
finish playback/recording of the current fragment which can take some time (usually proportionate to
the buffer size that was specified at initialization time).
Use `ma_device_start()` to start the device again.
This should not drop unprocessed samples. Backends are required to either pause the stream in-place
or drain the buffer if pausing is not possible. The reason for this is that stopping the device and
the resuming it with ma_device_start() (which you might do when your program loses focus) may result
in a situation where those samples are never output to the speakers or received from the microphone
which can in turn result in de-syncs.
Parameters
----------
pDevice (in)
A pointer to the device to stop.
Return Value
------------
MA_SUCCESS if successful; any other error code otherwise.
Thread Safety
-------------
Safe. It's safe to call this from any thread with the exception of the callback thread.
Callback Safety
---------------
Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.
Remarks
-------
This API needs to wait on the worker thread to stop the backend device properly before returning. It also waits on a mutex for thread-safety. In addition, some
backends need to wait for the device to finish playback/recording of the current fragment which can take some time (usually proportionate to the buffer size
that was specified at initialization time).
Backends are required to either pause the stream in-place or drain the buffer if pausing is not possible. The reason for this is that stopping the device and
the resuming it with ma_device_start() (which you might do when your program loses focus) may result in a situation where those samples are never output to the
speakers or received from the microphone which can in turn result in de-syncs.
Do not call this in any callback.
Return Value:
MA_SUCCESS if successful; any other error code otherwise.
This will be called implicitly by `ma_device_uninit()`.
Thread Safety: SAFE
It's safe to call this from any thread with the exception of the callback thread.
Callback Safety: UNSAFE
It is not safe to call this inside any callback. Doing this will result in a deadlock.
See Also
--------
ma_device_start()
*/
ma_result ma_device_stop(ma_device* pDevice);
/*
Determines whether or not the device is started.
This is implemented as a simple accessor.
Return Value:
True if the device is started, false otherwise.
Parameters
----------
pDevice (in)
A pointer to the device whose start state is being retrieved.
Thread Safety: SAFE
If another thread calls ma_device_start() or ma_device_stop() at this same time as this function
is called, there's a very small chance the return value will be out of sync.
Return Value
------------
True if the device is started, false otherwise.
Thread Safety
-------------
Safe. If another thread calls `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, there's a very small chance the return