From 51afa7e1297c516cf6da960e4b132136516765a7 Mon Sep 17 00:00:00 2001 From: kode54 Date: Sun, 26 Aug 2012 07:44:19 +0000 Subject: [PATCH] Fixed a crash on Windows XP and older systems git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1112 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/XAudio2.cpp | 10 ++++++---- src/wx/xaudio2.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) 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 );