diff --git a/src/win32/XAudio2.cpp b/src/win32/XAudio2.cpp index a2601726..ffd48849 100644 --- a/src/win32/XAudio2.cpp +++ b/src/win32/XAudio2.cpp @@ -105,7 +105,6 @@ public: if ( SUCCEEDED( hr ) ) { pEnumerator->RegisterEndpointNotificationCallback( this ); - registered = true; } } @@ -118,9 +117,12 @@ public: { if ( InterlockedDecrement( ®istered ) == 0 ) { - pEnumerator->UnregisterEndpointNotificationCallback( this ); - pEnumerator->Release(); - registered = false; + if (pEnumerator) + { + pEnumerator->UnregisterEndpointNotificationCallback( this ); + pEnumerator->Release(); + pEnumerator = NULL; + } } EnterCriticalSection( &lock ); diff --git a/src/wx/xaudio2.cpp b/src/wx/xaudio2.cpp index 8b31ced9..35015b1f 100644 --- a/src/wx/xaudio2.cpp +++ b/src/wx/xaudio2.cpp @@ -103,7 +103,6 @@ public: if ( SUCCEEDED( hr ) ) { pEnumerator->RegisterEndpointNotificationCallback( this ); - registered = true; } } @@ -116,9 +115,12 @@ public: { if ( InterlockedDecrement( ®istered ) == 0 ) { - pEnumerator->UnregisterEndpointNotificationCallback( this ); - pEnumerator->Release(); - registered = false; + if (pEnumerator) + { + pEnumerator->UnregisterEndpointNotificationCallback( this ); + pEnumerator->Release(); + pEnumerator = NULL; + } } EnterCriticalSection( &lock );