diff options
| author | Lennart Poettering <lennart@poettering.net> | 2009-08-15 00:03:50 +0200 | 
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2009-08-15 00:03:50 +0200 | 
| commit | 0989be13f6b5f71872f381fe2b5a7379702f20bc (patch) | |
| tree | 77c4f5cb602e94fdeae6eaf1c9cc669c667b5023 | |
| parent | 7891f964e4a1858ccae744ddff5d33b78f00b4d2 (diff) | |
core: introduce pa_{sink_input|source_output}_fail_move()
| -rw-r--r-- | src/pulsecore/sink-input.c | 19 | ||||
| -rw-r--r-- | src/pulsecore/sink-input.h | 5 | ||||
| -rw-r--r-- | src/pulsecore/sink.c | 8 | ||||
| -rw-r--r-- | src/pulsecore/source-output.c | 19 | ||||
| -rw-r--r-- | src/pulsecore/source-output.h | 5 | ||||
| -rw-r--r-- | src/pulsecore/source.c | 8 | 
6 files changed, 52 insertions, 12 deletions
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 1f67d0fb..3a9915f0 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1318,6 +1318,24 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {  }  /* 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;      } diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h index cd424e87..9088d6a1 100644 --- a/src/pulsecore/sink-input.h +++ b/src/pulsecore/sink-input.h @@ -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); diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index edcf5bdd..65c6374b 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -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); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 5d79dbbb..8cb361c9 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -847,6 +847,24 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t  }  /* 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;      } diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h index 4bf88ca4..6e3475a6 100644 --- a/src/pulsecore/source-output.h +++ b/src/pulsecore/source-output.h @@ -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) diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 97a20b91..5731663b 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -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);  | 
