summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2016-08-13 01:12:31 +0300
committerTanu Kaskinen <tanuk@iki.fi>2017-04-06 22:57:23 +0300
commitb6777d7f090d4e765c93709e3a9ca178e82ba954 (patch)
tree10179c02bd04be1f2280517c67d48dd4db5058a2
parentdf92274787edc2d5cba32df3c9c191d8378f8325 (diff)
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.
-rw-r--r--src/modules/module-pipe-sink.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index da650211..1c688d77 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -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);