diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-15 11:34:56 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-15 11:34:56 +0000 |
commit | c5c555e1b78f4301abe1e9ee46d65eb8f215ee53 (patch) | |
tree | ff5372ff4beda60083fd7d9b1b28071077e50884 /audio/sink.c | |
parent | f802c1c270aadd8e6c019cce1ee6a89f5c784a65 (diff) |
Fix resuming of stream on rapid unix client reconnects
Diffstat (limited to 'audio/sink.c')
-rw-r--r-- | audio/sink.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/audio/sink.c b/audio/sink.c index f7052fb6..bdbabab2 100644 --- a/audio/sink.c +++ b/audio/sink.c @@ -59,6 +59,8 @@ struct sink { struct pending_request *c; DBusConnection *conn; gboolean initiator; + gboolean suspending; + gboolean resume; }; static void pending_connect_free(struct pending_request *c) @@ -108,6 +110,8 @@ void stream_state_changed(struct avdtp_stream *stream, avdtp_state_t old_state, } break; case AVDTP_STATE_OPEN: + sink->suspending = FALSE; + if (old_state == AVDTP_STATE_CONFIGURED) dbus_connection_emit_signal(dev->conn, dev->path, AUDIO_SINK_INTERFACE, @@ -117,13 +121,14 @@ void stream_state_changed(struct avdtp_stream *stream, avdtp_state_t old_state, if (!sink->initiator) break; - if (sink->c && sink->c->pkt) { + if (sink->resume || (sink->c && sink->c->pkt)) { cmd_err = avdtp_start(sink->session, stream); if (cmd_err < 0) { error("Error on avdtp_start %s (%d)", strerror(-cmd_err), cmd_err); goto failed; } + sink->resume = FALSE; } else c = sink->c; @@ -370,7 +375,7 @@ int sink_get_config(struct device *dev, int sock, struct ipc_packet *req, int err; struct pending_request *c = NULL; - if (sink->state == AVDTP_STATE_STREAMING) + if (!sink->suspending && sink->state == AVDTP_STATE_STREAMING) goto proceed; if (sink->c) { @@ -390,7 +395,10 @@ int sink_get_config(struct device *dev, int sock, struct ipc_packet *req, err = avdtp_discover(sink->session, discovery_complete, dev); else if (sink->state < AVDTP_STATE_STREAMING) err = avdtp_start(sink->session, sink->stream); - else + else if (sink->suspending) { + sink->resume = TRUE; + err = 0; + } else err = -EINVAL; if (err < 0) @@ -451,8 +459,10 @@ void sink_set_state(struct device *dev, avdtp_state_t state) case AVDTP_STATE_STREAMING: if (state == AVDTP_STATE_OPEN) { err = avdtp_suspend(sink->session, sink->stream); - if (err == 0) + if (err == 0) { + sink->suspending = TRUE; return; + } } else if (state == AVDTP_STATE_IDLE) { err = avdtp_close(sink->session, sink->stream); |