changeset 114:ccdc5b30e54c

* Remove PAv18 support, change PORTAUDIO to PORTAUDIO_2_0 throughout as this is what comes from PAv19's pkgconfig module name
author Chris Cannam
date Fri, 09 May 2008 15:39:42 +0000
parents 0c1ea5ff6518
children 5dcbda490794
files audioio/AudioPortAudioTarget.cpp audioio/AudioPortAudioTarget.h audioio/AudioTargetFactory.cpp audioio/audioio.pro
diffstat 4 files changed, 8 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/audioio/AudioPortAudioTarget.cpp	Thu May 08 14:46:22 2008 +0000
+++ b/audioio/AudioPortAudioTarget.cpp	Fri May 09 15:39:42 2008 +0000
@@ -13,7 +13,7 @@
     COPYING included with this distribution for more information.
 */
 
-#ifdef HAVE_PORTAUDIO
+#ifdef HAVE_PORTAUDIO_2_0
 
 #include "AudioPortAudioTarget.h"
 #include "AudioCallbackPlaySource.h"
@@ -35,12 +35,8 @@
     PaError err;
 
 #ifdef DEBUG_AUDIO_PORT_AUDIO_TARGET
-#ifdef HAVE_PORTAUDIO_V18
-    std::cerr << "AudioPortAudioTarget: Initialising for PortAudio v18" << std::endl;
-#else
     std::cerr << "AudioPortAudioTarget: Initialising for PortAudio v19" << std::endl;
 #endif
-#endif
 
     err = Pa_Initialize();
     if (err != paNoError) {
@@ -54,15 +50,6 @@
 	m_sampleRate = m_source->getSourceSampleRate();
     }
 
-#ifdef HAVE_PORTAUDIO_V18
-    m_latency = Pa_GetMinNumBuffers(m_bufferSize, m_sampleRate) * m_bufferSize;
-#endif
-
-#ifdef HAVE_PORTAUDIO_V18
-    err = Pa_OpenDefaultStream(&m_stream, 0, 2, paFloat32,
-			       m_sampleRate, m_bufferSize, 0,
-			       processStatic, this);
-#else
     PaStreamParameters op;
     op.device = Pa_GetDefaultOutputDevice();
     op.channelCount = 2;
@@ -72,9 +59,7 @@
     err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate,
                         paFramesPerBufferUnspecified,
                         paNoFlag, processStatic, this);
-#endif    
 
-#ifndef HAVE_PORTAUDIO_V18
     if (err != paNoError) {
 
         std::cerr << "WARNING: AudioPortAudioTarget: Failed to open PortAudio stream with default frames per buffer, trying again with fixed frames per buffer..." << std::endl;
@@ -84,7 +69,6 @@
                             paNoFlag, processStatic, this);
 	m_bufferSize = 1024;
     }
-#endif
 
     if (err != paNoError) {
 	std::cerr << "ERROR: AudioPortAudioTarget: Failed to open PortAudio stream: " << Pa_GetErrorText(err) << std::endl;
@@ -93,11 +77,9 @@
 	return;
     }
 
-#ifndef HAVE_PORTAUDIO_V18
     const PaStreamInfo *info = Pa_GetStreamInfo(m_stream);
     m_latency = int(info->outputLatency * m_sampleRate + 0.001);
     if (m_bufferSize < m_latency) m_bufferSize = m_latency;
-#endif
 
     std::cerr << "PortAudio latency = " << m_latency << " frames" << std::endl;
 
@@ -175,16 +157,6 @@
     else return Pa_GetStreamTime(m_stream);
 }
 
-#ifdef HAVE_PORTAUDIO_V18
-int
-AudioPortAudioTarget::processStatic(void *input, void *output,
-				    unsigned long nframes,
-				    PaTimestamp outTime, void *data)
-{
-    return ((AudioPortAudioTarget *)data)->process(input, output,
-						   nframes, outTime);
-}
-#else
 int
 AudioPortAudioTarget::processStatic(const void *input, void *output,
                                     unsigned long nframes,
@@ -195,7 +167,6 @@
                                                    nframes, timeInfo,
                                                    flags);
 }
