diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-04-10 01:21:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-04-10 01:21:16 +0200 |
commit | 9ae8ca2c3754abb9b6f6ce94c414c12d87419ac0 (patch) | |
tree | 3586b254321aa57758162f1648467fcd55ac2ea6 | |
parent | dcd4a73df94b0e9083f72d79f81083961bd15746 (diff) |
core: memory leak, fix ref counting when moving streams
-rw-r--r-- | src/pulsecore/sink-input.c | 20 | ||||
-rw-r--r-- | src/pulsecore/sink.c | 6 | ||||
-rw-r--r-- | src/pulsecore/source-output.c | 16 | ||||
-rw-r--r-- | src/pulsecore/source.c | 6 |
4 files changed, 38 insertions, 10 deletions
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 58559775..9ae98edd 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -335,8 +335,8 @@ int pa_sink_input_new( 0, &i->sink->silence); - pa_assert_se(pa_idxset_put(core->sink_inputs, pa_sink_input_ref(i), &i->index) == 0); - pa_assert_se(pa_idxset_put(i->sink->inputs, i, NULL) == 0); + pa_assert_se(pa_idxset_put(core->sink_inputs, i, &i->index) == 0); + pa_assert_se(pa_idxset_put(i->sink->inputs, pa_sink_input_ref(i), NULL) == 0); if (i->client) pa_assert_se(pa_idxset_put(i->client->sink_inputs, i, NULL) >= 0); @@ -1155,6 +1155,8 @@ int pa_sink_input_start_move(pa_sink_input *i) { pa_sink_update_status(i->sink); i->sink = NULL; + pa_sink_input_unref(i); + return 0; } @@ -1202,7 +1204,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) { i->sink = dest; i->save_sink = save; - pa_idxset_put(dest->inputs, i, NULL); + pa_idxset_put(dest->inputs, pa_sink_input_ref(i), NULL); if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED) i->sink->n_corked++; @@ -1267,11 +1269,19 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, pa_bool_t save) { if (!pa_sink_input_may_move_to(i, dest)) return -PA_ERR_NOTSUPPORTED; - if ((r = pa_sink_input_start_move(i)) < 0) + pa_sink_input_ref(i); + + if ((r = pa_sink_input_start_move(i)) < 0) { + pa_sink_input_unref(i); return r; + } - if ((r = pa_sink_input_finish_move(i, dest, save)) < 0) + if ((r = pa_sink_input_finish_move(i, dest, save)) < 0) { + pa_sink_input_unref(i); return r; + } + + pa_sink_input_unref(i); return 0; } diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 4cf7b6c0..2771fecb 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -515,8 +515,12 @@ pa_queue *pa_sink_move_all_start(pa_sink *s) { for (i = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i = n) { n = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx)); + pa_sink_input_ref(i); + if (pa_sink_input_start_move(i) >= 0) - pa_queue_push(q, pa_sink_input_ref(i)); + pa_queue_push(q, i); + else + pa_sink_input_unref(i); } return q; diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 8918b431..489393a5 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -705,6 +705,8 @@ int pa_source_output_start_move(pa_source_output *o) { pa_source_update_status(o->source); o->source = NULL; + pa_source_output_unref(o); + return 0; } @@ -752,7 +754,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t o->source = dest; o->save_source = save; - pa_idxset_put(o->source->outputs, o, NULL); + pa_idxset_put(o->source->outputs, pa_source_output_ref(o), NULL); if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED) o->source->n_corked++; @@ -804,11 +806,19 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t sav if (!pa_source_output_may_move_to(o, dest)) return -PA_ERR_NOTSUPPORTED; - if ((r = pa_source_output_start_move(o)) < 0) + pa_source_output_ref(o); + + if ((r = pa_source_output_start_move(o)) < 0) { + pa_source_output_unref(o); return r; + } - if ((r = pa_source_output_finish_move(o, dest, save)) < 0) + if ((r = pa_source_output_finish_move(o, dest, save)) < 0) { + pa_source_output_unref(o); return r; + } + + pa_source_output_unref(o); return 0; } diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index b85d6e12..693fab3c 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -466,8 +466,12 @@ pa_queue *pa_source_move_all_start(pa_source *s) { for (o = PA_SOURCE_OUTPUT(pa_idxset_first(s->outputs, &idx)); o; o = n) { n = PA_SOURCE_OUTPUT(pa_idxset_next(s->outputs, &idx)); + pa_source_output_ref(o); + if (pa_source_output_start_move(o) >= 0) - pa_queue_push(q, pa_source_output_ref(o)); + pa_queue_push(q, o); + else + pa_source_output_unref(o); } return q; |