mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
restore the ability move record streams between sources
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1641 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
50e014e7a9
commit
e71a34762e
2 changed files with 56 additions and 42 deletions
|
|
@ -55,10 +55,14 @@ typedef enum pa_core_hook {
|
||||||
PA_CORE_HOOK_SINK_INPUT_PUT,
|
PA_CORE_HOOK_SINK_INPUT_PUT,
|
||||||
PA_CORE_HOOK_SINK_INPUT_DISCONNECT,
|
PA_CORE_HOOK_SINK_INPUT_DISCONNECT,
|
||||||
PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST,
|
PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST,
|
||||||
|
PA_CORE_HOOK_SINK_INPUT_MOVE,
|
||||||
|
PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
|
||||||
PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
|
PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
|
||||||
PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
|
PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
|
||||||
PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT,
|
PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT,
|
||||||
PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST,
|
PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST,
|
||||||
|
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE,
|
||||||
|
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST,
|
||||||
PA_CORE_HOOK_MAX
|
PA_CORE_HOOK_MAX
|
||||||
} pa_core_hook_t;
|
} pa_core_hook_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ static void source_output_free(pa_object* mo) {
|
||||||
void pa_source_output_put(pa_source_output *o) {
|
void pa_source_output_put(pa_source_output *o) {
|
||||||
pa_source_output_assert_ref(o);
|
pa_source_output_assert_ref(o);
|
||||||
|
|
||||||
pa_asyncmsgq_post(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_ADD_OUTPUT, pa_source_output_ref(o), 0, NULL, (pa_free_cb_t) pa_source_output_unref);
|
pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_ADD_OUTPUT, o, 0, NULL);
|
||||||
pa_source_update_status(o->source);
|
pa_source_update_status(o->source);
|
||||||
|
|
||||||
pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
|
pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
|
||||||
|
|
@ -327,63 +327,73 @@ pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_source_output_move_to(pa_source_output *o, pa_source *dest) {
|
int pa_source_output_move_to(pa_source_output *o, pa_source *dest) {
|
||||||
/* pa_source *origin; */
|
pa_source *origin;
|
||||||
/* pa_resampler *new_resampler = NULL; */
|
pa_resampler *new_resampler = NULL;
|
||||||
|
|
||||||
pa_source_output_assert_ref(o);
|
pa_source_output_assert_ref(o);
|
||||||
pa_source_assert_ref(dest);
|
pa_source_assert_ref(dest);
|
||||||
|
|
||||||
return -1;
|
origin = o->source;
|
||||||
|
|
||||||
/* origin = o->source; */
|
if (dest == origin)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* if (dest == origin) */
|
if (pa_idxset_size(dest->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
|
||||||
/* return 0; */
|
pa_log_warn("Failed to move source output: too many outputs per source.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* if (pa_idxset_size(dest->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) { */
|
if (o->thread_info.resampler &&
|
||||||
/* pa_log_warn("Failed to move source output: too many outputs per source."); */
|
pa_sample_spec_equal(&origin->sample_spec, &dest->sample_spec) &&
|
||||||
/* return -1; */
|
pa_channel_map_equal(&origin->channel_map, &dest->channel_map))
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if (o->resampler && */
|
/* Try to reuse the old resampler if possible */
|
||||||
/* pa_sample_spec_equal(&origin->sample_spec, &dest->sample_spec) && */
|
new_resampler = o->thread_info.resampler;
|
||||||
/* pa_channel_map_equal(&origin->channel_map, &dest->channel_map)) */
|
|
||||||
|
|
||||||
/* /\* Try to reuse the old resampler if possible *\/ */
|
else if (!pa_sample_spec_equal(&o->sample_spec, &dest->sample_spec) ||
|
||||||
/* new_resampler = o->resampler; */
|
!pa_channel_map_equal(&o->channel_map, &dest->channel_map)) {
|
||||||
|
|
||||||
/* else if (!pa_sample_spec_equal(&o->sample_spec, &dest->sample_spec) || */
|
/* Okey, we need a new resampler for the new source */
|
||||||
/* !pa_channel_map_equal(&o->channel_map, &dest->channel_map)) { */
|
|
||||||
|
|
||||||
/* /\* Okey, we need a new resampler for the new source *\/ */
|
if (!(new_resampler = pa_resampler_new(
|
||||||
|
dest->core->mempool,
|
||||||
|
&dest->sample_spec, &dest->channel_map,
|
||||||
|
&o->sample_spec, &o->channel_map,
|
||||||
|
o->resample_method))) {
|
||||||
|
pa_log_warn("Unsupported resampling operation.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if (!(new_resampler = pa_resampler_new( */
|
pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE], o);
|
||||||
/* dest->core->mempool, */
|
|
||||||
/* &dest->sample_spec, &dest->channel_map, */
|
|
||||||
/* &o->sample_spec, &o->channel_map, */
|
|
||||||
/* o->resample_method))) { */
|
|
||||||
/* pa_log_warn("Unsupported resampling operation."); */
|
|
||||||
/* return -1; */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* Okey, let's move it *\/ */
|
/* Okey, let's move it */
|
||||||
/* pa_idxset_remove_by_data(origin->outputs, o, NULL); */
|
pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL);
|
||||||
/* pa_idxset_put(dest->outputs, o, NULL); */
|
|
||||||
/* o->source = dest; */
|
|
||||||
|
|
||||||
/* /\* Replace resampler *\/ */
|
pa_idxset_remove_by_data(origin->outputs, o, NULL);
|
||||||
/* if (new_resampler != o->resampler) { */
|
pa_idxset_put(dest->outputs, o, NULL);
|
||||||
/* if (o->resampler) */
|
o->source = dest;
|
||||||
/* pa_resampler_free(o->resampler); */
|
|
||||||
/* o->resampler = new_resampler; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* Notify everyone *\/ */
|
/* Replace resampler */
|
||||||
/* pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index); */
|
if (new_resampler != o->thread_info.resampler) {
|
||||||
/* pa_source_notify(o->source); */
|
if (o->thread_info.resampler)
|
||||||
|
pa_resampler_free(o->thread_info.resampler);
|
||||||
|
o->thread_info.resampler = new_resampler;
|
||||||
|
}
|
||||||
|
|
||||||
/* return 0; */
|
pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_ADD_OUTPUT, o, 0, NULL);
|
||||||
|
|
||||||
|
pa_source_update_status(origin);
|
||||||
|
pa_source_update_status(dest);
|
||||||
|
|
||||||
|
pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST], o);
|
||||||
|
|
||||||
|
pa_log_debug("Successfully moved source output %i from %s to %s.", o->index, origin->name, dest->name);
|
||||||
|
|
||||||
|
/* Notify everyone */
|
||||||
|
pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_source_output_process_msg(pa_msgobject *mo, int code, void *userdata, int64_t offset, pa_memchunk* chunk) {
|
int pa_source_output_process_msg(pa_msgobject *mo, int code, void *userdata, int64_t offset, pa_memchunk* chunk) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue