Gilles Barges | 31 Jul 09:13 2014
Picon

CoreAudio error -50

Mac OSX 10.7, pa_stable_v19_20111121

hi there,

I tried to add a second Stream to my app.

A first stream is already started, it is always playing (either samples, either silence).

Then I open a second stream (same frequency) with no error.
At the time I call Pa_StartStream(), i have this message:
||PaMacCore (AUHAL)|| Error on line 2428: err='-50', msg=Unknown Error

I searched through PA sources at saw that this is an unknow CoreAudio error
It's the return code of AudioUnitRender()

And, in the same time Pa_StartStream() returns 0 (no error).

From there, the sound played by the first stream is incorrect, sliced, and timing information reported by its callback is weird, walkin like a crab.
the above error message is repeated about 10 times/second.
The 2nd stream seems not to work at all.

I have correctly embedded Pa_Initialise()/Pa_Terminate() calls.

I tried with
- same number of channels stereo+stereo, either stereo+mono
- same or different buffer size
yhat changed nothing.
The sample rates are always equal.









_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Garth Hjelte | 30 Jul 20:37 2014

Getting all possible samplerates of a device

Is there a function to get all possible input (and output, but I'm interested in input) sample rates of a
device? PaDeviceInfo just has DefaultSampleRate.

If not, would it be suggestible to just try the popular ones (or whatever I'm interested in) by calling
OpenStream() and seeing what fails?

Garth Hjelte
Sampler User
Gilles Barges | 29 Jul 17:00 2014
Picon

Re: How to prevent exceptions when stopping a stream ?



Expression 'pthread_join( self->thread, &pret )' failed in
'src/os/unix/pa_unix_util.c', line: 441

Expression 'PaUnixThread_Terminate( &stream->thread, !abort, &threadRes
)' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3102

Unanticipated host errorExpression 'pthread_join( self->thread, &pret )'
failed in 'src/os/unix/pa_unix_util.c', line: 441


Does anyone else know what the issue is?

I looked in pa_unix_util.c, and saw that these messages result from pthread_join() returning not zero.
Unfortunately, this return value is not given (EDEADLK, EINVAL, ESRCH?)

Jean-Michaël, could you patch pa_linux_utils.c 
replacing line 441 by
int ptj_return = pthread_join( self->thread, &pret );
if ( ptj_return != 0 ) {
  printf ( "pthread_join() returning error %d\n", ptj_return );
  goto error;
}


--
Gilles Barges.



_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Gilles Barges | 29 Jul 09:26 2014
Picon

Re: cannot play and record on MME


Le 25 juil. 2014 à 16:51, Gilles Barges a écrit :

It appears on the Web that audio input problems are not so rare with VirtualBox.
The first thing I shoud do is to try my app on a "real" Windows, not an emulated one.
Unfortunaltely, I have only a 32 bit Win7, and I have to recompile all my libs … :-(

I'll be back when it will be done

hello, I'm back with good news.

After 4 days of incredible headache, I could compile my app in 32 bits and run it on a 32 bit true Window box.

And I works as expected, that is recording and playing simultaneously. MME, DX & ASIO seem to work the same.

So yes, there is a problem with VirtualBox audio input, that makes it a poor audio development platform.

Has somebody tested a better virtual machine (host=MacOSX, guest=W7), even commercial ? 




_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Gilles Barges | 25 Jul 18:31 2014
Picon

Re: How to prevent exceptions when stopping a stream ?


hello Jean-Michaël,

some years ago I had problems with exceptions on Linux, this occured when I killed a thread by pthread_cancel()
If seemed that the cancellation was implemented by throwing an "uncatchable exception"
and I had a catch ( … ) in my thread.
Removing that generic catch permitted to pass the cancellation.
hope this helps...

Gilles.




Hello,

I am using the cpp bindings of portaudio.

When I stop a stream using MemFunCallbackStream::stop(), I sometimes get the following crash : 

Expression 'pthread_join( self->thread, &pret )' failed in 'src/os/unix/pa_unix_util.c', line: 441
Expression 'PaUnixThread_Terminate( &stream->thread, !abort, &threadRes )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3102
Unanticipated host errorExpression 'pthread_join( self->thread, &pret )' failed in 'src/os/unix/pa_unix_util.c', line: 441


How can I prevent this ? Even if I catch the exception, the program stops.

I am running on Linux, and tried on both my dev computer, with and without Pulseaudio, and an ARM board, with only ALSA.


Best regards,

-------
Jean-Michaël Celerier
Élève-ingénieur spécialisé en informatique
ENSEIRB-MATMECA, Université Bordeaux 1


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

--
Gilles Barges.



_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Jean-Michaël Celerier | 25 Jul 16:51 2014
Picon

How to prevent exceptions when stopping a stream ?

Hello,

I am using the cpp bindings of portaudio.

When I stop a stream using MemFunCallbackStream::stop(), I sometimes get the following crash : 

Expression 'pthread_join( self->thread, &pret )' failed in 'src/os/unix/pa_unix_util.c', line: 441

Expression 'PaUnixThread_Terminate( &stream->thread, !abort, &threadRes )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3102

Unanticipated host errorExpression 'pthread_join( self->thread, &pret )' failed in 'src/os/unix/pa_unix_util.c', line: 441



How can I prevent this ? Even if I catch the exception, the program stops.

I am running on Linux, and tried on both my dev computer, with and without Pulseaudio, and an ARM board, with only ALSA.


Best regards,

-------
Jean-Michaël Celerier
Élève-ingénieur spécialisé en informatique
ENSEIRB-MATMECA, Université Bordeaux 1
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Gilles Barges | 25 Jul 08:20 2014
Picon

Re: cannot play and record on MME

hello Phil

> wrote a mini-file-player application, using callback method.
Are you reading the file in your audio callback?!

surely not !

Note that one should not call any function that can block from the PortAudio callback. That includes fread(), malloc(), etc. 

my CB function does only copy or clear memory bytes, doesn't call any blocking function.  The audio file is entirely loaded in memory on init.

As an alternative to the callback, I recommend using the PortAudio blocking write function.

I want low latencies, so the callback method should be preferred, AFAIK
And, this is a port of a working app from Mac to Win, not a re-design :-)

Also try opening your recorder in a second stream.

Don't want to redesign… one stream is enough on Mac. 

Honnestly, I feel my design is correct. When not connecting the input, it works fairly well on Win7.

Meanwhile, I could test one another (emulated) hardware, with quite the same results.

It appears on the Web that audio input problems are not so rare with VirtualBox.
The first thing I shoud do is to try my app on a "real" Windows, not an emulated one.
Unfortunaltely, I have only a 32 bit Win7, and I have to recompile all my libs … :-(

I'll be back when it will be done

--
Gilles Barges.



On 7/21/14, 11:05 PM, Gilles Barges wrote:
hi there,

I've been using PA on MacOSX for some time, and wrote a mini-file-player
application, using callback method. Works well.

As I'm using only cross-platform libraries (PA, wxWidgets, sndfile...),
I tried to port my app 1st on Linux, then on MSW

On Linux, I had no problems. I must guess I have not paid attention to
what host API is selected, I'm using defaults.
And my player worked well.

On Windows, I compiled PA "out-of-the-box" (using MSYS ans TDM-GCC64),
so it gives me access to MME only (could you confirm?)
And my player didn't work !

The symptoms are :
The sound is played slowly, with cuts. Seems like a slice of sound is
played, then a slice of silence, and so on.
To debug, I set buffersize to 64K frames (1,3 seconds), and noticed the
Callback was called every 5 seconds approx. !
Now, if I Stop/Close the stream and Open/Start again, I have no sound at
all !

What I found:
when opening the stream, I ask it to play _and_ record, ie the 2nd & 3rd
args of Pa_OpenStream() are not NULL.
I tried to suppress recording (passing NULL as 2nd arg).
And it worked !
Unfortunately this is not a workaround for me as my final project needs
recording while playing.

Maybe my audio device is half-duplex only ?
(As I have a Mac, Linux and MSW run in VirtualBox, the device is one of
those VirtualBox offers)
Can I prevent strange behaviors like I described ?
is that a mimitation of MME ?

have a nice day
Gilles.






_______________________________________________
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

--
Gilles Barges.



_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Ross Bencina | 24 Jul 11:40 2014

[OT] Paper about lock-free message-passing based real-time file I/O

Hi Everyone,

Apologies if this is a bit off-topic, but it's probably of interest to 
some people here.

I just uploaded all of the materials for my paper "Interfacing Real-Time 
Audio and File I/O." There's a paper, slides, animation and example code 
(that uses PortAudio).

The paper is about using message passing and lock-free queues to 
implement real-time-safe asynchronous file I/O. It might be of interest 
to developers wanting to implement their own real-time file streaming 
code. The paper also describes a number of lock-free tricks that I think 
are generally useful for real-time audio programming.

All the details and links are here:

http://www.rossbencina.com/code/interfacing-real-time-audio-and-file-io

Many thanks to Phil Burk any others for helping with feedback on earlier 
drafts of the paper.

Please feel free to get in touch if you have any questions/comments.

Thanks,

Ross.
Gilles Barges | 22 Jul 08:05 2014
Picon

cannot play and record on MME

hi there,

I've been using PA on MacOSX for some time, and wrote a mini-file-player application, using callback method. Works well.

As I'm using only cross-platform libraries (PA, wxWidgets, sndfile...), I tried to port my app 1st on Linux, then on MSW

On Linux, I had no problems. I must guess I have not paid attention to what host API is selected, I'm using defaults.
And my player worked well.

On Windows, I compiled PA "out-of-the-box" (using MSYS ans TDM-GCC64), so it gives me access to MME only (could you confirm?)
And my player didn't work !

The symptoms are :
The sound is played slowly, with cuts. Seems like a slice of sound is played, then a slice of silence, and so on.
To debug, I set buffersize to 64K frames (1,3 seconds), and noticed the Callback was called every 5 seconds approx. !
Now, if I Stop/Close the stream and Open/Start again, I have no sound at all !

What I found:
when opening the stream, I ask it to play _and_ record, ie the 2nd & 3rd args of Pa_OpenStream() are not NULL.
I tried to suppress recording (passing NULL as 2nd arg).
And it worked !
Unfortunately this is not a workaround for me as my final project needs recording while playing.

Maybe my audio device is half-duplex only ?
(As I have a Mac, Linux and MSW run in VirtualBox, the device is one of those VirtualBox offers)
Can I prevent strange behaviors like I described ?
is that a mimitation of MME ?

have a nice day
Gilles.




_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Gilles Barges | 22 Jul 07:26 2014
Picon

Re: Designing a stream output using PA

hi Roland,

My solutions so far:
1. ...
2. As an alternative I was thinking to never call Pa_StopStream(), but fill the buffer in the callback with zeros, if no data is available. Does this make sense?
3. …

2 is for far the easiest solution. if your FIFO has datas, play these, else play zeros.
That's what I use and, apart a light CPU waste when playing silence, it works like a charm

Gilles




_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Roland Winklmeier | 21 Jul 18:50 2014
Picon

Designing a stream output using PA

Dear list,

I have a quick design question about PortAudio. I'm new to PortAudio and currently trying to improve a C++ voice library, which used to have its own host API implementations for alsa, CoreAudio, etc. Since I don't have the resources and knowledge to maintain them all, I decided to port all host API's to a cross platform abstraction library and after some investigations I found PortAudio which is perfect for my use case.

The first tests went well but now I'm a bit stuck in trying to find a good design for a specific problem:

Problem description:
My voice library is a kind of VoIP library. When voice is received from the server, the data packets are queued for playing in a FIFO buffer. I had chosen the callback I/O method which reads from the FIFO buffer and plays audio. The problem I'm facing now is, the stream from the server is not continuous, so I get data only when somebody is talking. At some point the stream stops and no more data is available and according to the docs I should call Pa_StopStream(). I don't have any means to know when the stream needs to stop except when all queued data has been played. This is in contrast to use cases, where a audio file is played and its clear when the stream needs to finish.

My solutions so far:
1. In a first very dirty try, I had a monitoring thread in the background. If the FIFO buffer is empty, Pa_StopStream() was called and the thread was sleeping for 100ms. After 100ms, the thread checks if data is available. If yes Pa_StartStream() is called again. The callback itself does return paComplete in case no data is available any more. So the callback shouldn't be called any more.
2. As an alternative I was thinking to never call Pa_StopStream(), but fill the buffer in the callback with zeros, if no data is available. Does this make sense?
3. Another alternative would be to monitor Pa_IsStreamActive in a thread and call Pa_StopStream() if it is inactive.

Ideally it would be possible to signal via the callback return value if the stream should stop or not. But even though the callback returns paComplete, I still have to call Pa_StopStream() from outside the callback.

So I'm wondering now - being a beginner with PortAudio and audio design in general - what would be the best option? Keeping the stream open and feed it with zeros or run a monitoring thread, which regularly checks if the stream needs to be stopped.

I'm sure you guys can come up with something more advanced.
Sorry for such a silly question and thanks very much for your help.

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

Gmane