Ross Bencina | 1 Sep 17:10 2010

Re: MAC SPDIF Problem

Hi Guys
 
I can reproduce what I think is the same crash using SoundFlower (http://cycling74.com/products/soundflower/). At least I get the same error at the same line.
 
I'm still on OS X 10.5.? (10.5.6 perhaps)
 
Steps to reproduce:
    1. Use Soundflower 2ch for input, built-in audio for output
    2. In a single process, first open a full duplex stream at 44.1k, start,stop, close, then open again at 96k, start, stop, close, then again at 44.1k, start... crash (run the stream for a few seconds in each case)
    3. The assertion failure below happens after the stream is running for the 3rd time
 
The message is:
 
||PaMacCore (AUHAL)|| Error on line 2143: err='-10863', msg=Audio Unit: cannot do in current context
pa_mac_core.c:2144: failed assertion `!err'
 
The error is being returned by AudioUnitRender in the capture IOProc. You can see the stack trace and variables in these screenshots I took from XCode:

Stack trace, error message on bottom line, local variables:
http://bit.ly/bulxbh
 
With variable view showing the state of the stream:
http://bit.ly/bOWrJN
 
Note that there is one weird thing: the stream indicates that both input and output are at 44.1k but inputSRConverter is not NULL.
 
By the way, are we really supposed to be passing through the ioActionFlags parameter of our IOProc through to AudioUnitRender?
 
I can try some things if you like but I'm a bit in the dark about how to debug this.
 
I'll ask on the Core Audio list too...
 
Thanks
 
Ross
 
 
----- Original Message -----
Sent: Monday, August 23, 2010 2:21 AM
Subject: Re: [Portaudio] MAC SPDIF Problem

Hi Bjorn,

I have a MAC-Mini and used the internal SPDIF port.
I updated to rev. 1537, but still the same problem.

Here the crash report: Thread 4 Crashed: 0 libSystem.B.dylib 0x94b59136 __semwait_signal_nocancel + 10 1 libSystem.B.dylib 0x94b52013 usleep$NOCANCEL$UNIX2003 + 61 2 libSystem.B.dylib 0x94b69685 abort + 85 3 libSystem.B.dylib 0x94b5e3db __assert_rtn + 101 4 org.FRL.PG-AMM 0x001a0bd6 AudioIOProc + 3846 (pa_mac_core.c:2002) 5 ...pple.audio.units.Components 0x70011e95 AUGenericOutputEntry + 9541 6 com.apple.audio.CoreAudio 0x91c12177 HP_IOProc::Call(AudioTimeStamp const&, AudioTimeStamp const&, AudioBufferList const*, AudioTimeStamp const&, AudioBufferList*) + 319 7 com.apple.audio.CoreAudio 0x91c11e68 IOA_Device::CallIOProcs(AudioTimeStamp const&, AudioTimeStamp const&, AudioTimeStamp const&) + 274 8 com.apple.audio.CoreAudio 0x91c11d44 HP_IOThread::PerformIO(AudioTimeStamp const&) + 1246 9 com.apple.audio.CoreAudio 0x91c1011f HP_IOThread::WorkLoop() + 1239 10 com.apple.audio.CoreAudio 0x91c0fc43 HP_IOThread::ThreadEntry(HP_IOThread*) + 17 11 com.apple.audio.CoreAudio 0x91c00480 CAPThread::Entry(CAPThread*) + 96 12 libSystem.B.dylib 0x94aae155 _pthread_start + 321 13 libSystem.B.dylib 0x94aae012 thread_start + 34 Thread 4 crashed with X86 Thread State (32-bit): eax: 0x0000003c ebx: 0x94b58c88 ecx: 0xb01ad71c edx: 0x94b59136 edi: 0x1a7f7db0 esi: 0xb01ad778 ebp: 0xb01ad758 esp: 0xb01ad71c ss: 0x0000001f efl: 0x00000247 eip: 0x94b59136 cs: 0x00000007 ds: 0x0000001f es: 0x0000001f fs: 0x0000001f gs: 0x00000037 cr2: 0x1b8d7000 and this from system log:
: ||PaMacCore (AUHAL)|| Error on line 2137: err='-10863', msg=Audio Unit: cannot do in current context : Assertion failed: (!err), function AudioIOProc, file src/hostapi/coreaudio/pa_mac_core.c, line 2138. Frank

Am 22.08.2010 09:00, schrieb Ross Bencina:
Hi Bjorn, Frank

If it's any help I've had reports of this on OSX 10.5 and 10.6 too. When the SPDIF external sample rate changes, PortAudio crashes.

There was also a report of a similar crash when using an RME fireface with external sync and changing the sample rate. Not sure if that's related or not.

Ross.


----- Original Message ----- From: "Bjorn Roche" <bjorn <at> xowave.com>
To: "Portaudio Mailing List" <portaudio <at> music.columbia.edu>
Sent: Sunday, August 22, 2010 10:33 AM
Subject: Re: [Portaudio] MAC SPDIF Problem


On Aug 20, 2010, at 7:05 AM, Frank Lichtner wrote:

Hi to all,

Hello Frank,


we still have the problem that PortAudio crashes on MAC when the  signal is coming from the build in SPDIF input and the sample rate  changes. This can be easily reproduced by connecting a DVD player to  the SPDIF input playing a CD and then a DVD or the other way round,  no matter. When the sample rate changes PortAudio asserts in  pa_mac_core.c, line 2103


Sorry I don't have time to look into this personally right now --  especially since I can't reproduce this at the moment. Which OS  version are you running and what hardware?

Perhaps you could find out exactly what the error is by printing it  out? Since err is clearly not equal to RING_BUFFER_EMPTY, there should  be some printout already from the ERR function (unless I am  misremembering how that all works), so just sending your stdout would  be useful.

Some "errors" are more like warnings or instructions to handle special cases. For example, perhaps the audio converter needs to be reset or something (although this should not be the case).

bjorn

-----------------------------
Bjorn Roche
XO Wave
Digital Audio Production and Post-Production Software
http://www.xowave.com
http://blog.bjornroche.com
http://myspace.com/xowave

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Denis | 1 Sep 22:41 2010
Picon

Can't link my QT project with the PortAudio lib (MinGW, WindowsXP).

Hi!

I add in my .pro file a line:
LIBS += lportaudio

but it gives me an error from MinGW: cannot find -lportaudio.

If I try to compile with that line:
LIBS += -L"c:\portaudio\"
(also I tried: LIBS += -L"c:\portaudio\lib" )

it gives me an error: "file.cpp: undefined reference to Pa_StartStream".

I don't know to link it correctly.. Does anyone have any suggestions? :)

By the way.. I can't compile PortAudio with MinGW. Is it necessary or I can just include .c and .h files into my
program and it will work without compiling 
portaudio?
Ross Bencina | 2 Sep 10:24 2010

Re: Can't link my QT project with the PortAudio lib (MinGW, WindowsXP).

Hi Denis

> I add in my .pro file a line:
> LIBS += lportaudio
>
> but it gives me an error from MinGW: cannot find -lportaudio.

you need to compile libportaudio first before you can link against it

One way or another you need to link with PortAudio object code. You can do 
this by including the right .c files in your project or by linking with the 
lib.

You can add all the correct PortAudio files to your Pro file but you will 
need to experiment to work out what include paths you need, what SDKs you 
need installed etc. This isn't too hard but you will probably have to 
resolve a number of errors along the way.

The alternative is to use the usual ./configure;make; process which will 
build the lib and then you should be able to do something like what you've 
described above.

Ross.

----- Original Message ----- 
From: "Denis" <intraden <at> mail.ru>
To: "portaudio" <portaudio <at> music.columbia.edu>
Sent: Thursday, September 02, 2010 6:41 AM
Subject: [Portaudio] Can't link my QT project with the PortAudio lib 
(MinGW,WindowsXP).

> Hi!
>
> I add in my .pro file a line:
> LIBS += lportaudio
>
> but it gives me an error from MinGW: cannot find -lportaudio.
>
> If I try to compile with that line:
> LIBS += -L"c:\portaudio\"
> (also I tried: LIBS += -L"c:\portaudio\lib" )
>
> it gives me an error: "file.cpp: undefined reference to Pa_StartStream".
>
> I don't know to link it correctly.. Does anyone have any suggestions? :)
>
> By the way.. I can't compile PortAudio with MinGW. Is it necessary or I 
> can just include .c and .h files into my program and it will work without 
> compiling
> portaudio?
> _______________________________________________
> Portaudio mailing list
> Portaudio <at> music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio 
Denis | 2 Sep 12:13 2010
Picon

Re: Can't link my QT project with the PortAudio lib (MinGW, WindowsXP).

Hi Ross!

> One way or another you need to link with PortAudio 
> object code. You can do this by including the right .c 
>> files in your project or by linking with the lib.
I really like this way! But I don't know what files I need to include in my .pro file :) I'll try to experiment
with including different .c files..

Thanks for the advice!

Denis.
Denis | 2 Sep 13:06 2010
Picon

Can't compile portaudio under Windows (MinGW + MSYS)... :)

Hi!

I need to compile portaudio under Windows but I get some problem.. I've done ./configure process
successfully but when I start the make process I get error:
----------
src/hostapi/wmme/.libs/pa_win_wmme.o: In function `QueryFormatSupported':
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:549: undefined
reference to `PaWin_InitializeWaveFormatExtensible'
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:555: undefined
reference to `PaWin_InitializeWaveFormatEx'
src/hostapi/wmme/.libs/pa_win_wmme.o: In function `InitializeWaveHandles':
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1751: undefined
reference to `PaWin_InitializeWaveFormatExtensible'
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1759: undefined
reference to `PaWin_InitializeWaveFormatEx'
src/hostapi/wmme/.libs/pa_win_wmme.o: In function `OpenStream':
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2260: undefined
reference to `PaWin_DefaultChannelMask'
C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2309: undefined
reference to `PaWin_DefaultChannelMask'
----------

Does anyone know how to solve this problem?
I'm using: "pa_stable_v19_20071207.tar.gz is current V19 posted December 7, 2007"
Bjorn Roche | 2 Sep 14:14 2010

Re: MAC SPDIF Problem

Thank you for finding a way to reproduce this, and also a mailing list reference. It's odd because I am pretty sure I tested this (that would have been in 10.4 or maybe 10.3) and the SR conversion automatically conformed when the SR of the device changed. Perhaps the code that did that is lost? It will take some time to sort this out.

The question of how PA should behave is, I think, fairly straightforward, at least in the best case:

- If you requested SR conversion (the default), the stream should continue to give you the correct rate if possible. If not possible, I am not sure if it should do the next best thing or stop, but it seems to me that the next best thing is likely to be error prone.

- If SR conversion was not selected, then I don't think it is necessary or possible to define the behavior, because the only possible behaviors are clearly not what the client wanted. While it strikes me that the most "correct" course of action is to stop playback, that might be unnecessarily jarring so I think the best course of action is to continue playing if possible, and if not possible (due to buffer size changes or whatever), playback should stop. OTOH, there may be a lot of exceptional cases that are hard to test here and stopping may be the most reliable thing.

bjorn

On Sep 1, 2010, at 11:29 AM, Ross Bencina wrote:

Further to my previous email, it looks like  kAudioUnitErr_CannotDoInCurrentContext is returned if there's a sample rate mismatch in the stream format:
 
This might explain the failure in Frank's case since the stream is still configured to use the old sample rate. I'm not sure why it would be a problem with Soundflower unless PA is having trouble telling it to change sample rate or something.
 
Obviously we shouldn't crash, but it does raise a question about how PA should behave in this case:
 
If the stream is opened at 44,1k and you change the incoming SPDIF to 48k should PA instantiate the sample rate converter and continue to provide the client with a 44.1k stream, or should it silently pass the data through as-if it was 44,1k but actually at 48k. This gets more complicated with full duplex streams.
 
Thoughts? Opinions?
 
Ross.

bjorn

-----------------------------
Bjorn Roche
XO Audio, LLC
Audio Software & Digital Audio Consulting

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Frank Lichtner | 2 Sep 15:03 2010
Picon

Re: MAC SPDIF Problem

Hi Bjorn,

one could, in the case you have to stop audio, give some notification that sample rate has changed, so that we could in our code react on this e.g. inform the user, change sample rate and restart the stream. It would be anyway a good thing to get informed by PA if sample rate has changed while a stream is running.

Frank

Am 02.09.2010 14:14, schrieb Bjorn Roche:
Thank you for finding a way to reproduce this, and also a mailing list reference. It's odd because I am pretty sure I tested this (that would have been in 10.4 or maybe 10.3) and the SR conversion automatically conformed when the SR of the device changed. Perhaps the code that did that is lost? It will take some time to sort this out.

The question of how PA should behave is, I think, fairly straightforward, at least in the best case:

- If you requested SR conversion (the default), the stream should continue to give you the correct rate if possible. If not possible, I am not sure if it should do the next best thing or stop, but it seems to me that the next best thing is likely to be error prone.

- If SR conversion was not selected, then I don't think it is necessary or possible to define the behavior, because the only possible behaviors are clearly not what the client wanted. While it strikes me that the most "correct" course of action is to stop playback, that might be unnecessarily jarring so I think the best course of action is to continue playing if possible, and if not possible (due to buffer size changes or whatever), playback should stop. OTOH, there may be a lot of exceptional cases that are hard to test here and stopping may be the most reliable thing.

bjorn

On Sep 1, 2010, at 11:29 AM, Ross Bencina wrote:

Further to my previous email, it looks like  kAudioUnitErr_CannotDoInCurrentContext is returned if there's a sample rate mismatch in the stream format:
 
This might explain the failure in Frank's case since the stream is still configured to use the old sample rate. I'm not sure why it would be a problem with Soundflower unless PA is having trouble telling it to change sample rate or something.
 
Obviously we shouldn't crash, but it does raise a question about how PA should behave in this case:
 
If the stream is opened at 44,1k and you change the incoming SPDIF to 48k should PA instantiate the sample rate converter and continue to provide the client with a 44.1k stream, or should it silently pass the data through as-if it was 44,1k but actually at 48k. This gets more complicated with full duplex streams.
 
Thoughts? Opinions?
 
Ross.

bjorn

-----------------------------
Bjorn Roche
XO Audio, LLC
Audio Software & Digital Audio Consulting

_______________________________________________ Portaudio mailing list Portaudio <at> music.columbia.edu http://music.columbia.edu/mailman/listinfo/portaudio
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Ross Bencina | 2 Sep 15:33 2010

Re: MAC SPDIF Problem

Hi Bjorn

Bjorn wrote:
> It's odd because I am pretty sure I tested this (that would have been in 
> 10.4 or maybe 10.3)
> and the SR conversion automatically conformed when the SR of the device 
> changed. Perhaps the code that did that is lost?

