Bug 92148 - pulseaudio jack modules drop samples on low fragment sizes
Summary: pulseaudio jack modules drop samples on low fragment sizes
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: modules (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-27 22:16 UTC by Michał Zegan
Modified: 2018-07-30 09:59 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Michał Zegan 2015-09-27 22:16:04 UTC
I am running pulseaudio. Sometimes I want to run jack, my card is a realtek HD Audio one, and I run jackd with 128 fragments and 2 periods.
When I do this, and then switch pulseaudio to jack using module-jack-sink and module-jack-source, the sound from pulseaudio works and goes over jack, but it encounters often dropouts. Sound from an app directly connected to jack is fine, as is sound going via pulse to jack when it is using 256 fragments/2 periods.
Comment 1 Raymond 2015-09-28 00:47:35 UTC
do you mean Jack is running with 2 periods of 256 frames ?

this mean that pulseaudio should reject any client request latency lower than the jack server
Comment 2 Alexander E. Patrakov 2015-09-28 02:24:26 UTC
Raymond, let's not reiterate over the relationship between the sink's minimum wakeup period and the client latency. PulseAudio cannot reject this case, because it can also appear because of stream-moving in pavucontrol. Please see bug 66962 (wrongly closed as fixed, even though it is only worked around). The long-term plan in description there (about timer-based emulation) is spot on, and that suggestion has never been implemented.
Comment 3 Raymond 2015-09-28 03:31:00 UTC
module-jack-sink only support fixed latency and does not support rewind

although you may deduce the jack server use which alsa card since pulseaudio need to release that card to jackd 

pulseaudio still unable to change the hardware volume control of the sound card,

any volume change was force to use software volume when the sink does not support rewind
Comment 4 Michał Zegan 2015-09-28 06:35:35 UTC
In this specific case it is 128 fragments and 2 periods. in case of 256, it works correctly, in case of 128 it drops samples.
Comment 5 Raymond 2015-09-28 15:33:24 UTC
http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/src/modules/jack/module-jack-sink.c?id=311654766207b3776e2618ae63ac35115db48bbd

module-jack-sink/source: Set fixed latency correctly on creation


http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/src/modules/jack/module-jack-sink.c?id=29f064aa3d3a83e275361aad3f9e7efdc84b8ad0

do jack protcol really support rewind at such low latency



jackd -p default is 1024 but you are using 128 or 256
Comment 6 Raymond 2015-09-28 15:46:18 UTC
what is the minimum period size when you using aplay without any underrun ? 32, 64, 128, 256, 512

aplay -Dhw:0,0 --period-size=32 --buffer-size=64 stereo.wav
Comment 7 Michał Zegan 2015-09-28 16:01:11 UTC
Had to use pasuspender, used this command without any changes just with my own file, and just changing period size, leaving buffer size intact, as I actually do not know how to change it, like I should double buffer size when doubling period size? if not, then 256 was the first... normal one
Comment 8 Raymond 2015-09-29 12:08:03 UTC
    jack_port_get_latency_range(u->port[0], JackPlaybackLatency, &r);
    n = r.max * pa_frame_size(&u->sink->sample_spec);
    pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(n, &u->sink->sample_spec));


what is your jack 's latency and pulseaudio's fixed latency ?
Comment 9 Michał Zegan 2015-09-29 20:02:01 UTC
Actually in case of 2 periods/128 fragments, current latency is around 7 ms, fixed one is 5.33 ms
Comment 10 Raymond 2015-09-30 02:45:54 UTC
(In reply to Michał Zegan from comment #7)
> Had to use pasuspender, used this command without any changes just with my
> own file, and just changing period size, leaving buffer size intact, as I
> actually do not know how to change it, like I should double buffer size when
> doubling period size? if not, then 256 was the first... normal one

you have to stop jackd and pulseaudio

128 bytes is the minimum period bytes of snd-hda-intel , there are two choices if you get underrun when using aplay 

a) increase number of periods to 3, 4, 5, .....

b) increase period size and buffer size and keep the number of periods at 2
Comment 11 Raymond 2015-09-30 02:56:50 UTC
http://jackaudio.org/files/docs/html/group__LatencyFunctions.html

you have to ask the author why pulseaudio only has JackPlaybackLatency but no JackCaptureLatency
Comment 12 Raymond 2015-09-30 05:23:48 UTC
(In reply to Alexander E. Patrakov from comment #2)
> Raymond, let's not reiterate over the relationship between the sink's
> minimum wakeup period and the client latency. PulseAudio cannot reject this
> case, because it can also appear because of stream-moving in pavucontrol.
> Please see bug 66962 (wrongly closed as fixed, even though it is only worked
> around). The long-term plan in description there (about timer-based
> emulation) is spot on, and that suggestion has never been implemented.

http://jackaudio.org/files/docs/html/index.html


calling jack_client_open() to connect to the JACK server.
registering "ports" to enable data to be moved to and from your application.
registering a "process callback" which will be called at the right time by the JACK server.
telling JACK that your application is ready to start processing data.

 it is JACK server call jack_process callback and pulseaudio server have to supply enough frames
Comment 13 Michał Zegan 2015-09-30 09:31:28 UTC
Well, I actually did not run jackd, and pulseaudio was suspended, I depend on speech for usage of the computer because I am blind, so turning pa completely off is not an option. Suspending it allowed access to hw0,.
Comment 14 Michał Zegan 2017-05-03 14:27:05 UTC
Hello!
After few years it is, I have tried testing aplay directly on sound card again.
When ran on sysdefault pcm, minimum possible is buffer size 512, period size 256 (does that means two periods?). 128/2 does xrun. However:
running on pcm hw, i can go down to 64 period size and 128 buffer size and it plays correctly. It starts heavily underrunning below that, when using buffer size 64 and period size 32.
Comment 15 GitLab Migration User 2018-07-30 09:59:50 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/158.


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.