summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-07-23 16:50:16 +0200
committerLennart Poettering <lennart@poettering.net>2008-07-23 16:50:16 +0200
commit1f10ca4e4bb1d1181cf16d6998e71d2be1fb1b19 (patch)
treefb6444cee421db48c810259c649ca64d671af69f /src
parent7140bdd9a56d5b5f14b2300abb4c891cbfb75395 (diff)
don't break if we fail to resume access to an audio device
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/sink.c17
-rw-r--r--src/pulsecore/source.c17
2 files changed, 26 insertions, 8 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 749710355..4102f31d0 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -261,22 +261,31 @@ pa_sink* pa_sink_new(
static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
int ret;
pa_bool_t suspend_change;
+ pa_sink_state_t original_state;
pa_assert(s);
if (s->state == state)
return 0;
+ original_state = s->state;
+
suspend_change =
- (s->state == PA_SINK_SUSPENDED && PA_SINK_IS_OPENED(state)) ||
- (PA_SINK_IS_OPENED(s->state) && state == PA_SINK_SUSPENDED);
+ (original_state == PA_SINK_SUSPENDED && PA_SINK_IS_OPENED(state)) ||
+ (PA_SINK_IS_OPENED(original_state) && state == PA_SINK_SUSPENDED);
if (s->set_state)
if ((ret = s->set_state(s, state)) < 0)
- return -1;
+ return ret;
if (s->asyncmsgq)
- pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
+ if ((ret = pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL)) < 0) {
+
+ if (s->set_state)
+ s->set_state(s, original_state);
+
+ return ret;
+ }
s->state = state;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index e62c6c247..95007af43 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -224,22 +224,31 @@ pa_source* pa_source_new(
static int source_set_state(pa_source *s, pa_source_state_t state) {
int ret;
pa_bool_t suspend_change;
+ pa_source_state_t original_state;
pa_assert(s);
if (s->state == state)
return 0;
+ original_state = s->state;
+
suspend_change =
- (s->state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(state)) ||
- (PA_SOURCE_IS_OPENED(s->state) && state == PA_SOURCE_SUSPENDED);
+ (original_state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(state)) ||
+ (PA_SOURCE_IS_OPENED(original_state) && state == PA_SOURCE_SUSPENDED);
if (s->set_state)
if ((ret = s->set_state(s, state)) < 0)
- return -1;
+ return ret;
if (s->asyncmsgq)
- pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
+ if ((ret = pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL)) < 0) {
+
+ if (s->set_state)
+ s->set_state(s, original_state);
+
+ return ret;
+ }
s->state = state;