mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
correct latency calculation
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@197 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
1231598206
commit
fbefe67d52
4 changed files with 21 additions and 4 deletions
1
doc/todo
1
doc/todo
|
|
@ -19,6 +19,7 @@
|
|||
- input latency
|
||||
- fix tcp/native
|
||||
- suid
|
||||
- add volume to create_stream command in native protocol
|
||||
|
||||
** later ***
|
||||
- xmlrpc/http
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue