Bug 64284

Summary: Shorter-than-prebuf streams are silent if started corked
Product: PulseAudio Reporter: Tanu Kaskinen <tanuk>
Component: coreAssignee: Tanu Kaskinen <tanuk>
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Test program for reproducing the bug
Quick hack to fix (or work around) the bug

Description Tanu Kaskinen 2013-05-06 15:52:04 UTC
If a stream is shorter than prebuf, and the stream is started in the corked state, its audio will get discarded when uncorking.

I'll attach a program that reproduces the issue, and a fix for the bug. The fix is a quick hack, and probably not suitable as the final solution. I haven't investigated the root cause myself that deeply yet, but I was told that the audio gets discarded during rewinding, so the proper fix probably involves modifying the rewinding code.

How to compile test.c:

gcc test.c -std=c99 $(pkg-config --cflags --libs libpulse) -lm -o test
Comment 1 Tanu Kaskinen 2013-05-06 15:56:18 UTC
Created attachment 78933 [details]
Test program for reproducing the bug

The test program does the following:
 * creates a stream with PA_STREAM_START_CORKED and 400 ms prebuf
 * writes 200 ms long sine wave
 * calls pa_stream_drain() (the operation doesn't complete before uncorking)
 * waits 10 seconds
 * uncorks the stream
Comment 2 Tanu Kaskinen 2013-05-06 15:57:49 UTC
Created attachment 78934 [details] [review]
Quick hack to fix (or work around) the bug
Comment 3 Tanu Kaskinen 2013-05-06 16:01:57 UTC
I will try to come up with a cleaner fix.
Comment 4 Tanu Kaskinen 2013-05-07 15:14:38 UTC
Patch sent to the mailing list: http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/16918

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.