I've asked Bill S. to clarify, but the implication of his initial answer to 
my question is that perhaps this is a new 10.6 behavior to not automatically 
do SR conversion.
On CoreAudio-API Bill Stewart wrote:
>Yes, AUHAL won't do a rate conversion for you in 10.6.
http://osdir.com/ml/coreaudio-api/2010-09/msg00003.html

> It will take some time to sort this out.

I'm thinking of putting in a quick fix to the IOProc that checks for that 
error code and just zeros the buffer rather than crashing. What do you 
think?

I also think the PA IOProc needs an overhaul and to be split out into 
separate implementations for the different cases. Right now it tries to 
handle too many unrelated cases.

I agree with Frank that there should be an optional callback to notify the 
client that the sample rate has changed.

Part of the design space that we havn't explored is that when PA is slaved 
to an external clock source PA should tell the client what the SR is, not 
the client tell PA what the SR is. I.e. there could be three modes:

1. Client wants a specific sample rate (doesn't care if this is the hardware 
rate) => PA does SR conversion where necessary. always keep running.

2. Client wants specific hardware sample rate => PA fails/stops & notifies 
client if the rate changes or is unavailable.

3. Client slaves to external clock => PA tells client what the sample rate 
is, notifies client if SR changes but keeps running at the new SR.

