Make debug printf's a perm fixture wrapped with PORTAUDIO2_DEBUG.

Originally committed to SVN as r2803.
This commit is contained in:
Amar Takhar 2009-04-16 14:22:46 +00:00
parent bcc8cede88
commit eebde56363
1 changed files with 18 additions and 13 deletions

View File

@ -46,6 +46,8 @@
#include "options.h" #include "options.h"
#include "utils.h" #include "utils.h"
// Uncomment to enable debug features.
//#define PORTAUDIO2_DEBUG
///////////////////// /////////////////////
// Reference counter // Reference counter
@ -122,14 +124,11 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, uns
// Set play position (and real one) // Set play position (and real one)
player->playPos += framesPerBuffer; player->playPos += framesPerBuffer;
const PaStreamInfo* streamInfo = Pa_GetStreamInfo(player->stream); #ifdef PORTAUDIO2_DEBUG
printf("paCallBack: playPos: %lld startPos: %lld paStart: %f Pa_GetStreamTime: %f AdcTime: %f DacTime: %f\n",
/* player->playPos, player->startPos, player->paStart, Pa_GetStreamTime(player->stream),
printf("playPos: %lld startPos: %lld paStart: %f currentTime: %f realPlayPos: %lld Pa_GetStreamTime: %f AdcTime: %f DacTime: %f\n",
player->playPos, player->startPos, player->paStart, timeInfo->currentTime, player->realPlayPos, Pa_GetStreamTime(player->stream),
timeInfo->inputBufferAdcTime, timeInfo->outputBufferDacTime); timeInfo->inputBufferAdcTime, timeInfo->outputBufferDacTime);
*/ #endif
// Cap to start if lower // Cap to start if lower
return end; return end;
} }
@ -234,12 +233,18 @@ int64_t PortAudioPlayer::GetCurrentPosition()
if (!playing) return 0; if (!playing) return 0;
const PaStreamInfo* streamInfo = Pa_GetStreamInfo(stream); const PaStreamInfo* streamInfo = Pa_GetStreamInfo(stream);
/*
int64_t real = ((Pa_GetStreamTime(stream) - paStart) * streamInfo->sampleRate) + startPos; #ifdef PORTAUDIO2_DEBUG
printf("GetCurrentPosition Pa_GetStreamTime: %f startPos: %lld playPos: %lld paStart: %f real: %lld\n", PaTime pa_getstream = Pa_GetStreamTime(stream);
Pa_GetStreamTime(stream), startPos, playPos, paStart, real); int64_t real = ((pa_getstream - paStart) * streamInfo->sampleRate) + startPos;
*/ printf("GetCurrentPosition: Pa_GetStreamTime: %f startPos: %lld playPos: %lld paStart: %f real: %lld diff: %f\n",
pa_getstream, startPos, playPos, paStart, real, pa_getstream-paStart);
return real;
#else
return ((Pa_GetStreamTime(stream) - paStart) * streamInfo->sampleRate) + startPos; return ((Pa_GetStreamTime(stream) - paStart) * streamInfo->sampleRate) + startPos;
#endif
} }