summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-10-26 19:32:04 +0100
committerLennart Poettering <lennart@poettering.net>2008-10-26 19:32:04 +0100
commitadc2973c8dfab862d4333e0c1206995cd2df20c6 (patch)
treee74b9b79f36cfe7cd42c6261844009c39f5d6074 /src/pulsecore
parentc180cb5c48737b60b14fee22f20edc906ae8fec6 (diff)
Implement new flags DONT_INHIBIT_AUTO_SUSPEND and START_UNMUTED
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/protocol-native.c42
-rw-r--r--src/pulsecore/sink-input.h3
-rw-r--r--src/pulsecore/sink.c34
-rw-r--r--src/pulsecore/sink.h1
-rw-r--r--src/pulsecore/source-output.h3
-rw-r--r--src/pulsecore/source.c29
-rw-r--r--src/pulsecore/source.h1
7 files changed, 104 insertions, 9 deletions
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 46dcb14a..56e86cb4 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -959,6 +959,7 @@ static playback_stream* playback_stream_new(
uint32_t *minreq,
pa_cvolume *volume,
pa_bool_t muted,
+ pa_bool_t muted_set,
uint32_t syncid,
uint32_t *missing,
pa_sink_input_flags_t flags,
@@ -1013,7 +1014,8 @@ static playback_stream* playback_stream_new(
pa_sink_input_new_data_set_channel_map(&data, map);
if (volume)
pa_sink_input_new_data_set_volume(&data, volume);
- pa_sink_input_new_data_set_muted(&data, muted);
+ if (muted_set)
+ pa_sink_input_new_data_set_muted(&data, muted);
data.sync_base = ssync ? ssync->sink_input : NULL;
sink_input = pa_sink_input_new(c->protocol->core, &data, flags);
@@ -1688,7 +1690,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
variable_rate = FALSE,
muted = FALSE,
adjust_latency = FALSE,
- early_requests = FALSE;
+ early_requests = FALSE,
+ dont_inhibit_auto_suspend = FALSE,
+ muted_set = FALSE;
pa_sink_input_flags_t flags = 0;
pa_proplist *p;
@@ -1769,6 +1773,16 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
}
}
+ if (c->version >= 15) {
+
+ if (pa_tagstruct_get_boolean(t, &muted_set) < 0 ||
+ pa_tagstruct_get_boolean(t, &dont_inhibit_auto_suspend) < 0) {
+ protocol_error(c);
+ pa_proplist_free(p);
+ return;
+ }
+ }
+
if (!pa_tagstruct_eof(t)) {
protocol_error(c);
pa_proplist_free(p);
@@ -1800,9 +1814,14 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
(fix_rate ? PA_SINK_INPUT_FIX_RATE : 0) |
(fix_channels ? PA_SINK_INPUT_FIX_CHANNELS : 0) |
(no_move ? PA_SINK_INPUT_DONT_MOVE : 0) |
- (variable_rate ? PA_SINK_INPUT_VARIABLE_RATE : 0);
+ (variable_rate ? PA_SINK_INPUT_VARIABLE_RATE : 0) |
+ (dont_inhibit_auto_suspend ? PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND : 0);
+
+ /* Only since protocol version 15 there's a seperate muted_set
+ * flag. For older versions we synthesize it here */
+ muted_set = muted_set || muted;
- s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, syncid, &missing, flags, p, adjust_latency, early_requests);
+ s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, muted_set, syncid, &missing, flags, p, adjust_latency, early_requests);
pa_proplist_free(p);
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
@@ -1923,7 +1942,8 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
variable_rate = FALSE,
adjust_latency = FALSE,
peak_detect = FALSE,
- early_requests = FALSE;
+ early_requests = FALSE,
+ dont_inhibit_auto_suspend = FALSE;
pa_source_output_flags_t flags = 0;
pa_proplist *p;
uint32_t direct_on_input_idx = PA_INVALID_INDEX;
@@ -1995,6 +2015,15 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
}
}
+ if (c->version >= 15) {
+
+ if (pa_tagstruct_get_boolean(t, &dont_inhibit_auto_suspend) < 0) {
+ protocol_error(c);
+ pa_proplist_free(p);
+ return;
+ }
+ }
+
if (!pa_tagstruct_eof(t)) {
protocol_error(c);
pa_proplist_free(p);
@@ -2035,7 +2064,8 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
(fix_rate ? PA_SOURCE_OUTPUT_FIX_RATE : 0) |
(fix_channels ? PA_SOURCE_OUTPUT_FIX_CHANNELS : 0) |
(no_move ? PA_SOURCE_OUTPUT_DONT_MOVE : 0) |
- (variable_rate ? PA_SOURCE_OUTPUT_VARIABLE_RATE : 0);
+ (variable_rate ? PA_SOURCE_OUTPUT_VARIABLE_RATE : 0) |
+ (dont_inhibit_auto_suspend ? PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND : 0);
s = record_stream_new(c, source, &ss, &map, peak_detect, &maxlength, &fragment_size, flags, p, adjust_latency, direct_on_input, early_requests);
pa_proplist_free(p);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 97668c52..27125988 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -56,7 +56,8 @@ typedef enum pa_sink_input_flags {
PA_SINK_INPUT_NO_REMIX = 16,
PA_SINK_INPUT_FIX_FORMAT = 32,
PA_SINK_INPUT_FIX_RATE = 64,
- PA_SINK_INPUT_FIX_CHANNELS = 128
+ PA_SINK_INPUT_FIX_CHANNELS = 128,
+ PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND = 256,
} pa_sink_input_flags_t;
struct pa_sink_input {
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d8d1f792..a6027e70 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -991,7 +991,7 @@ unsigned pa_sink_linked_by(pa_sink *s) {
ret = pa_idxset_size(s->inputs);
/* We add in the number of streams connected to us here. Please
- * not the asymmmetry to pa_sink_used_by()! */
+ * note the asymmmetry to pa_sink_used_by()! */
if (s->monitor_source)
ret += pa_source_linked_by(s->monitor_source);
@@ -1015,6 +1015,38 @@ unsigned pa_sink_used_by(pa_sink *s) {
return ret - s->n_corked;
}
+/* Called from main thread */
+unsigned pa_sink_check_suspend(pa_sink *s) {
+ unsigned ret;
+ pa_sink_input *i;
+ uint32_t idx;
+
+ pa_sink_assert_ref(s);
+ pa_assert(PA_SINK_IS_LINKED(s->state));
+
+ ret = 0;
+
+ for (i = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx))) {
+ pa_sink_input_state_t st;
+
+ st = pa_sink_input_get_state(i);
+ pa_assert(PA_SINK_INPUT_IS_LINKED(st));
+
+ if (st == PA_SINK_INPUT_CORKED)
+ continue;
+
+ if (i->flags & PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND)
+ continue;
+
+ ret ++;
+ }
+
+ if (s->monitor_source)
+ ret += pa_source_check_suspend(s->monitor_source);
+
+ return ret;
+}
+
/* Called from IO thread, except when it is not */
int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
pa_sink *s = PA_SINK(o);
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 74671b44..c5a73214 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -252,6 +252,7 @@ pa_bool_t pa_sink_get_mute(pa_sink *sink, pa_bool_t force_refres);
unsigned pa_sink_linked_by(pa_sink *s); /* Number of connected streams */
unsigned pa_sink_used_by(pa_sink *s); /* Number of connected streams which are not corked */
+unsigned pa_sink_check_suspend(pa_sink *s); /* Returns how many streams are active that don't allow suspensions */
#define pa_sink_get_state(s) ((s)->state)
/* To be called exclusively by the sink driver, from IO context */
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index 6ae10c62..f011f9bd 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -52,7 +52,8 @@ typedef enum pa_source_output_flags {
PA_SOURCE_OUTPUT_NO_REMIX = 16,
PA_SOURCE_OUTPUT_FIX_FORMAT = 32,
PA_SOURCE_OUTPUT_FIX_RATE = 64,
- PA_SOURCE_OUTPUT_FIX_CHANNELS = 128
+ PA_SOURCE_OUTPUT_FIX_CHANNELS = 128,
+ PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND = 256
} pa_source_output_flags_t;
struct pa_source_output {
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index edbbf017..7d927faa 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -645,6 +645,35 @@ unsigned pa_source_used_by(pa_source *s) {
return ret - s->n_corked;
}
+/* Called from main thread */
+unsigned pa_source_check_suspend(pa_source *s) {
+ unsigned ret;
+ pa_source_output *o;
+ uint32_t idx;
+
+ pa_source_assert_ref(s);
+ pa_assert(PA_SOURCE_IS_LINKED(s->state));
+
+ ret = 0;
+
+ for (o = PA_SOURCE_OUTPUT(pa_idxset_first(s->outputs, &idx)); o; o = PA_SOURCE_OUTPUT(pa_idxset_next(s->outputs, &idx))) {
+ pa_source_output_state_t st;
+
+ st = pa_source_output_get_state(o);
+ pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(st));
+
+ if (st == PA_SOURCE_OUTPUT_CORKED)
+ continue;
+
+ if (o->flags & PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND)
+ continue;
+
+ ret ++;
+ }
+
+ return ret;
+}
+
/* Called from IO thread, except when it is not */
int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
pa_source *s = PA_SOURCE(object);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index cae78693..aaf904b4 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -234,6 +234,7 @@ pa_bool_t pa_source_get_mute(pa_source *source, pa_bool_t force_refresh);
unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */
unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */
+unsigned pa_source_check_suspend(pa_source *s); /* Returns how many streams are active that don't allow suspensions */
#define pa_source_get_state(s) ((pa_source_state_t) (s)->state)
/* To be called exclusively by the source driver, from IO context */