summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 74971035..4102f31d 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 e62c6c24..95007af4 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;