Gabriel M. Beddingfield wrote:
I've attached the backtrace, build log, h2 output, and scache.conf. It
looks like the callback got used before the buffers were allocated.
Ah, I see what happened... and I've attached patch(es) to fix it. The pointer
to the callback data should have been (void*)this. This is actually a standard
practice for C-style callbacks, so it's worth taking a moment to understand it.
The same callback "pattern" is used in the ALSA and JACK APIS... as well as
stuff like SQLite (and just about any other C library that utilizes a client
callback).
I've attached two patches: (a) the patch that gets applied on top of
Sebastian's patch, and (b) the full patch.
This now works with portaudio v19 (API v2).
Question: Do we want to support both API's... or go ahead an migrate to the v2
API? How widely avail. is the the v2 API on stable distro's?
Thanks,
Gabriel
diff --git a/libs/hydrogen/src/IO/portaudio_driver.cpp b/libs/hydrogen/src/IO/portaudio_driver.cpp
index 892ba4f..2b42fa1 100644
--- a/libs/hydrogen/src/IO/portaudio_driver.cpp
+++ b/libs/hydrogen/src/IO/portaudio_driver.cpp
@@ -82,9 +82,6 @@ int PortAudioDriver::connect()
return 1;
}
- static paTestData data;
-
-
err = Pa_OpenDefaultStream(
&m_pStream, /* passes back stream pointer */
0, /* no input channels */
@@ -94,7 +91,7 @@ int PortAudioDriver::connect()
m_nBufferSize, // frames per buffer
//0, // number of buffers, if zero then use default minimum
portAudioCallback, /* specify our custom callback */
- &data ); /* pass our data through to callback */
+ (void*)this ); /* pass our data through to callback */
if ( err != paNoError ) {
diff --git a/libs/hydrogen/src/IO/PortAudioDriver.h b/libs/hydrogen/src/IO/PortAudioDriver.h
index 5dda3f5..36c5196 100644
--- a/libs/hydrogen/src/IO/PortAudioDriver.h
+++ b/libs/hydrogen/src/IO/PortAudioDriver.h
@@ -28,6 +28,11 @@
#ifdef PORTAUDIO_SUPPORT
+
+
+#define PortAudioStream PaStream
+#define PaTimestamp PaTime
+
#include <inttypes.h>
#include <portaudio.h>
diff --git a/libs/hydrogen/src/IO/portaudio_driver.cpp b/libs/hydrogen/src/IO/portaudio_driver.cpp
index a6df93e..2b42fa1 100644
--- a/libs/hydrogen/src/IO/portaudio_driver.cpp
+++ b/libs/hydrogen/src/IO/portaudio_driver.cpp
@@ -10,10 +10,11 @@ namespace H2Core
{
int portAudioCallback(
- void *inputBuffer,
+ const void *inputBuffer,
void *outputBuffer,
unsigned long framesPerBuffer,
- PaTimestamp outTime,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
void *userData
)
{
@@ -66,9 +67,16 @@ int PortAudioDriver::connect()
m_pOut_L = new float[ m_nBufferSize ];
m_pOut_R = new float[ m_nBufferSize ];
- int err = Pa_Initialize();
-
+ PaError err = Pa_Initialize();
+ typedef struct
+ {
+ float left_phase;
+ float right_phase;
+ } paTestData;
+
+
+
if ( err != paNoError ) {
ERRORLOG( "Portaudio error in Pa_Initialize: " + QString( Pa_GetErrorText( err ) ) );
return 1;
@@ -81,9 +89,9 @@ int PortAudioDriver::connect()
paFloat32, /* 32 bit floating point output */
m_nSampleRate, // sample rate
m_nBufferSize, // frames per buffer
- 0, // number of buffers, if zero then use default minimum
+ //0, // number of buffers, if zero then use default minimum
portAudioCallback, /* specify our custom callback */
- this ); /* pass our data through to callback */
+ (void*)this ); /* pass our data through to callback */
if ( err != paNoError ) {
------------------------------------------------------------------------------
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel