core: introduce pa_{sink_input|source_output}_fail_move()

This commit is contained in:
Lennart Poettering 2009-08-15 00:03:50 +02:00
parent 7891f964e4
commit 0989be13f6
6 changed files with 52 additions and 12 deletions

View file

@ -1317,6 +1317,24 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
return 0;
}
/* Called from main context */
void pa_sink_input_fail_move(pa_sink_input *i) {
pa_sink_input_assert_ref(i);
pa_assert_ctl_context();
pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
pa_assert(!i->sink);
/* Check if someone wants this sink input? */
if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL], i) == PA_HOOK_STOP)
return;
if (i->moving)
i->moving(i, NULL);
pa_sink_input_kill(i);
}
/* Called from main context */
int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
int r;
@ -1341,6 +1359,7 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
}
if ((r = pa_sink_input_finish_move(i, dest, save)) < 0) {
pa_sink_input_fail_move(i);
pa_sink_input_unref(i);
return r;
}

View file

@ -159,7 +159,9 @@ struct pa_sink_input {
/* If non-NULL called whenever the sink input is moved to a new
* sink. Called from main context after the sink input has been
* detached from the old sink and before it has been attached to
* the new sink. */
* the new sink. If dest is NULL the move was executed in two
* phases and the second one failed; the stream will be destroyed
* after this call. */
void (*moving) (pa_sink_input *i, pa_sink *dest); /* may be NULL */
/* Supposed to unlink and destroy this stream. Called from main
@ -337,6 +339,7 @@ pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest); /* may thi
* new sink */
int pa_sink_input_start_move(pa_sink_input *i);
int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save);
void pa_sink_input_fail_move(pa_sink_input *i);
pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i);

View file

@ -649,7 +649,7 @@ void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, pa_bool_t save) {
while ((i = PA_SINK_INPUT(pa_queue_pop(q)))) {
if (pa_sink_input_finish_move(i, s, save) < 0)
pa_sink_input_kill(i);
pa_sink_input_fail_move(i);
pa_sink_input_unref(i);
}
@ -665,10 +665,8 @@ void pa_sink_move_all_fail(pa_queue *q) {
pa_assert(q);
while ((i = PA_SINK_INPUT(pa_queue_pop(q)))) {
if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL], i) == PA_HOOK_OK) {
pa_sink_input_kill(i);
pa_sink_input_unref(i);
}
pa_sink_input_fail_move(i);
pa_sink_input_unref(i);
}
pa_queue_free(q, NULL, NULL);

View file

@ -846,6 +846,24 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
return 0;
}
/* Called from main context */
void pa_source_output_fail_move(pa_source_output *o) {
pa_source_output_assert_ref(o);
pa_assert_ctl_context();
pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
pa_assert(!o->source);
/* Check if someone wants this source output? */
if (pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL], o) == PA_HOOK_STOP)
return;
if (o->moving)
o->moving(o, NULL);
pa_source_output_kill(o);
}
/* Called from main context */
int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t save) {
int r;
@ -870,6 +888,7 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t sav
}
if ((r = pa_source_output_finish_move(o, dest, save)) < 0) {
pa_source_output_fail_move(o);
pa_source_output_unref(o);
return r;
}

View file

@ -127,7 +127,9 @@ struct pa_source_output {
/* If non-NULL called whenever the source output is moved to a new
* source. Called from main context after the stream was detached
* from the old source and before it is attached to the new
* source. */
* source. If dest is NULL the move was executed in two
* phases and the second one failed; the stream will be destroyed
* after this call. */
void (*moving) (pa_source_output *o, pa_source *dest); /* may be NULL */
/* Supposed to unlink and destroy this stream. Called from main
@ -262,6 +264,7 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t sav
* new source */
int pa_source_output_start_move(pa_source_output *o);
int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t save);
void pa_source_output_fail_move(pa_source_output *o);
#define pa_source_output_get_state(o) ((o)->state)

View file

@ -574,7 +574,7 @@ void pa_source_move_all_finish(pa_source *s, pa_queue *q, pa_bool_t save) {
while ((o = PA_SOURCE_OUTPUT(pa_queue_pop(q)))) {
if (pa_source_output_finish_move(o, s, save) < 0)
pa_source_output_kill(o);
pa_source_output_fail_move(o);
pa_source_output_unref(o);
}
@ -590,10 +590,8 @@ void pa_source_move_all_fail(pa_queue *q) {
pa_assert(q);
while ((o = PA_SOURCE_OUTPUT(pa_queue_pop(q)))) {
if (pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL], o) == PA_HOOK_OK) {
pa_source_output_kill(o);
pa_source_output_unref(o);
}
pa_source_output_fail_move(o);
pa_source_output_unref(o);
}
pa_queue_free(q, NULL, NULL);