2

I use WASAPI to capture audio buffers in shared mode on Windows 7. I use my loudspeakers which can only have a 48 kHz sample rate, 96 kHz, 192 kHz or 44.1 kHz sample rate. My sound card is a Realtek High Definition one.

I need to know if WASAPI will behave differently if I execute my program on another OS like Windows Vista or Windows 8. Also, I need to know if getBuffer will retrieve the same size for captured buffers with different hardware (different sound cards).

I can't test it on my own and I can't find much details on the Internet. But my program has to work on different computers with different versions of Windows and different hardware. My program won't work correctly on another computer if captured buffer size is different.

If anyone knows anything about it, let me know please. Thank you.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
userAR15
  • 21
  • 7

1 Answers1

2

Capturing a Stream on MSDN offers you a code snippet that shows how to capture data without relying on specific amount of bytes (samples) returned from audio device. Your capture logic should be copying from buffers into your internal buffer where you accumulate sufficient amount of contiguous data for further processing. Also note that under certain circumstances your capture loop might lose samples and you have discontinuity on the data stream. This can basically happen at any part of the stream and reduce about of bytes/buffers you are having. You are interested to handle this gracefully as well.

// Get the available data in the shared buffer.
hr = pCaptureClient->GetBuffer(&pData, &numFramesAvailable, &flags, NULL, NULL);
if (flags & AUDCLNT_BUFFERFLAGS_SILENT)
{
   // TODO: Tell CopyData to write silence.
}
// Copy the available capture data to the audio sink.
hr = pMySink->CopyData(pData, numFramesAvailable, &bDone);
Roman R.
  • 68,205
  • 6
  • 94
  • 158