core: move 'flags' field into 'pa_sink_input_new_data' structure so that hooks can access it

This commit is contained in:
Lennart Poettering 2009-08-28 23:24:09 +02:00
parent 300384ce0a
commit 84eb6614eb
17 changed files with 50 additions and 43 deletions

View file

@ -844,8 +844,9 @@ static int output_create_sink_input(struct output *o) {
pa_sink_input_new_data_set_channel_map(&data, &o->userdata->sink->channel_map);
data.module = o->userdata->module;
data.resample_method = o->userdata->resample_method;
data.flags = PA_SINK_INPUT_VARIABLE_RATE|PA_SINK_INPUT_DONT_MOVE|PA_SINK_INPUT_NO_CREATE_ON_SUSPEND;
pa_sink_input_new(&o->sink_input, o->userdata->core, &data, PA_SINK_INPUT_VARIABLE_RATE|PA_SINK_INPUT_DONT_MOVE|PA_SINK_INPUT_NO_CREATE_ON_SUSPEND);
pa_sink_input_new(&o->sink_input, o->userdata->core, &data);
pa_sink_input_new_data_done(&data);

View file

@ -812,7 +812,7 @@ int pa__init(pa_module*m) {
pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data, 0);
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data);
pa_sink_input_new_data_done(&sink_input_data);
if (!u->sink_input)

View file

@ -676,8 +676,9 @@ int pa__init(pa_module *m) {
pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "abstract");
pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
sink_input_data.flags = PA_SINK_INPUT_VARIABLE_RATE;
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data, PA_SINK_INPUT_VARIABLE_RATE);
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data);
pa_sink_input_new_data_done(&sink_input_data);
if (!u->sink_input)
@ -709,7 +710,7 @@ int pa__init(pa_module *m) {
pa_source_output_new_data_set_sample_spec(&source_output_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
pa_source_output_new(&u->source_output, m->core, &source_output_data, 0);
pa_source_output_new(&u->source_output, m->core, &source_output_data);
pa_source_output_new_data_done(&source_output_data);
if (!u->source_output)

View file

@ -406,8 +406,9 @@ int pa__init(pa_module*m) {
pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "filter");
pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &stream_map);
sink_input_data.flags = (remix ? 0 : PA_SINK_INPUT_NO_REMIX);
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data, (remix ? 0 : PA_SINK_INPUT_NO_REMIX));
pa_sink_input_new(&u->sink_input, m->core, &sink_input_data);
pa_sink_input_new_data_done(&sink_input_data);
if (!u->sink_input)

View file

