mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
pipe-sink: set correct latency
The old pa_sink_set_fixed_latency() call didn't take into account that other places use pa_frame_align() on the pa_pipe_buf() result, so the configured latency could be sometimes slightly too high. Adding a buffer_size variable in userdata makes it a bit easier to keep all places that deal with the buffer size in sync.
This commit is contained in:
parent
df92274787
commit
b6777d7f09
1 changed files with 6 additions and 3 deletions
|
|
@ -75,6 +75,7 @@ struct userdata {
|
|||
|
||||
char *filename;
|
||||
int fd;
|
||||
size_t buffer_size;
|
||||
|
||||
pa_memchunk memchunk;
|
||||
|
||||
|
|
@ -123,7 +124,7 @@ static int process_render(struct userdata *u) {
|
|||
pa_assert(u);
|
||||
|
||||
if (u->memchunk.length <= 0)
|
||||
pa_sink_render(u->sink, pa_frame_align(pa_pipe_buf(u->fd), &u->sink->sample_spec), &u->memchunk);
|
||||
pa_sink_render(u->sink, u->buffer_size, &u->memchunk);
|
||||
|
||||
pa_assert(u->memchunk.length > 0);
|
||||
|
||||
|
|
@ -306,8 +307,10 @@ int pa__init(pa_module *m) {
|
|||
|
||||
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
|
||||
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||
pa_sink_set_max_request(u->sink, pa_frame_align(pa_pipe_buf(u->fd), &u->sink->sample_spec));
|
||||
pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(pa_pipe_buf(u->fd), &u->sink->sample_spec));
|
||||
|
||||
u->buffer_size = pa_frame_align(pa_pipe_buf(u->fd), &u->sink->sample_spec);
|
||||
pa_sink_set_max_request(u->sink, u->buffer_size);
|
||||
pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->buffer_size, &u->sink->sample_spec));
|
||||
|
||||
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
|
||||
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue