From 5c80993982bef12ed98512c34fcabb9e4399bb5a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 24 Sep 2011 05:14:07 +0000 Subject: [PATCH] ok - lets make pa use correct channels to start with so it doesnt fail instead of assume "front" take the first channel in the lsit - also chanel id's stuffed inot pointers are no good if other code assume ptr of NULL == no channel'mixer channel as it was a ptr... so incriment id's by 1 in the interface to make sure id 0 doesnt happen. SVN revision: 63578 --- src/modules/mixer/app_mixer.c | 2 +- src/modules/mixer/sink.c | 10 ++++--- src/modules/mixer/sys_pulse.c | 51 ++++++++++++++++++++--------------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/modules/mixer/app_mixer.c b/src/modules/mixer/app_mixer.c index 80ced48e3..76a15fe79 100644 --- a/src/modules/mixer/app_mixer.c +++ b/src/modules/mixer/app_mixer.c @@ -264,7 +264,7 @@ _populate_channels(E_Mixer_App_Dialog_Data *app) eina_stringshare_del(app->channel_name); app->channel_name = e_mod_mixer_channel_default_name_get(app->sys); - + if (app->channels_infos) _channels_info_free(app->channels_infos); app->channels_infos = _channels_info_new(app->sys); diff --git a/src/modules/mixer/sink.c b/src/modules/mixer/sink.c index 7959e6b34..5b827dd8a 100644 --- a/src/modules/mixer/sink.c +++ b/src/modules/mixer/sink.c @@ -226,9 +226,8 @@ pulse_sink_channel_names_get(Pulse_Sink *sink) unsigned int x; EINA_SAFETY_ON_NULL_RETURN_VAL(sink, NULL); - - for (x = 0; x < sink->channel_map.channels; x++) - ret = eina_list_append(ret, eina_stringshare_add(channel_name_table[x])); + for (x = 0; x < sink->volume.channels; x++) + ret = eina_list_append(ret, pulse_sink_channel_id_get_name(sink, x)); return ret; } @@ -240,7 +239,10 @@ pulse_sink_channel_name_get_id(Pulse_Sink *sink, const char *name) EINA_SAFETY_ON_NULL_RETURN_VAL(sink, UINT_MAX); EINA_SAFETY_ON_NULL_RETURN_VAL(name, UINT_MAX); for (x = 0; x < sink->channel_map.channels; x++) - if (!strcmp(name, channel_name_table[sink->channel_map.map[x]])) return x; + { + if (!strcmp(name, channel_name_table[sink->channel_map.map[x]])) + return x; + } return UINT_MAX; } diff --git a/src/modules/mixer/sys_pulse.c b/src/modules/mixer/sys_pulse.c index c7d90d389..47e9ab23b 100644 --- a/src/modules/mixer/sys_pulse.c +++ b/src/modules/mixer/sys_pulse.c @@ -294,8 +294,8 @@ e_mixer_pulse_get_channels(E_Mixer_System *self) uintptr_t id; Eina_List *ret = NULL; - for (id=0; id < pulse_sink_channels_count((void*)self); id++) - ret = eina_list_append(ret, (void*)id); + for (id = 0; id < pulse_sink_channels_count((void *)self); id++) + ret = eina_list_append(ret, (void *)(id + 1)); return ret; } @@ -308,30 +308,29 @@ e_mixer_pulse_free_channels(Eina_List *channels) Eina_List * e_mixer_pulse_get_channels_names(E_Mixer_System *self) { - return pulse_sink_channel_names_get((void*)self);; + return pulse_sink_channel_names_get((void *)self); } void e_mixer_pulse_free_channels_names(Eina_List *channels_names) { const char *str; - EINA_LIST_FREE(channels_names, str) - eina_stringshare_del(str); + EINA_LIST_FREE(channels_names, str) eina_stringshare_del(str); } const char * -e_mixer_pulse_get_default_channel_name(E_Mixer_System *self __UNUSED__) +e_mixer_pulse_get_default_channel_name(E_Mixer_System *self) { - return eina_stringshare_add("Front"); + return e_mixer_pulse_get_channel_name(self, 0); } E_Mixer_Channel * e_mixer_pulse_get_channel_by_name(E_Mixer_System *self, const char *name) { unsigned int x; - x = pulse_sink_channel_name_get_id((void*)self, name); - if (x == UINT_MAX) return (intptr_t*)-2; - return (uintptr_t*)((uintptr_t)x); + x = pulse_sink_channel_name_get_id((void *)self, name); + if (x == UINT_MAX) return NULL; + return (E_Mixer_Channel *)((uintptr_t)(x + 1)); } void @@ -342,8 +341,9 @@ e_mixer_pulse_channel_del(E_Mixer_Channel *channel __UNUSED__) const char * e_mixer_pulse_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel) { - if (channel == (E_Mixer_Channel *)-2) return NULL; - return pulse_sink_channel_id_get_name((void*)self, (uintptr_t)channel); + if (!channel) return NULL; + return pulse_sink_channel_id_get_name((void *)self, + ((uintptr_t)channel) - 1); } int @@ -351,10 +351,11 @@ e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *le { double volume; - volume = pulse_sink_channel_volume_get((void*)self, (uintptr_t)channel); + if (!channel) return 0; + volume = pulse_sink_channel_volume_get((void *)self, + ((uintptr_t)channel) - 1); if (left) *left = (int)volume; if (right) *right = (int)volume; - return 1; } @@ -363,7 +364,10 @@ e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int lef { uint32_t id; - id = pulse_sink_channel_volume_set(conn, (void*)self, (uintptr_t)channel, (left + right) / 2); + if (!channel) return 0; + id = pulse_sink_channel_volume_set(conn, (void *)self, + ((uintptr_t)channel) - 1, + (left + right) / 2); if (!id) return 0; pulse_cb_set(conn, id, (Pulse_Cb)_pulse_result_cb); return 1; @@ -378,7 +382,7 @@ e_mixer_pulse_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel int e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel *channel __UNUSED__, int *mute) { - if (mute) *mute = pulse_sink_muted_get((void*)self); + if (mute) *mute = pulse_sink_muted_get((void *)self); return 1; } @@ -388,8 +392,8 @@ e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel __UNUSED__ { uint32_t idx, id; - idx = pulse_sink_idx_get((void*)self); - id = pulse_sink_mute_set(conn, pulse_sink_idx_get((void*)self), mute); + idx = pulse_sink_idx_get((void *)self); + id = pulse_sink_mute_set(conn, pulse_sink_idx_get((void *)self), mute); if (!id) return 0; pulse_cb_set(conn, id, (Pulse_Cb)_pulse_result_cb); return 1; @@ -402,8 +406,10 @@ e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_ if (!state) return 0; - vol = pulse_sink_channel_volume_get((void*)self, (uintptr_t)channel); - state->mute = pulse_sink_muted_get((void*)self); + if (!channel) return 0; + vol = pulse_sink_channel_volume_get((void *)self, + ((uintptr_t)channel) - 1); + state->mute = pulse_sink_muted_get((void *)self); state->left = state->right = (int)vol; return 1; @@ -414,7 +420,10 @@ e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_ { uint32_t id; - id = pulse_sink_channel_volume_set(conn, (void*)self, (uintptr_t)channel, (state->left + state->right) / 2); + if (!channel) return 0; + id = pulse_sink_channel_volume_set(conn, (void *)self, + ((uintptr_t)channel) - 1, + (state->left + state->right) / 2); if (!id) return 0; pulse_cb_set(conn, id, (Pulse_Cb)_pulse_result_cb); return 1;