detect PortAudio v19 and use accordingly

Originally committed to SVN as r1011.
This commit is contained in:
David Lamparter 2007-04-05 16:39:49 +00:00
parent 55db15f9d9
commit a274bbc1aa
3 changed files with 24 additions and 1 deletions

View File

@ -83,7 +83,13 @@ typedef unsigned __int64 uint64_t;
//////////////////////
// PortAudio callback
#ifndef HAVE_PA_GETSTREAMTIME
int PortAudioPlayer::paCallback(void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData) {
#else
int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timei,
PaStreamCallbackFlags flags, void *userData) {
#endif
// Get provider
PortAudioPlayer *player = (PortAudioPlayer *) userData;
AudioProvider *provider = player->GetProvider();
@ -178,7 +184,12 @@ void PortAudioPlayer::Stop(bool timerToo) {
// Open stream
void PortAudioPlayer::OpenStream() {
// Open stream
PaError err = Pa_OpenDefaultStream(&stream,0,provider->GetChannels(),paInt16,provider->GetSampleRate(),256,16,paCallback,this);
PaError err = Pa_OpenDefaultStream(&stream,0,provider->GetChannels(),paInt16,provider->GetSampleRate(),256,
#ifndef HAVE_PA_GETSTREAMTIME
16, /* Pa v19 doesn't have a numberOfBuffers parameter */
#endif
paCallback,this);
if (err != paNoError) {
throw wxString(_T("Failed initializing PortAudio stream with error: ") + wxString(Pa_GetErrorText(err),wxConvLocal));
}

View File

@ -46,6 +46,10 @@ extern "C" {
#include <portaudio.h>
}
#ifdef HAVE_PA_GETSTREAMTIME
#define Pa_StreamTime Pa_GetStreamTime /* PortAudio v19 */
#define PaTimestamp PaTime
#endif
////////////////////
// Portaudio player
@ -65,7 +69,14 @@ private:
PaTimestamp paStart;
volatile __int64 realPlayPos;
#ifndef HAVE_PA_GETSTREAMTIME
static int paCallback(void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData);
#else
static int paCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo *timei,
PaStreamCallbackFlags flags, void *userData);
#endif
public:
PortAudioPlayer();

View File

@ -124,6 +124,7 @@ AC_CHECK_LIB([m], [main])
AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([portaudio], [Pa_Initialize],, [AC_MSG_ERROR([portaudio not found.])])
AC_CHECK_FUNCS([Pa_GetStreamTime])
AC_CHECK_LIB([avcodec], [avcodec_init])
AC_CHECK_LIB([avformat], [av_read_frame])