mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Don't stop the device in ma_device_uninit().
If the state miniaudio side of the device does not match the actual state of the backend side of it, such as when the device is stopped but the backend doesn't post a notification, attempting to stop the device might result in a deadlock. This is a just a quick workaround hack for the moment while a more robust solution is figured out. https://github.com/mackron/miniaudio/issues/717
This commit is contained in:
+14
-3
@@ -87,7 +87,7 @@ device on the stack, but you could allocate it on the heap if that suits your si
|
|||||||
|
|
||||||
// Do something here. Probably your program's main loop.
|
// Do something here. Probably your program's main loop.
|
||||||
|
|
||||||
ma_device_uninit(&device); // This will stop the device so no need to do that manually.
|
ma_device_uninit(&device);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -9133,8 +9133,6 @@ speakers or received from the microphone which can in turn result in de-syncs.
|
|||||||
|
|
||||||
Do not call this in any callback.
|
Do not call this in any callback.
|
||||||
|
|
||||||
This will be called implicitly by `ma_device_uninit()`.
|
|
||||||
|
|
||||||
|
|
||||||
See Also
|
See Also
|
||||||
--------
|
--------
|
||||||
@@ -42100,10 +42098,23 @@ MA_API void ma_device_uninit(ma_device* pDevice)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
It's possible for the miniaudio side of the device and the backend to not be in sync due to
|
||||||
|
system-level situations such as the computer being put into sleep mode and the backend not
|
||||||
|
notifying miniaudio of the fact the device has stopped. It's possible for this to result in a
|
||||||
|
deadlock due to miniaudio thinking the device is in a running state, when in fact it's not
|
||||||
|
running at all. For this reason I am no longer explicitly stopping the device. I don't think
|
||||||
|
this should affect anyone in practice since uninitializing the backend will naturally stop the
|
||||||
|
device anyway.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
/* Make sure the device is stopped first. The backends will probably handle this naturally, but I like to do it explicitly for my own sanity. */
|
/* Make sure the device is stopped first. The backends will probably handle this naturally, but I like to do it explicitly for my own sanity. */
|
||||||
if (ma_device_is_started(pDevice)) {
|
if (ma_device_is_started(pDevice)) {
|
||||||
ma_device_stop(pDevice);
|
ma_device_stop(pDevice);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Putting the device into an uninitialized state will make the worker thread return. */
|
/* Putting the device into an uninitialized state will make the worker thread return. */
|
||||||
ma_device__set_state(pDevice, ma_device_state_uninitialized);
|
ma_device__set_state(pDevice, ma_device_state_uninitialized);
|
||||||
|
|||||||
Reference in New Issue
Block a user