mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-12 13:30:10 -05:00
Implement new flags DONT_INHIBIT_AUTO_SUSPEND and START_UNMUTED
This commit is contained in:
parent
c180cb5c48
commit
adc2973c8d
13 changed files with 156 additions and 24 deletions
|
|
@ -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);
|
||||
|
||||
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);
|
||||
/* 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, 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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue