[pulseaudio-discuss] pa_simple_write blocks too long

Stossel, Darrell (Insight/CSBU/RGS/Tucker) darrell.stossel at hp.com
Thu Jul 31 12:46:43 PDT 2014


I've been tasked with migrating our project from using two different sound libraries to use only pulse.
I'm stuck with 0.9.21 on RHEL6 as the release because too many customers are on this version to force a migration.

With this version, the asynchronous version I've found to be too unreliable. Asserts get thrown about 5% of the time for conditions that should not be true, even when using example code on the pulse site. So, I've gone to the simple api. Outside of our product, I've gotten both the record and play versions to work. Inside our product, the record part works fine. However, the playback version blocks in pa_simple_write (the first write when the buffer is made small, once full in a large buffer) with no sound ever being played. I've tried setting the buffer attributes to different settings with no success. Using pacmd, both the sink and the sink input are shown in the running state. No other applications are using audio at the same time. The audio I'm trying to send is continuous so (or at least it would be) I wouldn't think a suspension would occur due to underflow. I've also tried doing an open, write, close for each piece of audio with no luck. Our product is multi-threaded, but the audio is all in one thread. I've tried using the default device (having set the default) and using the device name directly to no avail in the pa_simple_new call.

As there are only 3 calls in the simple api, I don't know what to do at this point.
Does anyone have any ideas of where to look or what could be the issue?

Though the calls are basic, here is the code:

In a routine called to open the stream:

pulseSpecs.rate = 44100;
pulseSpecs.channels = 2;
pulseSpecs.bits = PA_SAMPLE_S16LE;
pulseAudio = pa_simple_new(NULL, "RGS Audio", PA_STREAM_PLAYBACK, NULL /* or alsa_output.pci-0000_00_1b.0.analog-stero */, "RGS Play", &pulseSpecs, NULL, NULL, NULL);

In a routine to receive the audio and send it to pulse:

Std::vector<unsigned char> rawSound is a parameter to the routine
If (rawSound.size() == 0) return;
pa_simple_write(pulseAudio, &rawSound[0], rawSound.size(), NULL);
//also tried copying rawSound to another buffer


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20140731/316ad1e2/attachment.html>


More information about the pulseaudio-discuss mailing list