makes sense?

Ross. 
Ross Bencina | 2 Sep 15:41 2010

Re: Can't compile portaudio under Windows (MinGW + MSYS)... :)

Hi Denis

> I'm using: "pa_stable_v19_20071207.tar.gz is current V19 posted December 
> 7, 2007"

I strongly recommend you try the latest SVN nightly snapshot. But in any 
case...

> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `QueryFormatSupported':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:549: 
> undefined reference to `PaWin_InitializeWaveFormatExtensible'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:555: 
> undefined reference to `PaWin_InitializeWaveFormatEx'

This means that the linker can'd find the function 
PaWin_InitializeWaveFormatExtensible.

A quick search of the .c files in the source tree...

-------
>grep -d PaWin_InitializeWaveFormatExtensible *.c
[snip]
File src\os\win\pa_win_waveformat.c:
void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
-------

Shows that the function is defined in src\os\win\pa_win_waveformat.c So you 
need to add that .c file.

If you continue that process you'll probably work most things out.

(note if you use grep you probably need a different option for recursive 
search than -d, I use Borland grep).

One thing to be careful of is that pa_win_hostapis.c defines which host apis 
get used, so you need to make sure that you add compiler options for the 
host apis you don't want eg

-DPA_NO_WASAPI -DPA_NO_ASIO

Ross.

----- Original Message ----- 
From: "Denis" <intraden <at> mail.ru>
To: <portaudio <at> music.columbia.edu>
Sent: Thursday, September 02, 2010 9:06 PM
Subject: [Portaudio] Can't compile portaudio under Windows (MinGW + MSYS)... 
:)

> Hi!
>
> I need to compile portaudio under Windows but I get some problem.. I've 
> done ./configure process successfully but when I start the make process I 
> get error:
> ----------
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `QueryFormatSupported':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:549: 
> undefined reference to `PaWin_InitializeWaveFormatExtensible'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:555: 
> undefined reference to `PaWin_InitializeWaveFormatEx'
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `InitializeWaveHandles':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1751: 
> undefined reference to `PaWin_InitializeWaveFormatExtensible'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1759: 
> undefined reference to `PaWin_InitializeWaveFormatEx'
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `OpenStream':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2260: 
> undefined reference to `PaWin_DefaultChannelMask'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2309: 
> undefined reference to `PaWin_DefaultChannelMask'
> ----------
>
> Does anyone know how to solve this problem?
> I'm using: "pa_stable_v19_20071207.tar.gz is current V19 posted December 
> 7, 2007"
> _______________________________________________
> Portaudio mailing list
> Portaudio <at> music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio 
Ross Bencina | 2 Sep 15:43 2010

