CoreAudio implementation doesn't support non-interleaved ReadStream and WriteStream
There is no test for this case either.
See mailing list discussion thread 19/2/2008:
Re: [Portaudio] ASIO Blocking I/O Patch Implementation (a ring buffercontaining frames, not bytes)
> So I took a look at pa_mac_core_blocking.c, what I noticed is:
>
> - It doesn't seem to use the buffer processor
>
> - It doesn't appear to handle non-interleaved calls to ReadStream/
> WriteStream (shall I create a ticket for that?). This particular
> case is one of the reasons why Sven is using the buffer processor on
> the ReadStream()/WriteStream() side of the queue.
>
Yes, since that sounds like a major issue and I won't be able to
address that anytime soon. Is there a test for it?
[nope]
There is a ticket to implement the test: #83
See mailing list discussion thread 19/2/2008:
Re: [Portaudio] ASIO Blocking I/O Patch Implementation (a ring buffercontaining frames, not bytes)
> So I took a look at pa_mac_core_blocking.c, what I noticed is:
>
> - It doesn't seem to use the buffer processor
>
> - It doesn't appear to handle non-interleaved calls to ReadStream/
> WriteStream (shall I create a ticket for that?). This particular
> case is one of the reasons why Sven is using the buffer processor on
> the ReadStream()/WriteStream() side of the queue.
>
Yes, since that sounds like a major issue and I won't be able to
address that anytime soon. Is there a test for it?
[nope]
There is a ticket to implement the test: #83
Leave a comment
A long time ago Roman M. Shulakov wrote:
I believe there might be a bug in a MacOS part when playing audio from separate non-interleaved buffers using blocking API. If I got it right, one needs to
OR 'paNonInterleaved' flag with a sample format in use when describing PA stream parameters.
After this Pa_WriteStream() will take an array of (void *) pointers to separate buffers, one per channel, instead of a pointer to one large interleaved buffer. This works nicely on Linux. On OSX however, Pa_WriteStream() never returns. I traced it down to internal ring buffer having size of zero thus never being ready to accept a single byte of data. This condition seems to be caused by 'computeSampleSizeFromFormat()' and 'computeSampleSizeFromFormatPow2()' procs in 'pa_mac_core_blocking.c' not expecting any extra flags OR'ed with a sample format.
Next I tried to help it by changing lines 79 and 94 from:
switch( format ) {
to:
switch( format & (~paNonInterleaved) ) {
This gave an internal ring buffer a reasonable size, however it also caused a memory corruption in CoreAudo RT thread (I think). Any ideas?
I believe there might be a bug in a MacOS part when playing audio from separate non-interleaved buffers using blocking API. If I got it right, one needs to
OR 'paNonInterleaved' flag with a sample format in use when describing PA stream parameters.
After this Pa_WriteStream() will take an array of (void *) pointers to separate buffers, one per channel, instead of a pointer to one large interleaved buffer. This works nicely on Linux. On OSX however, Pa_WriteStream() never returns. I traced it down to internal ring buffer having size of zero thus never being ready to accept a single byte of data. This condition seems to be caused by 'computeSampleSizeFromFormat()' and 'computeSampleSizeFromFormatPow2()' procs in 'pa_mac_core_blocking.c' not expecting any extra flags OR'ed with a sample format.
Next I tried to help it by changing lines 79 and 94 from:
switch( format ) {
to:
switch( format & (~paNonInterleaved) ) {
This gave an internal ring buffer a reasonable size, however it also caused a memory corruption in CoreAudo RT thread (I think). Any ideas?
It looks like the fix is non-trivial. The implementation uses the ringbuffer to write data to CoreAudio. We probably need to interleave the data as it is written to the ringbuffer and then make the back iend run in interleaved mode.
For now I just added code to detect paNonInterleaved and return paSampleFormatNotSupported. I also fixed the switch statements that return sample size.
For now I just added code to detect paNonInterleaved and return paSampleFormatNotSupported. I also fixed the switch statements that return sample size.