mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
Fix race condition by adding required locking in WasapiOut to avoid rare
crash.
This commit is contained in:
parent
6bae859ac2
commit
4bb9bbad3c
@ -1,3 +1,7 @@
|
||||
0.96.10
|
||||
|
||||
* fixed race condition in WasapiOut that caused the app to crash.
|
||||
|
||||
0.96.9
|
||||
|
||||
* fixed `-rpath` to use `$ORIGIN` instead of `./` to appease `Feodra 35`.
|
||||
|
@ -359,6 +359,8 @@ OutputState WasapiOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
||||
}
|
||||
|
||||
void WasapiOut::Reset() {
|
||||
Lock lock(this->stateMutex);
|
||||
|
||||
if (this->simpleAudioVolume) {
|
||||
this->simpleAudioVolume->Release();
|
||||
}
|
||||
@ -516,6 +518,7 @@ found_or_done:
|
||||
|
||||
int WasapiOut::GetDefaultSampleRate() {
|
||||
int result = -1;
|
||||
Lock lock(this->stateMutex);
|
||||
this->InitializeAudioClient();
|
||||
if (this->audioClient) {
|
||||
WAVEFORMATEX* deviceFormat = nullptr;
|
||||
@ -529,6 +532,8 @@ int WasapiOut::GetDefaultSampleRate() {
|
||||
}
|
||||
|
||||
bool WasapiOut::InitializeAudioClient() {
|
||||
/* assumes stateMutex is locked */
|
||||
|
||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
|
||||
HRESULT result = S_FALSE;
|
||||
@ -584,6 +589,7 @@ bool WasapiOut::InitializeAudioClient() {
|
||||
}
|
||||
|
||||
bool WasapiOut::Configure(IBuffer *buffer) {
|
||||
/* assumes stateMutex is locked */
|
||||
if (this->audioClient &&
|
||||
waveFormat.Format.nChannels == buffer->Channels() &&
|
||||
waveFormat.Format.nSamplesPerSec == buffer->SampleRate())
|
||||
|
Loading…
Reference in New Issue
Block a user