0

声音输出功能给了我意想不到的信息。这是我做错了什么的迹象吗?如果是这样呢?否则是否有一个很好的来源可以解释这些消息可能是什么?

根据 https://wiki.winehq.org/List_Of_Windows_Messages,waveOutOpen() 给了我消息 955 MM_WOM_OPEN 作为记录,然后是未记录的 1024(可能是 DDM_SETFMT、DM_GETDEFID、NIN_SELECT、TBM_GETPOS、WM_PSD_PAGESETUPDLG、WM_USER

在主线程中:

  hAudioOut = CreateThread( 0, 0, AudioOutThreadProc, this, 0, &dwAudioOutId );

      if( !hAudioOut ) {
          AKS( AKSWarn, "Audio Out CreateThread() fail" );
          return;
      }

在生成的音频线程中:

static DWORD WINAPI AudioOutThreadProc( LPVOID lpParameter ) {

  Interpreter* pinterp = (Interpreter *) lpParameter;
  WAVEFORMATEX waveFormat;

  waveFormat.cbSize          = sizeof(waveFormat);
  waveFormat.wFormatTag      = WAVE_FORMAT_PCM;
  waveFormat.nChannels       = 1;
  waveFormat.nSamplesPerSec  = (int) dFreqEval;
  waveFormat.wBitsPerSample  = iOutputBits;
  waveFormat.nBlockAlign     = waveFormat.nChannels *
                               waveFormat.wBitsPerSample / 8;
  waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec *
                               waveFormat.nBlockAlign;

  MMRESULT openRes = waveOutOpen( &waveOut, WAVE_MAPPER, &waveFormat,
                                  (DWORD_PTR) dwAudioOutId, (DWORD_PTR) this,
                                  CALLBACK_THREAD /*| WAVE_FORMAT_DIRECT*/ );

  if ( openRes != MMSYSERR_NOERROR )
      Log( "waveOutOpen() = %d", openRes );

  MSG msg;
  int iRV;
  while ( iRV = GetMessage( &msg, 0, 0, 0 ) ) {

      Log( "got  message %d", msg.message );

      // Is the main thread asking us to stop?
      if ( pinterp->bStop ) {

          Log( "AudioInThreadProc(): bStop" );
          return EXIT_SUCCESS;
      }

      // Did we get an error?
      if ( iRV == -1 ) {
          Log( "GetMessage() = -1: %d", GetLastError() );
          abort();
      }

      // Did we get an expected message?  (Only one expected,
      // which tells us its time to write more data.)
      if ( msg.message == WOM_DONE )
          pinterp->Write();

      // Anything else--log it.
      else
          Log( "got unknown message %d", msg.message );
  }

  Log( "AudioInThreadProc(): GetMessage = return" );

  return msg.wParam;
}

waveOutWrite() 没有记录以提供任何消息,但也给了我消息 1024。

4

0 回答 0