* Set Pa_OpenStream to use paClipOff as we don't need any clipping

* Update comment (realPlayPos has been removed).
* Return from paCallback with paAbort if there is no more audio to play.
  Also set endPos to be less than the current playPos to stop the audio
  event timer.
* Add CPU usage statistics to debug printf in paCallback.

Originally committed to SVN as r2804.
This commit is contained in:
Amar Takhar 2009-04-16 19:55:52 +00:00
parent eebde56363
commit 89fa60082e

View file

@ -121,15 +121,20 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, uns
// Fill rest with blank // Fill rest with blank
for (unsigned int i=avail;i<framesPerBuffer;i++) output[i]=0; for (unsigned int i=avail;i<framesPerBuffer;i++) output[i]=0;
// Set play position (and real one) // Set play position
player->playPos += framesPerBuffer; player->playPos += framesPerBuffer;
#ifdef PORTAUDIO2_DEBUG #ifdef PORTAUDIO2_DEBUG
printf("paCallBack: playPos: %lld startPos: %lld paStart: %f Pa_GetStreamTime: %f AdcTime: %f DacTime: %f\n", printf("paCallBack: playPos: %lld startPos: %lld paStart: %f Pa_GetStreamTime: %f AdcTime: %f DacTime: %f CPU: %f\n",
player->playPos, player->startPos, player->paStart, Pa_GetStreamTime(player->stream), player->playPos, player->startPos, player->paStart, Pa_GetStreamTime(player->stream),
timeInfo->inputBufferAdcTime, timeInfo->outputBufferDacTime); timeInfo->inputBufferAdcTime, timeInfo->outputBufferDacTime, Pa_GetStreamCpuLoad(player->stream));
#endif #endif
// Cap to start if lower
// Set the end position to be less then the current play position.
if (lenAvailable <= 0) {
player->endPos = player->endPos - (framesPerBuffer + 8192);
return paAbort;
}
return end; return end;
} }
@ -203,7 +208,7 @@ void PortAudioPlayer::OpenStream() {
wxLogDebug(_T("PortAudioPlayer::OpenStream Output channels: %d, Latency: %f Sample Rate: %ld\n"), wxLogDebug(_T("PortAudioPlayer::OpenStream Output channels: %d, Latency: %f Sample Rate: %ld\n"),
pa_output_p.channelCount, pa_output_p.suggestedLatency, pa_output_p.sampleFormat); pa_output_p.channelCount, pa_output_p.suggestedLatency, pa_output_p.sampleFormat);
PaError err = Pa_OpenStream(&stream, NULL, &pa_output_p, provider->GetSampleRate(), 256, paNoFlag, paCallback, this); PaError err = Pa_OpenStream(&stream, NULL, &pa_output_p, provider->GetSampleRate(), 256, paClipOff, paCallback, this);
if (err != paNoError) { if (err != paNoError) {