diff options
author | Pierre Ossman <ossman@cendio.se> | 2006-03-08 12:16:51 +0000 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2006-03-08 12:16:51 +0000 |
commit | 8c65cdcb6e1872470f66a97a1c70418a688d4490 (patch) | |
tree | 68a24a2cb18ed320a71d1c257b26538633e1ab72 /polyp/polyp.c | |
parent | 9dd5f99aaa41c94b0ca89701282a9564f24e88fe (diff) |
Properly terminate stream in polypaudio plugin
Some applications like to call prepare over and over again, recreating
the stream each time. Previously we just cleaned up the local end each
time, but this makes sure the server also releases its resources.
Signed-off-by: Pierre Ossman <ossman@cendio.se>
Diffstat (limited to 'polyp/polyp.c')
-rw-r--r-- | polyp/polyp.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/polyp/polyp.c b/polyp/polyp.c index 0b25ae5..c6bc5e1 100644 --- a/polyp/polyp.c +++ b/polyp/polyp.c @@ -182,6 +182,32 @@ int polyp_wait_operation(snd_polyp_t *p, pa_operation *o) return 0; } +int polyp_wait_stream_state(snd_polyp_t *p, pa_stream *stream, pa_stream_state_t target) +{ + int err; + pa_stream_state_t state; + + assert(p && stream && (p->state == POLYP_STATE_READY)); + + while (1) { + state = pa_stream_get_state(stream); + + if (state == PA_STREAM_FAILED) + return -EIO; + + if (state == target) + break; + + p->state = POLYP_STATE_POLLING; + err = pa_mainloop_iterate(p->mainloop, 1, NULL); + p->state = POLYP_STATE_READY; + if (err < 0) + return -EIO; + } + + return 0; +} + snd_polyp_t *polyp_new() { snd_polyp_t *p; |