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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
DWORD WINAPI MyNotificationProc( LPVOID lpParameter )
{
HRESULT hr;
HWND hDlg;
MSG msg;
DWORD dwResult;
BOOL bDone = FALSE;
BOOL bLooped;
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 3, &g_hNotificationEvent[0],
FALSE, INFINITE, QS_ALLEVENTS );
threadInfos *pThreadInfo = (threadInfos *)lpParameter;
hDlg = pThreadInfo->dlgHandle;
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
if(pThreadInfo->threadID == 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 :
if (pThreadInfo->threadID == 1) {
bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
if( FAILED( hr = g_pStreamingSound[1]->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 + 2 :
if(pThreadInfo->threadID == 2) {
bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
if( FAILED( hr = g_pStreamingSound[2]->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 + 3:
// Messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
bDone = TRUE;
}
break;
}
}
return 0;
} |
Partager