}
/* Called from main thread */
-static void source_output_suspend_cb(pa_source_output *o, bool suspended) {
+static void source_output_suspend_cb(pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
struct userdata *u;
+ bool suspended;
pa_source_output_assert_ref(o);
pa_assert_ctl_context();
pa_assert_se(u = o->userdata);
+ /* State has not changed, nothing to do */
+ if (old_state == o->source->state)
+ return;
+
+ suspended = (o->source->state == PA_SOURCE_SUSPENDED);
+
/* If the source has been suspended, we need to handle this like
* a source change when the source is resumed */
if (suspended) {
}
/* Called from main thread */
-static void sink_input_suspend_cb(pa_sink_input *i, bool suspended) {
+static void sink_input_suspend_cb(pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
struct userdata *u;
+ bool suspended;
pa_sink_input_assert_ref(i);
pa_assert_ctl_context();
pa_assert_se(u = i->userdata);
+ /* State has not changed, nothing to do */
+ if (old_state == i->sink->state)
+ return;
+
+ suspended = (i->sink->state == PA_SINK_SUSPENDED);
+
/* If the sink has been suspended, we need to handle this like
* a sink change when the sink is resumed. Because the sink
* is suspended, we can set the variables directly. */
static bool sink_input_process_underrun_cb(pa_sink_input *i);
static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk);
static void sink_input_kill_cb(pa_sink_input *i);
-static void sink_input_suspend_cb(pa_sink_input *i, bool suspend);
+static void sink_input_suspend_cb(pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause);
static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest);
static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes);
static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes);
static void source_output_kill_cb(pa_source_output *o);
static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk);
-static void source_output_suspend_cb(pa_source_output *o, bool suspend);
+static void source_output_suspend_cb(pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause);
static void source_output_moving_cb(pa_source_output *o, pa_source *dest);
static pa_usec_t source_output_get_latency_cb(pa_source_output *o);
static void source_output_send_event_cb(pa_source_output *o, const char *event, pa_proplist *pl);
}
/* Called from main context */
-static void sink_input_suspend_cb(pa_sink_input *i, bool suspend) {
+static void sink_input_suspend_cb(pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
playback_stream *s;
pa_tagstruct *t;
+ bool suspend;
pa_sink_input_assert_ref(i);
+
+ /* State has not changed, nothing to do */
+ if (old_state == i->sink->state)
+ return;
+
+ suspend = (i->sink->state == PA_SINK_SUSPENDED);
+
s = PLAYBACK_STREAM(i->userdata);
playback_stream_assert_ref(s);
}
/* Called from main context */
-static void source_output_suspend_cb(pa_source_output *o, bool suspend) {
+static void source_output_suspend_cb(pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
record_stream *s;
pa_tagstruct *t;
+ bool suspend;
pa_source_output_assert_ref(o);
+
+ /* State has not changed, nothing to do */
+ if (old_state == o->source->state)
+ return;
+
+ suspend = (o->source->state == PA_SOURCE_SUSPENDED);
+
s = RECORD_STREAM(o->userdata);
record_stream_assert_ref(s);
void (*detach) (pa_sink_input *i); /* may be NULL */
/* If non-NULL called whenever the sink this input is attached
- * to suspends or resumes. Called from main context */
- void (*suspend) (pa_sink_input *i, bool b); /* may be NULL */
+ * to suspends or resumes or if the suspend cause changes.
+ * Called from main context */
+ void (*suspend) (pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause); /* may be NULL */
/* If non-NULL called whenever the sink this input is attached
* to suspends or resumes. Called from IO context */
bool suspend_cause_changed;
bool suspending;
bool resuming;
+ pa_sink_state_t old_state;
+ pa_suspend_cause_t old_suspend_cause;
pa_assert(s);
pa_assert_ctl_context();
}
}
+ old_suspend_cause = s->suspend_cause;
if (suspend_cause_changed) {
char old_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
char new_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
s->suspend_cause = suspend_cause;
}
+ old_state = s->state;
if (state_changed) {
pa_log_debug("%s: state: %s -> %s", s->name, pa_sink_state_to_string(s->state), pa_sink_state_to_string(state));
s->state = state;
}
}
- if (suspending || resuming) {
+ if (suspending || resuming || suspend_cause_changed) {
pa_sink_input *i;
uint32_t idx;
(i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND))
pa_sink_input_kill(i);
else if (i->suspend)
- i->suspend(i, state == PA_SINK_SUSPENDED);
+ i->suspend(i, old_state, old_suspend_cause);
}
if ((suspending || resuming || suspend_cause_changed) && s->monitor_source && state != PA_SINK_UNLINKED)
void (*detach) (pa_source_output *o); /* may be NULL */
/* If non-NULL called whenever the source this output is attached
- * to suspends or resumes. Called from main context */
- void (*suspend) (pa_source_output *o, bool b); /* may be NULL */
+ * to suspends or resumes or if the suspend cause changes.
+ * Called from main context */
+ void (*suspend) (pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause); /* may be NULL */
/* If non-NULL called whenever the source this output is attached
* to suspends or resumes. Called from IO context */
bool suspend_cause_changed;
bool suspending;
bool resuming;
+ pa_source_state_t old_state;
+ pa_suspend_cause_t old_suspend_cause;
pa_assert(s);
pa_assert_ctl_context();
}
}
+ old_suspend_cause = s->suspend_cause;
if (suspend_cause_changed) {
char old_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
char new_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
s->suspend_cause = suspend_cause;
}
+ old_state = s->state;
if (state_changed) {
pa_log_debug("%s: state: %s -> %s", s->name, pa_source_state_to_string(s->state), pa_source_state_to_string(state));
s->state = state;
}
}
- if (suspending || resuming) {
+ if (suspending || resuming || suspend_cause_changed) {
pa_source_output *o;
uint32_t idx;
(o->flags & PA_SOURCE_OUTPUT_KILL_ON_SUSPEND))
pa_source_output_kill(o);
else if (o->suspend)
- o->suspend(o, state == PA_SOURCE_SUSPENDED);
+ o->suspend(o, old_state, old_suspend_cause);
}
return ret;