1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
DWORD WINAPI NotificationProc( LPVOID lpParameter )
{
HRESULT hr;
HWND hDlg = (HWND) lpParameter;
MSG msg;
DWORD dwResult;
BOOL bDone = FALSE;
BOOL bLooped;
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 1, &g_hNotificationEvent[0],
FALSE, INFINITE, QS_ALLEVENTS );
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
// g_hNotificationEvent is signaled
// This means that DirectSound just finished playing
// a piece of the buffer, so we need to fill the circular
// buffer with new sound from the wav file
bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
if( FAILED( hr = g_pStreamingSound[0]->HandleWaveStreamNotification( bLooped ) ) )
{
DXTRACE_ERR_MSGBOX( TEXT("HandleWaveStreamNotification"), hr );
MessageBox( hDlg, "Error handling DirectSound notifications."
"Sample will now exit.", "DirectSound Sample",
MB_OK | MB_ICONERROR );
bDone = TRUE;
}
break;
case WAIT_OBJECT_0 + 1:
// Messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
bDone = TRUE;
}
break;
}
}
return 0;
} |
Partager