@ -163,7 +163,7 @@ int pa__init(pa_module*m) {
pa_proplist_setf(data.proplist, "sine.hz", "%u", frequency);
pa_sink_input_new_data_set_sample_spec(&data, &ss);
pa_sink_input_new(&u->sink_input, m->core, &data, 0);
pa_sink_input_new(&u->sink_input, m->core, &data);
pa_sink_input_new_data_done(&data);
if (!u->sink_input)

View file

@ -501,8 +501,9 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
pa_proplist_setf(data.proplist, "rtp.payload", "%u", (unsigned) sdp_info->payload);
data.module = u->module;
pa_sink_input_new_data_set_sample_spec(&data, &sdp_info->sample_spec);
data.flags = PA_SINK_INPUT_VARIABLE_RATE;
pa_sink_input_new(&s->sink_input, u->module->core, &data, PA_SINK_INPUT_VARIABLE_RATE);
pa_sink_input_new(&s->sink_input, u->module->core, &data);
pa_sink_input_new_data_done(&data);
if (!s->sink_input) {

View file

@ -330,8 +330,9 @@ int pa__init(pa_module*m) {
data.source = s;
pa_source_output_new_data_set_sample_spec(&data, &ss);
pa_source_output_new_data_set_channel_map(&data, &cm);
data.flags = PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND;
pa_source_output_new(&o, m->core, &data, PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND);
pa_source_output_new(&o, m->core, &data);
pa_source_output_new_data_done(&data);
if (!o) {

View file

@ -199,7 +199,7 @@ pa_sink_input* pa_memblockq_sink_input_new(
pa_sink_input_new_data_set_volume(&data, volume);
pa_proplist_update(data.proplist, PA_UPDATE_REPLACE, p);
pa_sink_input_new(&u->sink_input, sink->core, &data, 0);
pa_sink_input_new(&u->sink_input, sink->core, &data);
pa_sink_input_new_data_done(&data);
if (!u->sink_input)

View file

@ -429,7 +429,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
sdata.sink = sink;
pa_sink_input_new_data_set_sample_spec(&sdata, &ss);
pa_sink_input_new(&c->sink_input, c->protocol->core, &sdata, 0);
pa_sink_input_new(&c->sink_input, c->protocol->core, &sdata);
pa_sink_input_new_data_done(&sdata);
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
@ -525,7 +525,7 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi
sdata.source = source;
pa_source_output_new_data_set_sample_spec(&sdata, &ss);
pa_source_output_new(&c->source_output, c->protocol->core, &sdata, 0);
pa_source_output_new(&c->source_output, c->protocol->core, &sdata);
pa_source_output_new_data_done(&sdata);
CHECK_VALIDITY(c->source_output, "Failed to create source output.");

View file

@ -533,7 +533,7 @@ static void handle_listen_prefix(struct connection *c, const char *source_name)
pa_source_output_new_data_set_sample_spec(&data, &ss);
pa_source_output_new_data_set_channel_map(&data, &cm);
pa_source_output_new(&c->source_output, c->protocol->core, &data, 0);
pa_source_output_new(&c->source_output, c->protocol->core, &data);
pa_source_output_new_data_done(&data);
if (!c->source_output) {

View file

@ -648,8 +648,9 @@ static record_stream* record_stream_new(
pa_source_output_new_data_set_channel_map(&data, map);
if (peak_detect)
data.resample_method = PA_RESAMPLER_PEAKS;
data.flags = flags;
*ret = -pa_source_output_new(&source_output, c->protocol->core, &data, flags);
*ret = -pa_source_output_new(&source_output, c->protocol->core, &data);
pa_source_output_new_data_done(&data);
@ -1050,8 +1051,9 @@ static playback_stream* playback_stream_new(
if (muted_set)
pa_sink_input_new_data_set_muted(&data, muted);
data.sync_base = ssync ? ssync->sink_input : NULL;
data.flags = flags;
*ret = -pa_sink_input_new(&sink_input, c->protocol->core, &data, flags);
*ret = -pa_sink_input_new(&sink_input, c->protocol->core, &data);
pa_sink_input_new_data_done(&data);

View file

@ -541,7 +541,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
pa_proplist_update(data.proplist, PA_UPDATE_MERGE, c->client->proplist);
pa_sink_input_new_data_set_sample_spec(&data, &o->sample_spec);
pa_sink_input_new(&c->sink_input, p->core, &data, 0);
pa_sink_input_new(&c->sink_input, p->core, &data);
pa_sink_input_new_data_done(&data);
if (!c->sink_input) {
@ -593,7 +593,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
pa_proplist_update(data.proplist, PA_UPDATE_MERGE, c->client->proplist);
pa_source_output_new_data_set_sample_spec(&data, &o->sample_spec);
pa_source_output_new(&c->source_output, p->core, &data, 0);
pa_source_output_new(&c->source_output, p->core, &data);
pa_source_output_new_data_done(&data);
if (!c->source_output) {

View file

@ -134,8 +134,7 @@ static void reset_callbacks(pa_sink_input *i) {
int pa_sink_input_new(
pa_sink_input **_i,
pa_core *core,
pa_sink_input_new_data *data,
pa_sink_input_flags_t flags) {
pa_sink_input_new_data *data) {
pa_sink_input *i;
pa_resampler *resampler = NULL;
@ -198,15 +197,15 @@ int pa_sink_input_new(
if (!data->muted_is_set)
data->muted = FALSE;
if (flags & PA_SINK_INPUT_FIX_FORMAT)
if (data->flags & PA_SINK_INPUT_FIX_FORMAT)
data->sample_spec.format = data->sink->sample_spec.format;
if (flags & PA_SINK_INPUT_FIX_RATE)
if (data->flags & PA_SINK_INPUT_FIX_RATE)
data->sample_spec.rate = data->sink->sample_spec.rate;
original_cm = data->channel_map;
if (flags & PA_SINK_INPUT_FIX_CHANNELS) {
if (data->flags & PA_SINK_INPUT_FIX_CHANNELS) {
data->sample_spec.channels = data->sink->sample_spec.channels;
data->channel_map = data->sink->channel_map;
}
@ -225,7 +224,7 @@ int pa_sink_input_new(
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], data)) < 0)
return r;
if ((flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND) &&
if ((data->flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND) &&
pa_sink_get_state(data->sink) == PA_SINK_SUSPENDED) {
pa_log_warn("Failed to create sink input: sink is suspended.");
return -PA_ERR_BADSTATE;
@ -236,7 +235,7 @@ int pa_sink_input_new(
return -PA_ERR_TOOLARGE;
}
if ((flags & PA_SINK_INPUT_VARIABLE_RATE) ||
if ((data->flags & PA_SINK_INPUT_VARIABLE_RATE) ||
!pa_sample_spec_equal(&data->sample_spec, &data->sink->sample_spec) ||
!pa_channel_map_equal(&data->channel_map, &data->sink->channel_map)) {
@ -245,9 +244,9 @@ int pa_sink_input_new(
&data->sample_spec, &data->channel_map,
&data->sink->sample_spec, &data->sink->channel_map,
data->resample_method,
((flags & PA_SINK_INPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) |
((flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
((data->flags & PA_SINK_INPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) |
((data->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (data->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
pa_log_warn("Unsupported resampling operation.");
return -PA_ERR_NOTSUPPORTED;
@ -260,7 +259,7 @@ int pa_sink_input_new(
i->core = core;
i->state = PA_SINK_INPUT_INIT;
i->flags = flags;
i->flags = data->flags;
i->proplist = pa_proplist_copy(data->proplist);
i->driver = pa_xstrdup(pa_path_get_filename(data->driver));
i->module = data->module;

View file

@ -256,6 +256,8 @@ typedef struct pa_sink_input_send_event_hook_data {
} pa_sink_input_send_event_hook_data;
typedef struct pa_sink_input_new_data {
pa_sink_input_flags_t flags;
pa_proplist *proplist;
const char *driver;
@ -298,8 +300,7 @@ void pa_sink_input_new_data_done(pa_sink_input_new_data *data);
int pa_sink_input_new(
pa_sink_input **i,
pa_core *core,
pa_sink_input_new_data *data,
pa_sink_input_flags_t flags);
pa_sink_input_new_data *data);
void pa_sink_input_put(pa_sink_input *i);
void pa_sink_input_unlink(pa_sink_input* i);

View file

@ -311,7 +311,7 @@ int pa_play_file(
pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname);
pa_sndfile_init_proplist(u->sndfile, data.proplist);
pa_sink_input_new(&u->sink_input, sink->core, &data, 0);
pa_sink_input_new(&u->sink_input, sink->core, &data);
pa_sink_input_new_data_done(&data);
if (!u->sink_input)

View file

@ -101,8 +101,7 @@ static void reset_callbacks(pa_source_output *o) {
int pa_source_output_new(
pa_source_output**_o,
pa_core *core,
pa_source_output_new_data *data,
pa_source_output_flags_t flags) {
pa_source_output_new_data *data) {
pa_source_output *o;
pa_resampler *resampler = NULL;
@ -146,13 +145,13 @@ int pa_source_output_new(
pa_return_val_if_fail(pa_channel_map_valid(&data->channel_map), -PA_ERR_INVALID);
pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID);
if (flags & PA_SOURCE_OUTPUT_FIX_FORMAT)
if (data->flags & PA_SOURCE_OUTPUT_FIX_FORMAT)
data->sample_spec.format = data->source->sample_spec.format;
if (flags & PA_SOURCE_OUTPUT_FIX_RATE)
if (data->flags & PA_SOURCE_OUTPUT_FIX_RATE)
data->sample_spec.rate = data->source->sample_spec.rate;
if (flags & PA_SOURCE_OUTPUT_FIX_CHANNELS) {
if (data->flags & PA_SOURCE_OUTPUT_FIX_CHANNELS) {
data->sample_spec.channels = data->source->sample_spec.channels;
data->channel_map = data->source->channel_map;
}
@ -168,7 +167,7 @@ int pa_source_output_new(
if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], data)) < 0)
return r;
if ((flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND) &&
if ((data->flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND) &&
pa_source_get_state(data->source) == PA_SOURCE_SUSPENDED) {
pa_log("Failed to create source output: source is suspended.");
return -PA_ERR_BADSTATE;
@ -179,7 +178,7 @@ int pa_source_output_new(
return -PA_ERR_TOOLARGE;
}
if ((flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ||
if ((data->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ||
!pa_sample_spec_equal(&data->sample_spec, &data->source->sample_spec) ||
!pa_channel_map_equal(&data->channel_map, &data->source->channel_map)) {
@ -188,9 +187,9 @@ int pa_source_output_new(
&data->source->sample_spec, &data->source->channel_map,
&data->sample_spec, &data->channel_map,
data->resample_method,
((flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) |
((flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
((data->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) |
((data->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (data->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
pa_log_warn("Unsupported resampling operation.");
return -PA_ERR_NOTSUPPORTED;
@ -203,7 +202,7 @@ int pa_source_output_new(
o->core = core;
o->state = PA_SOURCE_OUTPUT_INIT;
o->flags = flags;
o->flags = data->flags;
o->proplist = pa_proplist_copy(data->proplist);
o->driver = pa_xstrdup(pa_path_get_filename(data->driver));
o->module = data->module;

View file

@ -201,6 +201,8 @@ typedef struct pa_source_output_send_event_hook_data {
} pa_source_output_send_event_hook_data;
typedef struct pa_source_output_new_data {
pa_source_output_flags_t flags;
pa_proplist *proplist;
pa_sink_input *direct_on_input;
@ -231,8 +233,7 @@ void pa_source_output_new_data_done(pa_source_output_new_data *data);
int pa_source_output_new(
pa_source_output**o,
pa_core *core,
pa_source_output_new_data *data,
pa_source_output_flags_t flags);
pa_source_output_new_data *data);
void pa_source_output_put(pa_source_output *o);
void pa_source_output_unlink(pa_source_output*o);