mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-10 06:41:42 +02:00
Wasapi player: unregister system volume change callback on player destroy. Fixes crash when changing Windows volume after switching streams
Wasapi player: unregister system volume change callback on player destroy. Fixes crash when changing Windows volume after switching streams
This commit is contained in:
parent
ea1236feef
commit
af621acf1c
2 changed files with 3 additions and 2 deletions
|
@ -83,6 +83,7 @@ WASAPIPlayer::WASAPIPlayer(boost::asio::io_context& io_context, const ClientSett
|
||||||
|
|
||||||
WASAPIPlayer::~WASAPIPlayer()
|
WASAPIPlayer::~WASAPIPlayer()
|
||||||
{
|
{
|
||||||
|
audioEndpointListener_->UnregisterControlChangeNotify(&audioEndpointVolumeCallback_);
|
||||||
WASAPIPlayer::stop();
|
WASAPIPlayer::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,10 +251,9 @@ void WASAPIPlayer::worker()
|
||||||
hr = control->RegisterAudioSessionNotification(audioEventListener_);
|
hr = control->RegisterAudioSessionNotification(audioEventListener_);
|
||||||
CHECK_HR(hr);
|
CHECK_HR(hr);
|
||||||
|
|
||||||
AudioEndpointVolumeCallback audioEndpointVolumeCallback;
|
|
||||||
hr = device->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&audioEndpointListener_);
|
hr = device->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&audioEndpointListener_);
|
||||||
|
|
||||||
audioEndpointListener_->RegisterControlChangeNotify((IAudioEndpointVolumeCallback*)&audioEndpointVolumeCallback);
|
audioEndpointListener_->RegisterControlChangeNotify((IAudioEndpointVolumeCallback*)&audioEndpointVolumeCallback_);
|
||||||
|
|
||||||
// Get the device period
|
// Get the device period
|
||||||
REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC;
|
REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC;
|
||||||
|
|
|
@ -192,6 +192,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
AudioSessionEventListener* audioEventListener_;
|
AudioSessionEventListener* audioEventListener_;
|
||||||
IAudioEndpointVolume* audioEndpointListener_;
|
IAudioEndpointVolume* audioEndpointListener_;
|
||||||
|
AudioEndpointVolumeCallback audioEndpointVolumeCallback_;
|
||||||
ClientSettings::SharingMode mode_;
|
ClientSettings::SharingMode mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue