Bug 101121 - padsp: misaligned fragment size or odd return from read() will cause pa_stream_write() to fail
Summary: padsp: misaligned fragment size or odd return from read() will cause pa_strea...
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: tools (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 99067
  Show dependency treegraph
 
Reported: 2017-05-20 15:48 UTC by aiju-freedesktop
Modified: 2017-06-04 22:30 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description aiju-freedesktop 2017-05-20 15:48:07 UTC
Since commit 150ace90f3808bbb7240e18a11140d66a7bda146 pulseaudio will cause pa_stream_write() to fail if supplied with a number of bytes that is not a multiple of the frame size. However padsp does not cope with this, in particular it will generate fragment sizes that are not multiples of the frame size (e.g. 7350 bytes for 44100 Hz 16-bit stereo).
It will also fail if read() returned a number of bytes that is not multiple of the frame size.
Comment 1 Tanu Kaskinen 2017-05-22 19:35:55 UTC
Regression, so marking as a release blocker.
Comment 2 Arun Raghavan 2017-05-31 06:19:08 UTC
Could you try this patch to see if it helps?

https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-May/028259.html
Comment 3 aiju-freedesktop 2017-05-31 18:35:32 UTC
Thanks, but your patch is not quite correct. I had to change

+            i->leftover = r - to_write;

to

+            i->leftover += r - to_write;

or else it would fail trying to memmove ~2**63 bytes...

With this correction it fixes the issue (at least in my brief test).
Comment 4 aiju-freedesktop 2017-05-31 18:42:01 UTC
I think it would also be helpful to fix the fragment size calculation by moving

    i->fragment_size = (i->fragment_size/fs)*fs;

in fix_metrics to the end of the function (just before the debug prints).
Comment 5 Arun Raghavan 2017-06-01 06:57:54 UTC
Good catch on the leftover. Will fix.

Want to write up a patch for the fragment size thing?
Comment 6 Tanu Kaskinen 2017-06-04 22:30:59 UTC
Arun's patch is now in master, closing bug.


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.