title: No sound output with WASAPI
body: <p>I am having trouble with WASAPI. It do not output any sound and I have been checked the data that writing to the buffer.</p>
  
  <p>Because of it does not output any sound, I haven't any idea to find out the problem.</p>
  
  <p>It may have some problems in following code.</p>
  
  <pre><code>SoundStream::SoundStream() : writtenCursor(0), writeCursor(0), distroy(false)
  {
  
      IMMDeviceEnumerator * pEnumerator = nullptr;
      HResult(CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, IID_PPV_ARGS(&amp;pEnumerator)));
  
      IMMDevice * pDevice = nullptr;
      HResult(pEnumerator-&gt;GetDefaultAudioEndpoint(eRender, eMultimedia, &amp;pDevice));
      SafeRelease(&amp;pEnumerator);
  
      HResult(pDevice-&gt;Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&amp;pAudioClient));
      SafeRelease(&amp;pDevice);
  
      WAVEFORMATEXTENSIBLE * pwfx = nullptr;
  
      hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  
      REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC * 2;
  
      HResult(pAudioClient-&gt;GetMixFormat((WAVEFORMATEX**)&amp;pwfx));
  
      HResult(pAudioClient-&gt;Initialize(
          AUDCLNT_SHAREMODE_SHARED,
          AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
          hnsRequestedDuration,
          0,
          (WAVEFORMATEX*)pwfx,
          NULL));
  
      pAudioClient-&gt;SetEventHandle(hEvent);
  
      channel = (size_t)pwfx-&gt;Format.nChannels;
      bits = (size_t)pwfx-&gt;Format.wBitsPerSample;
      validBits = (size_t)pwfx-&gt;Samples.wValidBitsPerSample;
      frequency = (size_t)pwfx-&gt;Format.nSamplesPerSec;
      buffer.reshape({ 0, channel, bits &gt;&gt; 3 });
  
      CoTaskMemFree(pwfx);
  
      HResult(pAudioClient-&gt;GetBufferSize(&amp;bufferFrameCount));
      HResult(pAudioClient-&gt;Start());
  
      if (pAudioClient)
      {
          thread = std::thread([&amp;]()
          {
              this-&gt;Sync();
          });
      }
  
  }
  </code></pre>