Re: Can't compile portaudio under Windows (MinGW + MSYS)... :)

Hi Again Denis

This might help, it's the files I include in my sconscript for Windows:

portaudio/src/common/pa_skeleton.c
  portaudio/src/hostapi/asio/iasiothiscallresolver.cpp
  portaudio/src/common/pa_stream.c
  portaudio/src/common/pa_allocation.c
  portaudio/src/common/pa_trace.c
  portaudio/src/common/pa_converters.c
  portaudio/src/common/pa_cpuload.c
  portaudio/src/common/pa_dither.c
  portaudio/src/common/pa_front.c
  portaudio/src/common/pa_process.c
  portaudio/src/common/pa_debugprint.c
  portaudio/src/common/pa_ringbuffer.c

portaudio/src/hostapi/asio/pa_asio.cpp
  portaudio/src/os/win/pa_win_util.c
  portaudio/src/os/win/pa_win_waveformat.c
  portaudio/src/hostapi/dsound/pa_win_ds.c
  portaudio/src/hostapi/dsound/pa_win_ds_dynlink.c
  portaudio/src/hostapi/wmme/pa_win_wmme.c

Ross.

----- Original Message ----- 
From: "Denis" <intraden <at> mail.ru>
To: <portaudio <at> music.columbia.edu>
Sent: Thursday, September 02, 2010 9:06 PM
Subject: [Portaudio] Can't compile portaudio under Windows (MinGW + MSYS)... 
:)

> Hi!
>
> I need to compile portaudio under Windows but I get some problem.. I've 
> done ./configure process successfully but when I start the make process I 
> get error:
> ----------
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `QueryFormatSupported':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:549: 
> undefined reference to `PaWin_InitializeWaveFormatExtensible'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:555: 
> undefined reference to `PaWin_InitializeWaveFormatEx'
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `InitializeWaveHandles':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1751: 
> undefined reference to `PaWin_InitializeWaveFormatExtensible'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:1759: 
> undefined reference to `PaWin_InitializeWaveFormatEx'
> src/hostapi/wmme/.libs/pa_win_wmme.o: In function `OpenStream':
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2260: 
> undefined reference to `PaWin_DefaultChannelMask'
> C:\mingw\msys\1.0\home\Admin\portaudio/src/hostapi/wmme/pa_win_wmme.c:2309: 
> undefined reference to `PaWin_DefaultChannelMask'
> ----------
>
> Does anyone know how to solve this problem?
> I'm using: "pa_stable_v19_20071207.tar.gz is current V19 posted December 
> 7, 2007"
> _______________________________________________
> Portaudio mailing list
> Portaudio <at> music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio 

Gmane