diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-13 13:26:44 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-13 13:26:44 +0000 |
commit | fbefe67d52eb89a429505c653d1ea4ce73d4f4e7 (patch) | |
tree | 662d7e8eb69b53a632353a742c7e5a4c9d70682d /polyp | |
parent | 12315982066ee1044840b598624920f8028c7924 (diff) |
correct latency calculation
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@197 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp')
-rw-r--r-- | polyp/module-alsa-sink.c | 8 | ||||
-rw-r--r-- | polyp/module-oss.c | 8 | ||||
-rw-r--r-- | polyp/sink-input.c | 8 |
3 files changed, 20 insertions, 4 deletions
diff --git a/polyp/module-alsa-sink.c b/polyp/module-alsa-sink.c index 95bb81f1..55e719c9 100644 --- a/polyp/module-alsa-sink.c +++ b/polyp/module-alsa-sink.c @@ -144,6 +144,7 @@ static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, } static pa_usec_t sink_get_latency_cb(struct pa_sink *s) { + pa_usec_t r = 0; struct userdata *u = s->userdata; snd_pcm_sframes_t frames; assert(s && u && u->sink); @@ -157,7 +158,12 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) { if (frames < 0) frames = 0; - return pa_bytes_to_usec(frames * u->frame_size, &s->sample_spec); + r += pa_bytes_to_usec(frames * u->frame_size, &s->sample_spec); + + if (u->memchunk.memblock) + r += pa_bytes_to_usec(u->memchunk.length, &s->sample_spec); + + return r; } int pa__init(struct pa_core *c, struct pa_module*m) { diff --git a/polyp/module-oss.c b/polyp/module-oss.c index 51cc42ef..b4e011d8 100644 --- a/polyp/module-oss.c +++ b/polyp/module-oss.c @@ -162,6 +162,7 @@ static void io_callback(struct pa_iochannel *io, void*userdata) { } static pa_usec_t sink_get_latency_cb(struct pa_sink *s) { + pa_usec_t r = 0; int arg; struct userdata *u = s->userdata; assert(s && u && u->sink); @@ -172,7 +173,12 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) { return 0; } - return pa_bytes_to_usec(arg, &s->sample_spec); + r += pa_bytes_to_usec(arg, &s->sample_spec); + + if (u->memchunk.memblock) + r += pa_bytes_to_usec(u->memchunk.length, &s->sample_spec); + + return r; } int pa__init(struct pa_core *c, struct pa_module*m) { diff --git a/polyp/sink-input.c b/polyp/sink-input.c index b0096182..7763f261 100644 --- a/polyp/sink-input.c +++ b/polyp/sink-input.c @@ -112,12 +112,16 @@ void pa_sink_input_kill(struct pa_sink_input*i) { } pa_usec_t pa_sink_input_get_latency(struct pa_sink_input *i) { + pa_usec_t r = 0; assert(i); if (i->get_latency) - return i->get_latency(i); + r += i->get_latency(i); - return 0; + if (i->resampled_chunk.memblock) + r += pa_bytes_to_usec(i->resampled_chunk.length, &i->sample_spec); + + return r; } int pa_sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) { |