summaryrefslogtreecommitdiffstats
path: root/src/polyp.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-15 21:18:18 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-15 21:18:18 +0000
commit710233bbf68c845ec5f1713679f4ff0b74c517de (patch)
treed6a88e5339790207f792d80cb00663af840f8250 /src/polyp.c
parentd8f13006614dca80de8903f5380b7cb718f26fcc (diff)
implement get_latency native command
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@72 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polyp.c')
-rw-r--r--src/polyp.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/polyp.c b/src/polyp.c
index bc6bff5a..d6d0f908 100644
--- a/src/polyp.c
+++ b/src/polyp.c
@@ -89,6 +89,9 @@ struct pa_stream {
void (*die_callback)(struct pa_stream*c, void *userdata);
void *die_userdata;
+
+ void (*get_latency_callback)(struct pa_stream*c, uint32_t latency, void *userdata);
+ void *get_latency_userdata;
};
static void command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
@@ -602,6 +605,8 @@ struct pa_stream* pa_stream_new(
s->die_userdata = NULL;
s->create_complete_callback = complete;
s->create_complete_userdata = NULL;
+ s->get_latency_callback = NULL;
+ s->get_latency_userdata = NULL;
s->name = strdup(name);
s->state = STREAM_CREATING;
@@ -895,3 +900,49 @@ void pa_context_stat(struct pa_context *c, void (*cb)(struct pa_context *c, uint
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_stat_callback, c);
}
+
+static void stream_get_latency_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+ struct pa_stream *s = userdata;
+ uint32_t latency;
+ assert(pd && s);
+
+ if (command != PA_COMMAND_REPLY) {
+ if (handle_error(s->context, command, t) < 0) {
+ context_dead(s->context);
+ return;
+ }
+
+ if (s->get_latency_callback)
+ s->get_latency_callback(s, (uint32_t) -1, s->get_latency_userdata);
+ return;
+ }
+
+ if (pa_tagstruct_getu32(t, &latency) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ s->context->error = PA_ERROR_PROTOCOL;
+ context_dead(s->context);
+ return;
+ }
+
+ if (s->get_latency_callback)
+ s->get_latency_callback(s, latency, s->get_latency_userdata);
+}
+
+void pa_stream_get_latency(struct pa_stream *p, void (*cb)(struct pa_stream *p, uint32_t latency, void *userdata), void *userdata) {
+ uint32_t tag;
+ struct pa_tagstruct *t;
+
+ p->get_latency_callback = cb;
+ p->get_latency_userdata = userdata;
+
+ if (cb == NULL)
+ return;
+
+ t = pa_tagstruct_new(NULL, 0);
+ assert(t);
+ pa_tagstruct_putu32(t, PA_COMMAND_GET_PLAYBACK_LATENCY);
+ pa_tagstruct_putu32(t, tag = p->context->ctag++);
+ pa_tagstruct_putu32(t, p->channel);
+ pa_pstream_send_tagstruct(p->context->pstream, t);
+ pa_pdispatch_register_reply(p->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_latency_callback, p);
+}