-#endif
 
 void
 AudioPortAudioTarget::sourceModelReplaced()
@@ -203,18 +174,11 @@
     m_source->setTargetSampleRate(m_sampleRate);
 }
 
-#ifdef HAVE_PORTAUDIO_V18
-int
-AudioPortAudioTarget::process(void *inputBuffer, void *outputBuffer,
-			      unsigned long nframes,
-			      PaTimestamp)
-#else
 int
 AudioPortAudioTarget::process(const void *, void *outputBuffer,
                               unsigned long nframes,
                               const PaStreamCallbackTimeInfo *,
                               PaStreamCallbackFlags)
-#endif
 {
 #ifdef DEBUG_AUDIO_PORT_AUDIO_TARGET    
     std::cout << "AudioPortAudioTarget::process(" << nframes << ")" << std::endl;
--- a/audioio/AudioPortAudioTarget.h	Thu May 08 14:46:22 2008 +0000
+++ b/audioio/AudioPortAudioTarget.h	Fri May 09 15:39:42 2008 +0000
@@ -16,15 +16,15 @@
 #ifndef _AUDIO_PORT_AUDIO_TARGET_H_
 #define _AUDIO_PORT_AUDIO_TARGET_H_
 
-#ifdef HAVE_PORTAUDIO
+#ifdef HAVE_PORTAUDIO_2_0
 
-// This code can be compiled for either PortAudio v18 or v19.
-// PortAudio v19 is the default.  If you want to use v18, define
-// the preprocessor symbol HAVE_PORTAUDIO_v18.
+// This code requires PortAudio v19 -- it won't work with v18.
 
 #include <portaudio.h>
 #include <vector>
 
+#include <QObject>
+
 #include "AudioCallbackPlayTarget.h"
 
 class AudioCallbackPlaySource;
@@ -47,18 +47,6 @@
     virtual void sourceModelReplaced();
 
 protected:
-#ifdef HAVE_PORTAUDIO_V18
-
-    int process(void *input, void *output, unsigned long frames,
-		PaTimestamp outTime);
-
-    static int processStatic(void *, void *, unsigned long,
-			     PaTimestamp, void *);
-
-    PortAudioStream *m_stream;
-
-#else
-
     int process(const void *input, void *output, unsigned long frames,
                 const PaStreamCallbackTimeInfo *timeInfo,
                 PaStreamCallbackFlags statusFlags);
@@ -69,8 +57,6 @@
 
     PaStream *m_stream;
 
-#endif
-
     int m_bufferSize;
     int m_sampleRate;
     int m_latency;
--- a/audioio/AudioTargetFactory.cpp	Thu May 08 14:46:22 2008 +0000
+++ b/audioio/AudioTargetFactory.cpp	Fri May 09 15:39:42 2008 +0000
@@ -52,8 +52,8 @@
 	delete target;
     }
 #endif
-
-#ifdef HAVE_PORTAUDIO
+    
+#ifdef HAVE_PORTAUDIO_2_0
     target = new AudioPortAudioTarget(source);
     if (target->isOK()) return target;
     else {
--- a/audioio/audioio.pro	Thu May 08 14:46:22 2008 +0000
+++ b/audioio/audioio.pro	Fri May 09 15:39:42 2008 +0000
@@ -1,6 +1,6 @@
 TEMPLATE = lib
 
-SV_UNIT_PACKAGES = fftw3f samplerate jack portaudio rubberband
+SV_UNIT_PACKAGES = fftw3f samplerate jack portaudio-2.0 rubberband
 load(../sv.prf)
 
 CONFIG += sv staticlib qt thread warn_on stl rtti exceptions