diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-07-15 20:51:55 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-07-15 20:51:55 +0000 |
commit | d8f13006614dca80de8903f5380b7cb718f26fcc (patch) | |
tree | a9c9e92a20cc5ef1dd718e81aafee61196541fe4 /src/polyp.c | |
parent | c36dadd2bdf01b26a3e5598def477b22a0b31e77 (diff) |
add pactl tool
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@71 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polyp.c')
-rw-r--r-- | src/polyp.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/polyp.c b/src/polyp.c index 75187d79..bc6bff5a 100644 --- a/src/polyp.c +++ b/src/polyp.c @@ -53,6 +53,9 @@ struct pa_context { void (*die_callback)(struct pa_context*c, void *userdata); void *die_userdata; + + void (*stat_callback)(struct pa_context*c, uint32_t count, uint32_t total, void *userdata); + void *stat_userdata; uint8_t auth_cookie[PA_NATIVE_COOKIE_LENGTH]; }; @@ -133,6 +136,9 @@ struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char * c->die_callback = NULL; c->die_userdata = NULL; + c->stat_callback = NULL; + c->stat_userdata = NULL; + pa_check_for_sigpipe(); return c; } @@ -834,3 +840,58 @@ void pa_stream_drain(struct pa_stream *s, void (*complete) (struct pa_stream*s, pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_drain_callback, s); } + +void pa_context_exit(struct pa_context *c) { + struct pa_tagstruct *t; + t = pa_tagstruct_new(NULL, 0); + assert(t); + pa_tagstruct_putu32(t, PA_COMMAND_EXIT); + pa_tagstruct_putu32(t, c->ctag++); + pa_pstream_send_tagstruct(c->pstream, t); +} + +static void context_stat_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) { + struct pa_context *c = userdata; + uint32_t total, count; + assert(pd && c); + + if (command != PA_COMMAND_REPLY) { + if (handle_error(c, command, t) < 0) { + context_dead(c); + return; + } + + if (c->stat_callback) + c->stat_callback(c, (uint32_t) -1, (uint32_t) -1, c->stat_userdata); + return; + } + + if (pa_tagstruct_getu32(t, &count) < 0 || + pa_tagstruct_getu32(t, &total) < 0 || + !pa_tagstruct_eof(t)) { + c->error = PA_ERROR_PROTOCOL; + context_dead(c); + return; + } + + if (c->stat_callback) + c->stat_callback(c, count, total, c->stat_userdata); +} + +void pa_context_stat(struct pa_context *c, void (*cb)(struct pa_context *c, uint32_t count, uint32_t total, void *userdata), void *userdata) { + uint32_t tag; + struct pa_tagstruct *t; + + c->stat_callback = cb; + c->stat_userdata = userdata; + + if (cb == NULL) + return; + + t = pa_tagstruct_new(NULL, 0); + assert(t); + pa_tagstruct_putu32(t, PA_COMMAND_STAT); + pa_tagstruct_putu32(t, tag = c->ctag++); + pa_pstream_send_tagstruct(c->pstream, t); + pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_stat_callback, c); +} |