diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-06-13 21:56:19 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-06-13 21:56:19 +0000 |
commit | b27cc1d426b7fda9cc21a0854a9cd6f494e2f7fa (patch) | |
tree | f33ade74f08bf6d736830a0a893620668d4473f7 /src/pulsecore/sink-input.c | |
parent | 7bae1baa3e59bd87d3502c13297f2b67edaed764 (diff) |
fix a bad memory access pulsecore/client.c
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2527 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/sink-input.c')
-rw-r--r-- | src/pulsecore/sink-input.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index d51ff810..4defb0f6 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -220,6 +220,8 @@ pa_sink_input* pa_sink_input_new( i->sink = data->sink; i->client = data->client; + i->direct_outputs = pa_idxset_new(NULL, NULL); + i->resample_method = data->resample_method; i->sample_spec = data->sample_spec; i->channel_map = data->channel_map; @@ -252,6 +254,7 @@ pa_sink_input* pa_sink_input_new( i->thread_info.rewrite_flush = FALSE; i->thread_info.underrun_for = (uint64_t) -1; i->thread_info.playing_for = 0; + i->thread_info.direct_outputs = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); i->thread_info.render_memblockq = pa_memblockq_new( 0, @@ -322,6 +325,7 @@ static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) { void pa_sink_input_unlink(pa_sink_input *i) { pa_bool_t linked; + pa_source_output *o, *p = NULL; pa_assert(i); /* See pa_sink_unlink() for a couple of comments how this function @@ -345,6 +349,12 @@ void pa_sink_input_unlink(pa_sink_input *i) { if (pa_idxset_remove_by_data(i->sink->inputs, i, NULL)) pa_sink_input_unref(i); + while ((o = pa_idxset_first(i->direct_outputs, NULL))) { + pa_assert(o != p); + pa_source_output_kill(o); + p = o; + } + update_n_corked(i, PA_SINK_INPUT_UNLINKED); i->state = PA_SINK_INPUT_UNLINKED; @@ -385,6 +395,12 @@ static void sink_input_free(pa_object *o) { if (i->proplist) pa_proplist_free(i->proplist); + if (i->direct_outputs) + pa_idxset_free(i->direct_outputs, NULL, NULL); + + if (i->thread_info.direct_outputs) + pa_hashmap_free(i->thread_info.direct_outputs, NULL, NULL); + pa_xfree(i->driver); pa_xfree(i); } @@ -839,6 +855,7 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest) { pa_resampler *new_resampler; pa_sink *origin; pa_sink_input_move_hook_data hook_data; + pa_source_output *o, *p = NULL; pa_sink_input_assert_ref(i); pa_assert(PA_SINK_INPUT_IS_LINKED(i->state)); @@ -862,6 +879,13 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest) { return -1; } + /* Kill directly connected outputs */ + while ((o = pa_idxset_first(i->direct_outputs, NULL))) { + pa_assert(o != p); + pa_source_output_kill(o); + p = o; + } + if (i->thread_info.resampler && pa_sample_spec_equal(&origin->sample_spec, &dest->sample_spec) && pa_channel_map_equal(&origin->channel_map, &dest->channel_map)) |