diff --git a/src/modules/mixer/app_mixer.c b/src/modules/mixer/app_mixer.c index b6c0d8d97..57eb4b0c7 100644 --- a/src/modules/mixer/app_mixer.c +++ b/src/modules/mixer/app_mixer.c @@ -60,43 +60,43 @@ struct channel_info }; static void -_cb_changed_left(void *data, Evas_Object *obj) +_cb_changed_left(void *data, Evas_Object *obj __UNUSED__) { E_Mixer_App_Dialog_Data *app = data; E_Mixer_Channel_State *state; state = &app->state; if (app->lock_sliders && (state->left != state->right)) - { - state->right = state->left; - e_widget_slider_value_int_set(app->ui.channel_editor.right, - state->right); - } + { + state->right = state->left; + e_widget_slider_value_int_set(app->ui.channel_editor.right, + state->right); + } e_mixer_system_set_volume(app->sys, app->channel_info->id, state->left, state->right); } static void -_cb_changed_right(void *data, Evas_Object *obj) +_cb_changed_right(void *data, Evas_Object *obj __UNUSED__) { E_Mixer_App_Dialog_Data *app = data; E_Mixer_Channel_State *state; state = &app->state; if (app->lock_sliders && (state->right != state->left)) - { - state->left = state->right; - e_widget_slider_value_int_set(app->ui.channel_editor.left, - state->left); - } + { + state->left = state->right; + e_widget_slider_value_int_set(app->ui.channel_editor.left, + state->left); + } e_mixer_system_set_volume(app->sys, app->channel_info->id, state->left, state->right); } static void -_cb_changed_mute(void *data, Evas_Object *obj) +_cb_changed_mute(void *data, Evas_Object *obj __UNUSED__) { E_Mixer_App_Dialog_Data *app = data; @@ -104,17 +104,17 @@ _cb_changed_mute(void *data, Evas_Object *obj) } static void -_cb_changed_lock_sliders(void *data, Evas_Object *obj) +_cb_changed_lock_sliders(void *data, Evas_Object *obj __UNUSED__) { E_Mixer_App_Dialog_Data *app = data; E_Mixer_Channel_State *state; if (!app->lock_sliders) - return; + return; state = &app->state; if (state->left == state->right) - return; + return; state->left = state->right = (state->left + state->right) / 2; @@ -127,34 +127,30 @@ _cb_changed_lock_sliders(void *data, Evas_Object *obj) static void _update_channel_editor_state(E_Mixer_App_Dialog_Data *app, const E_Mixer_Channel_State state) { - struct e_mixer_app_ui_channel_editor *ui; - - ui = &app->ui.channel_editor; + struct e_mixer_app_ui_channel_editor *ui = &app->ui.channel_editor; e_widget_slider_value_int_set(ui->left, state.left); e_widget_slider_value_int_set(ui->right, state.right); if (e_mixer_system_can_mute(app->sys, app->channel_info->id)) - { - e_widget_disabled_set(ui->mute, 0); - e_widget_check_checked_set(ui->mute, state.mute); - } + { + e_widget_disabled_set(ui->mute, 0); + e_widget_check_checked_set(ui->mute, state.mute); + } else - { - e_widget_disabled_set(ui->mute, 1); - e_widget_check_checked_set(ui->mute, 0); - } + { + e_widget_disabled_set(ui->mute, 1); + e_widget_check_checked_set(ui->mute, 0); + } } static void _populate_channel_editor(E_Mixer_App_Dialog_Data *app) { - struct e_mixer_app_ui_channel_editor *ui; + struct e_mixer_app_ui_channel_editor *ui = &app->ui.channel_editor; E_Mixer_Channel_State state; const char *card_name; - ui = &app->ui.channel_editor; - card_name = e_mixer_system_get_card_name(app->card); e_widget_entry_text_set(ui->card, card_name); eina_stringshare_del(card_name); @@ -162,9 +158,9 @@ _populate_channel_editor(E_Mixer_App_Dialog_Data *app) e_widget_entry_text_set(ui->channel, app->channel_name); if (e_mixer_system_has_capture(app->sys, app->channel_info->id)) - e_widget_entry_text_set(ui->type, _("Capture")); + e_widget_entry_text_set(ui->type, _("Capture")); else - e_widget_entry_text_set(ui->type, _("Playback")); + e_widget_entry_text_set(ui->type, _("Playback")); e_mixer_system_get_state(app->sys, app->channel_info->id, &state); _update_channel_editor_state(app, state); @@ -190,9 +186,9 @@ _channel_info_cmp(const void *data_a, const void *data_b) const struct channel_info *a = data_a, *b = data_b; if (a->has_capture < b->has_capture) - return -1; + return -1; else if (a->has_capture > b->has_capture) - return 1; + return 1; return strcmp(a->name, b->name); } @@ -205,16 +201,16 @@ _channels_info_new(E_Mixer_System *sys) channels = e_mixer_system_get_channels(sys); channels_infos = NULL; for (l = channels; l != NULL; l = l->next) - { - struct channel_info *info; + { + struct channel_info *info; - info = malloc(sizeof(*info)); - info->id = l->data; - info->name = e_mixer_system_get_channel_name(sys, info->id); - info->has_capture = e_mixer_system_has_capture(sys, info->id); + info = malloc(sizeof(*info)); + info->id = l->data; + info->name = e_mixer_system_get_channel_name(sys, info->id); + info->has_capture = e_mixer_system_has_capture(sys, info->id); - channels_infos = eina_list_append(channels_infos, info); - } + channels_infos = eina_list_append(channels_infos, info); + } e_mixer_system_free_channels(channels); return eina_list_sort(channels_infos, -1, _channel_info_cmp); @@ -226,22 +222,20 @@ _channels_info_free(Eina_List *list) struct channel_info *info; EINA_LIST_FREE(list, info) - { - eina_stringshare_del(info->name); - free(info); - } + { + eina_stringshare_del(info->name); + free(info); + } } static int -_cb_system_update(void *data, E_Mixer_System *sys) +_cb_system_update(void *data, E_Mixer_System *sys __UNUSED__) { - E_Mixer_App_Dialog_Data *app; + E_Mixer_App_Dialog_Data *app = data; E_Mixer_Channel_State state; - app = data; - if ((!app->sys) || (!app->channel_info)) - return 1; + return 1; e_mixer_system_get_state(app->sys, app->channel_info->id, &state); _update_channel_editor_state(app, state); @@ -264,7 +258,7 @@ _populate_channels(E_Mixer_App_Dialog_Data *app) e_widget_ilist_clear(ilist); if (app->sys) - e_mixer_system_del(app->sys); + e_mixer_system_del(app->sys); app->sys = e_mixer_system_new(app->card); e_mixer_system_callback_set(app->sys, _cb_system_update, app); @@ -272,47 +266,47 @@ _populate_channels(E_Mixer_App_Dialog_Data *app) app->channel_name = e_mixer_system_get_default_channel_name(app->sys); if (app->channels_infos) - _channels_info_free(app->channels_infos); + _channels_info_free(app->channels_infos); app->channels_infos = _channels_info_new(app->sys); if (app->channels_infos) - { - struct channel_info *info = app->channels_infos->data; - if (info->has_capture) - { - e_widget_ilist_header_append(ilist, NULL, _("Input")); - header_input = 1; - i = 1; - } - else - { - e_widget_ilist_header_append(ilist, NULL, _("Output")); - header_input = 0; - i = 1; - } - } + { + struct channel_info *info = app->channels_infos->data; + if (info->has_capture) + { + e_widget_ilist_header_append(ilist, NULL, _("Input")); + header_input = 1; + i = 1; + } + else + { + e_widget_ilist_header_append(ilist, NULL, _("Output")); + header_input = 0; + i = 1; + } + } for (l = app->channels_infos; l != NULL; l = l->next, i++) - { - struct channel_info *info = l->data; + { + struct channel_info *info = l->data; - if ((!header_input) && info->has_capture) - { - e_widget_ilist_header_append(ilist, NULL, _("Input")); - header_input = 1; - i++; - } + if ((!header_input) && info->has_capture) + { + e_widget_ilist_header_append(ilist, NULL, _("Input")); + header_input = 1; + i++; + } - info->app = app; - e_widget_ilist_append(ilist, NULL, info->name, _cb_channel_selected, - info, info->name); - if (app->channel_name && info->name && + info->app = app; + e_widget_ilist_append(ilist, NULL, info->name, _cb_channel_selected, + info, info->name); + if (app->channel_name && info->name && (strcmp(app->channel_name, info->name) == 0)) - { - e_widget_ilist_selected_set(ilist, i); - app->channel_info = info; - } - } + { + e_widget_ilist_selected_set(ilist, i); + app->channel_info = info; + } + } e_widget_ilist_go(ilist); e_widget_ilist_thaw(ilist); @@ -333,32 +327,31 @@ _cb_card_selected(void *data) } static void -_create_cards(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *app) +_create_cards(E_Dialog *dialog __UNUSED__, Evas *evas, E_Mixer_App_Dialog_Data *app) { - struct e_mixer_app_ui_cards *ui; + struct e_mixer_app_ui_cards *ui = &app->ui.cards; const char *card; Eina_List *l; app->card = e_mixer_system_get_default_card(); app->cards = e_mixer_system_get_cards(); if (eina_list_count(app->cards) < 2) - return; + return; - ui = &app->ui.cards; ui->list = e_widget_ilist_add(evas, 32, 32, &app->card); e_widget_size_min_set(ui->list, 180, 100); e_widget_ilist_go(ui->list); EINA_LIST_FOREACH(app->cards, l, card) - { - const char *card_name; + { + const char *card_name; - card_name = e_mixer_system_get_card_name(card); + card_name = e_mixer_system_get_card_name(card); - e_widget_ilist_append(ui->list, NULL, card_name, _cb_card_selected, - app, card); + e_widget_ilist_append(ui->list, NULL, card_name, _cb_card_selected, + app, card); - eina_stringshare_del(card_name); - } + eina_stringshare_del(card_name); + } ui->frame = e_widget_framelist_add(evas, _("Cards"), 0); e_widget_framelist_object_append(ui->frame, ui->list); @@ -366,11 +359,9 @@ _create_cards(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *app) } static void -_create_channels(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *app) +_create_channels(E_Dialog *dialog __UNUSED__, Evas *evas, E_Mixer_App_Dialog_Data *app) { - struct e_mixer_app_ui_channels *ui; - - ui = &app->ui.channels; + struct e_mixer_app_ui_channels *ui = &app->ui.channels; ui->list = e_widget_ilist_add(evas, 24, 24, &app->channel_name); e_widget_size_min_set(ui->list, 180, 100); e_widget_ilist_go(ui->list); @@ -381,11 +372,9 @@ _create_channels(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *app) } static void -_create_channel_editor(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *app) +_create_channel_editor(E_Dialog *dialog __UNUSED__, Evas *evas, E_Mixer_App_Dialog_Data *app) { - struct e_mixer_app_ui_channel_editor *ui; - - ui = &app->ui.channel_editor; + struct e_mixer_app_ui_channel_editor *ui = &app->ui.channel_editor; ui->label_card = e_widget_label_add(evas, _("Card:")); ui->card = e_widget_entry_add(evas, NULL, NULL, NULL, NULL); @@ -436,30 +425,28 @@ _create_channel_editor(E_Dialog *dialog, Evas *evas, E_Mixer_App_Dialog_Data *ap static void _create_ui(E_Dialog *dialog, E_Mixer_App_Dialog_Data *app) { - struct e_mixer_app_ui *ui; + struct e_mixer_app_ui *ui = &app->ui; Evas *evas; int mw, mh; evas = e_win_evas_get(dialog->win); - ui = &app->ui; - ui->hlayout = e_widget_list_add(evas, 0, 1); _create_cards(dialog, evas, app); _create_channels(dialog, evas, app); _create_channel_editor(dialog, evas, app); if (ui->cards.list) - e_widget_ilist_selected_set(ui->cards.list, 0); + e_widget_ilist_selected_set(ui->cards.list, 0); else - select_card(app); + select_card(app); e_widget_ilist_selected_set(ui->channels.list, 1); e_widget_size_min_get(ui->hlayout, &mw, &mh); if (mw < 300) - mw = 300; + mw = 300; if (mh < 200) - mh = 200; + mh = 200; e_dialog_content_set(dialog, ui->hlayout, mw, mh); } @@ -467,14 +454,14 @@ static void _mixer_app_dialog_del(E_Dialog *dialog, E_Mixer_App_Dialog_Data *app) { if (app->del.func) - app->del.func(dialog, app->del.data); + app->del.func(dialog, app->del.data); eina_stringshare_del(app->card); eina_stringshare_del(app->channel_name); if (app->cards) - e_mixer_system_free_cards(app->cards); + e_mixer_system_free_cards(app->cards); if (app->channels_infos) - _channels_info_free(app->channels_infos); + _channels_info_free(app->channels_infos); e_mixer_system_del(app->sys); e_util_defer_object_del(E_OBJECT(dialog)); @@ -485,12 +472,8 @@ _mixer_app_dialog_del(E_Dialog *dialog, E_Mixer_App_Dialog_Data *app) static void _cb_win_del(E_Win *win) { - E_Dialog *dialog; - E_Mixer_App_Dialog_Data *app; - - dialog = win->data; - app = dialog->data; - + E_Dialog *dialog = win->data; + E_Mixer_App_Dialog_Data *app = dialog->data; _mixer_app_dialog_del(dialog, app); } @@ -508,14 +491,14 @@ e_mixer_app_dialog_new(E_Container *con, void (*func)(E_Dialog *dialog, void *da dialog = e_dialog_new(con, _e_mixer_Name, "e_mixer_app_dialog"); if (!dialog) - return NULL; + return NULL; app = E_NEW(E_Mixer_App_Dialog_Data, 1); if (!app) - { - e_object_del(E_OBJECT(dialog)); - return NULL; - } + { + e_object_del(E_OBJECT(dialog)); + return NULL; + } dialog->data = app; app->del.data = data; @@ -546,8 +529,8 @@ _find_card_by_name(E_Mixer_App_Dialog_Data *app, const char *card_name) int i; for (i = 0, l = app->cards; l != NULL; i++, l = l->next) - if (strcmp(card_name, l->data) == 0) - return i; + if (strcmp(card_name, l->data) == 0) + return i; return -1; } @@ -561,26 +544,26 @@ _find_channel_by_name(E_Mixer_App_Dialog_Data *app, const char *channel_name) int header_input; if (app->channels_infos) - { - struct channel_info *info = app->channels_infos->data; + { + struct channel_info *info = app->channels_infos->data; - header_input = !!info->has_capture; - i = 1; - } + header_input = !!info->has_capture; + i = 1; + } EINA_LIST_FOREACH(app->channels_infos, l, info) - { - if ((!header_input) && info->has_capture) - { - header_input = 1; - i++; - } + { + if ((!header_input) && info->has_capture) + { + header_input = 1; + i++; + } - if (strcmp(channel_name, info->name) == 0) - return i; + if (strcmp(channel_name, info->name) == 0) + return i; - ++i; - } + ++i; + } return -1; } @@ -592,21 +575,21 @@ e_mixer_app_dialog_select(E_Dialog *dialog, const char *card_name, const char *c int n; if (!dialog) - return 0; + return 0; app = dialog->data; if (!app) - return 0; + return 0; n = _find_card_by_name(app, card_name); if (n < 0) - return 0; + return 0; if (app->ui.cards.list) - e_widget_ilist_selected_set(app->ui.cards.list, n); + e_widget_ilist_selected_set(app->ui.cards.list, n); n = _find_channel_by_name(app, channel_name); if (n < 0) - return 0; + return 0; e_widget_ilist_selected_set(app->ui.channels.list, n); return 1; diff --git a/src/modules/mixer/conf_gadget.c b/src/modules/mixer/conf_gadget.c index 7d44e6343..d13fad318 100644 --- a/src/modules/mixer/conf_gadget.c +++ b/src/modules/mixer/conf_gadget.c @@ -51,19 +51,19 @@ _mixer_fill_cards_info(E_Config_Dialog_Data *cfdata) cfdata->cards = e_mixer_system_get_cards(); cfdata->cards_names = NULL; EINA_LIST_FOREACH(cfdata->cards, l, card) - { - name = e_mixer_system_get_card_name(card); - if ((cfdata->card_num < 0) && card && cfdata->card && + { + name = e_mixer_system_get_card_name(card); + if ((cfdata->card_num < 0) && card && cfdata->card && (strcmp(card, cfdata->card) == 0)) - cfdata->card_num = i; + cfdata->card_num = i; - cfdata->cards_names = eina_list_append(cfdata->cards_names, name); + cfdata->cards_names = eina_list_append(cfdata->cards_names, name); - i++; - } + i++; + } if (cfdata->card_num < 0) - cfdata->card_num = 0; + cfdata->card_num = 0; } static void @@ -76,23 +76,23 @@ _mixer_fill_channels_info(E_Config_Dialog_Data *cfdata) sys = e_mixer_system_new(cfdata->card); if (!sys) - return; + return; cfdata->channel = 0; cfdata->channel_name = eina_stringshare_add(cfdata->conf->channel_name); cfdata->channels_names = e_mixer_system_get_channels_names(sys); EINA_LIST_FOREACH(cfdata->channels_names, l, channel) - { - if (channel && cfdata->channel_name && + { + if (channel && cfdata->channel_name && (channel == cfdata->channel_name || strcmp(channel, cfdata->channel_name) == 0)) - { - cfdata->channel = i; - break; - } + { + cfdata->channel = i; + break; + } - i++; - } + i++; + } e_mixer_system_del(sys); } @@ -104,7 +104,7 @@ _create_data(E_Config_Dialog *dialog) cfdata = E_NEW(E_Config_Dialog_Data, 1); if (!cfdata) - return NULL; + return NULL; conf = dialog->data; cfdata->conf = conf; @@ -120,23 +120,22 @@ _create_data(E_Config_Dialog *dialog) static void _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) { - E_Mixer_Gadget_Config *conf; + E_Mixer_Gadget_Config *conf = dialog->data; const char *card; - conf = dialog->data; if (conf) - conf->dialog = NULL; + conf->dialog = NULL; if (!cfdata) - return; + return; EINA_LIST_FREE(cfdata->cards_names, card) - eina_stringshare_del(card); + eina_stringshare_del(card); if (cfdata->channels_names) - e_mixer_system_free_channels_names(cfdata->channels_names); + e_mixer_system_free_channels_names(cfdata->channels_names); if (cfdata->cards) - e_mixer_system_free_cards(cfdata->cards); + e_mixer_system_free_cards(cfdata->cards); eina_stringshare_del(cfdata->card); eina_stringshare_del(cfdata->channel_name); @@ -149,57 +148,52 @@ _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) static int _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) { - E_Mixer_Gadget_Config *conf; + E_Mixer_Gadget_Config *conf = dialog->data; const char *card, *channel; - conf = dialog->data; conf->lock_sliders = cfdata->lock_sliders; conf->show_locked = cfdata->show_locked; card = eina_list_nth(cfdata->cards, cfdata->card_num); if (card) - { - eina_stringshare_del(conf->card); - conf->card = eina_stringshare_ref(card); - } + { + eina_stringshare_del(conf->card); + conf->card = eina_stringshare_ref(card); + } channel = eina_list_nth(cfdata->channels_names, cfdata->channel); if (channel) - { - eina_stringshare_del(conf->channel_name); - conf->channel_name = eina_stringshare_ref(channel); - } + { + eina_stringshare_del(conf->channel_name); + conf->channel_name = eina_stringshare_ref(channel); + } e_mixer_update(conf->instance); return 1; } static void -_lock_change(void *data, Evas_Object *obj, void *event) +_lock_change(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) { - E_Config_Dialog_Data *cfdata; - - cfdata = data; + E_Config_Dialog_Data *cfdata = data; e_widget_disabled_set(cfdata->ui.general.show_locked, !cfdata->lock_sliders); } static void _basic_create_general(Evas *evas, E_Config_Dialog_Data *cfdata) { - struct mixer_config_ui_general *ui; - - ui = &cfdata->ui.general; + struct mixer_config_ui_general *ui = &cfdata->ui.general; ui->frame = e_widget_framelist_add(evas, _("General Settings"), 0); ui->lock_sliders = e_widget_check_add( - evas, _("Lock Sliders"), &cfdata->lock_sliders); + evas, _("Lock Sliders"), &cfdata->lock_sliders); evas_object_smart_callback_add( - ui->lock_sliders, "changed", _lock_change, cfdata); + ui->lock_sliders, "changed", _lock_change, cfdata); e_widget_framelist_object_append(ui->frame, ui->lock_sliders); ui->show_locked = e_widget_check_add( - evas, _("Show both sliders when locked"), &cfdata->show_locked); + evas, _("Show both sliders when locked"), &cfdata->show_locked); e_widget_disabled_set(ui->show_locked, !cfdata->lock_sliders); e_widget_framelist_object_append(ui->frame, ui->show_locked); } @@ -210,59 +204,56 @@ _clear_channels(E_Config_Dialog_Data *cfdata) Evas_Object *o; EINA_LIST_FREE(cfdata->ui.channels.radios, o) - evas_object_del(o); + evas_object_del(o); } static void _fill_channels(Evas *evas, E_Config_Dialog_Data *cfdata) { - struct mixer_config_ui_channels *ui; + struct mixer_config_ui_channels *ui = &cfdata->ui.channels;; Evas_Object *selected; Evas_Coord mw, mh; const char *name; Eina_List *l; int i = 0; - ui = &cfdata->ui.channels; ui->radio = e_widget_radio_group_new(&cfdata->channel); EINA_LIST_FOREACH(cfdata->channels_names, l, name) - { - Evas_Object *ow; + { + Evas_Object *ow; - if (!name) continue; + if (!name) continue; - ow = e_widget_radio_add(evas, name, i, ui->radio); - ui->radios = eina_list_append(ui->radios, ow); - e_widget_list_object_append(ui->list, ow, 1, 1, 0.0); + ow = e_widget_radio_add(evas, name, i, ui->radio); + ui->radios = eina_list_append(ui->radios, ow); + e_widget_list_object_append(ui->list, ow, 1, 1, 0.0); - ++i; - } + ++i; + } e_widget_size_min_get(ui->list, &mw, &mh); evas_object_resize(ui->list, mw, mh); selected = eina_list_nth(ui->radios, cfdata->channel); if (selected) - { - Evas_Coord x, y, w, h, lx, ly; - evas_object_geometry_get(selected, &x, &y, &w, &h); - evas_object_geometry_get(ui->list, &lx, &ly, NULL, NULL); - x -= lx; - y -= ly - 10; - h += 20; - e_widget_scrollframe_child_region_show(ui->scroll, x, y, w, h); - } + { + Evas_Coord x, y, w, h, lx, ly; + evas_object_geometry_get(selected, &x, &y, &w, &h); + evas_object_geometry_get(ui->list, &lx, &ly, NULL, NULL); + x -= lx; + y -= ly - 10; + h += 20; + e_widget_scrollframe_child_region_show(ui->scroll, x, y, w, h); + } } static void _channel_scroll_set_min_size(struct mixer_config_ui_channels *ui) { Evas_Coord w, h; - int len; - - len = eina_list_count(ui->radios); + int len = eina_list_count(ui->radios); if (len < 1) - return; + return; e_widget_size_min_get(ui->list, &w, &h); h = 4 * h / len; @@ -272,9 +263,8 @@ _channel_scroll_set_min_size(struct mixer_config_ui_channels *ui) static void _basic_create_channels(Evas *evas, E_Config_Dialog_Data *cfdata) { - struct mixer_config_ui_channels *ui; + struct mixer_config_ui_channels *ui = &cfdata->ui.channels; - ui = &cfdata->ui.channels; ui->list = e_widget_list_add(evas, 1, 0); ui->scroll = e_widget_scrollframe_simple_add(evas, ui->list); ui->frame = e_widget_framelist_add(evas, _("Channels"), 0); @@ -286,14 +276,12 @@ _basic_create_channels(Evas *evas, E_Config_Dialog_Data *cfdata) } static void -_card_change(void *data, Evas_Object *obj, void *event) +_card_change(void *data, Evas_Object *obj, void *event __UNUSED__) { - E_Config_Dialog_Data *cfdata; + E_Config_Dialog_Data *cfdata = data; Evas *evas; char *card; - cfdata = data; - eina_stringshare_del(cfdata->card); e_mixer_system_free_channels_names(cfdata->channels_names); @@ -312,34 +300,32 @@ _card_change(void *data, Evas_Object *obj, void *event) static void _basic_create_cards(Evas *evas, E_Config_Dialog_Data *cfdata) { - struct mixer_config_ui_cards *ui; + struct mixer_config_ui_cards *ui = &cfdata->ui.cards; const char *card; Eina_List *l; int i = 0; - ui = &cfdata->ui.cards; - ui->frame = e_widget_framelist_add(evas, _("Sound Cards"), 0); ui->radio = e_widget_radio_group_new(&cfdata->card_num); EINA_LIST_FOREACH(cfdata->cards_names, l, card) - { - Evas_Object *ow; + { + Evas_Object *ow; - if (!card) continue; + if (!card) continue; - ow = e_widget_radio_add(evas, card, i, ui->radio); - e_widget_framelist_object_append(ui->frame, ow); - evas_object_smart_callback_add(ow, "changed", _card_change, cfdata); + ow = e_widget_radio_add(evas, card, i, ui->radio); + e_widget_framelist_object_append(ui->frame, ow); + evas_object_smart_callback_add(ow, "changed", _card_change, cfdata); - ++i; - } + ++i; + } } static Evas_Object * -_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata) { if (!cfdata) - return NULL; + return NULL; cfdata->ui.table = e_widget_table_add(evas, 0); _basic_create_general(evas, cfdata); @@ -363,11 +349,11 @@ e_mixer_config_dialog_new(E_Container *con, E_Mixer_Gadget_Config *conf) E_Config_Dialog_View *view; if (e_config_dialog_find(_e_mixer_Name, "e_mixer_config_dialog_new")) - return NULL; + return NULL; view = E_NEW(E_Config_Dialog_View, 1); if (!view) - return NULL; + return NULL; view->create_cfdata = _create_data; view->free_cfdata = _free_data; diff --git a/src/modules/mixer/conf_module.c b/src/modules/mixer/conf_module.c index d3a4a7f83..f06bb4805 100644 --- a/src/modules/mixer/conf_module.c +++ b/src/modules/mixer/conf_module.c @@ -23,8 +23,8 @@ _find_default_instance_index(E_Mixer_Module_Context *ctxt) int i; for (i = 0, l = ctxt->instances; l != NULL; l = l->next, i++) - if (l->data == ctxt->default_instance) - return i; + if (l->data == ctxt->default_instance) + return i; return 0; } @@ -37,7 +37,7 @@ _create_data(E_Config_Dialog *dialog) cfdata = E_NEW(E_Config_Dialog_Data, 1); if (!cfdata) - return NULL; + return NULL; ctxt = dialog->data; cfdata->default_instance = _find_default_instance_index(ctxt); @@ -48,11 +48,9 @@ _create_data(E_Config_Dialog *dialog) static void _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) { - E_Mixer_Module_Context *ctxt; - - ctxt = dialog->data; + E_Mixer_Module_Context *ctxt = dialog->data; if (ctxt) - ctxt->conf_dialog = NULL; + ctxt->conf_dialog = NULL; E_FREE(cfdata); } @@ -60,23 +58,21 @@ _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) static int _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) { - E_Mixer_Module_Context *ctxt; - - ctxt = dialog->data; + E_Mixer_Module_Context *ctxt = dialog->data; ctxt->default_instance = eina_list_nth(ctxt->instances, cfdata->default_instance); if (ctxt->default_instance) - { - E_Mixer_Module_Config *conf; - const char *id; + { + E_Mixer_Module_Config *conf; + const char *id; - conf = ctxt->conf; - if (conf->default_gc_id) - eina_stringshare_del(conf->default_gc_id); + conf = ctxt->conf; + if (conf->default_gc_id) + eina_stringshare_del(conf->default_gc_id); - id = ctxt->default_instance->gcc->cf->id; - conf->default_gc_id = eina_stringshare_add(id); - } + id = ctxt->default_instance->gcc->cf->id; + conf->default_gc_id = eina_stringshare_add(id); + } return 1; } @@ -84,15 +80,12 @@ _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata) static void _basic_create_general(E_Config_Dialog *dialog, Evas *evas, E_Config_Dialog_Data *cfdata) { - struct mixer_config_ui_general *ui; - E_Mixer_Module_Context *ctxt; + struct mixer_config_ui_general *ui = &cfdata->ui.general; + E_Mixer_Module_Context *ctxt = dialog->data; Evas_Object *label; Eina_List *l; int i; - ui = &cfdata->ui.general; - ctxt = dialog->data; - ui->frame = e_widget_framelist_add(evas, _("General Settings"), 0); label = e_widget_label_add(evas, _("Mixer to use for global actions:")); @@ -100,45 +93,45 @@ _basic_create_general(E_Config_Dialog *dialog, Evas *evas, E_Config_Dialog_Data ui->radio = e_widget_radio_group_new(&cfdata->default_instance); for (i = 0, l = ctxt->instances; l != NULL; l = l->next, i++) - { - E_Mixer_Instance *inst; - E_Mixer_Gadget_Config *conf; - Evas_Object *o; - char name[128]; - const char *card_name; + { + E_Mixer_Instance *inst; + E_Mixer_Gadget_Config *conf; + Evas_Object *o; + char name[128]; + const char *card_name; - inst = l->data; - conf = inst->conf; + inst = l->data; + conf = inst->conf; - card_name = e_mixer_system_get_card_name(conf->card); - snprintf(name, sizeof(name), "%s: %s", card_name, conf->channel_name); - eina_stringshare_del(card_name); + card_name = e_mixer_system_get_card_name(conf->card); + snprintf(name, sizeof(name), "%s: %s", card_name, conf->channel_name); + eina_stringshare_del(card_name); - o = e_widget_radio_add(evas, name, i, ui->radio); - e_widget_framelist_object_append(ui->frame, o); - } + o = e_widget_radio_add(evas, name, i, ui->radio); + e_widget_framelist_object_append(ui->frame, o); + } e_widget_list_object_append(cfdata->ui.list, ui->frame, 1, 1, 0.5); } static void -cb_mixer_app_del(E_Dialog *dialog, void *data) +cb_mixer_app_del(E_Dialog *dialog __UNUSED__, void *data) { E_Mixer_Module_Context *ctxt = data; ctxt->mixer_dialog = NULL; } static void -cb_mixer_call(void *data, void *data2) +cb_mixer_call(void *data, void *data2 __UNUSED__) { E_Mixer_Module_Context *ctxt = data; E_Container *con; if (ctxt->mixer_dialog) - { - e_dialog_show(ctxt->mixer_dialog); - return; - } + { + e_dialog_show(ctxt->mixer_dialog); + return; + } con = e_container_current_get(e_manager_current_get()); ctxt->mixer_dialog = e_mixer_app_dialog_new(con, cb_mixer_app_del, ctxt); @@ -158,7 +151,7 @@ static Evas_Object * _basic_create(E_Config_Dialog *dialog, Evas *evas, E_Config_Dialog_Data *cfdata) { if (!cfdata) - return NULL; + return NULL; cfdata->ui.list = e_widget_list_add(evas, 0, 0); _basic_create_general(dialog, evas, cfdata); @@ -173,11 +166,11 @@ e_mixer_config_module_dialog_new(E_Container *con, E_Mixer_Module_Context *ctxt) E_Config_Dialog_View *view; if (e_config_dialog_find(_e_mixer_Name, "extensions/mixer")) - return NULL; + return NULL; view = E_NEW(E_Config_Dialog_View, 1); if (!view) - return NULL; + return NULL; view->create_cfdata = _create_data; view->free_cfdata = _free_data; diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c index c2403fd17..b4ebe085d 100644 --- a/src/modules/mixer/e_mod_main.c +++ b/src/modules/mixer/e_mod_main.c @@ -12,7 +12,7 @@ const char * e_mixer_theme_path(void) { #define TF "/e-module-mixer.edj" - int dirlen; + size_t dirlen; dirlen = strlen(mixer_mod->dir); if (dirlen >= sizeof(tmpbuf) - sizeof(TF)) @@ -111,7 +111,7 @@ _mixer_gadget_configuration_free(E_Mixer_Module_Config *mod_conf, E_Mixer_Gadget } static Eina_Bool -_mixer_gadget_configuration_free_foreach(const Eina_Hash *hash, const void *key, void *hdata, void *fdata) +_mixer_gadget_configuration_free_foreach(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *hdata, void *fdata __UNUSED__) { _mixer_gadget_configuration_free_int(hdata); return 1; @@ -317,16 +317,11 @@ _mixer_toggle_mute(E_Mixer_Instance *inst) } static void -_mixer_popup_cb_volume_left_change(void *data, Evas_Object *obj, void *event) +_mixer_popup_cb_volume_left_change(void *data, Evas_Object *obj, void *event __UNUSED__) { - E_Mixer_Instance *inst; - E_Mixer_Channel_State *state; + E_Mixer_Instance *inst = data; + E_Mixer_Channel_State *state = &inst->mixer_state; - inst = data; - if (!inst) - return; - - state = &inst->mixer_state; e_mixer_system_get_volume(inst->sys, inst->channel, &state->left, &state->right); @@ -343,16 +338,11 @@ _mixer_popup_cb_volume_left_change(void *data, Evas_Object *obj, void *event) } static void -_mixer_popup_cb_volume_right_change(void *data, Evas_Object *obj, void *event) +_mixer_popup_cb_volume_right_change(void *data, Evas_Object *obj, void *event __UNUSED__) { - E_Mixer_Instance *inst; - E_Mixer_Channel_State *state; + E_Mixer_Instance *inst = data; + E_Mixer_Channel_State *state = &inst->mixer_state; - inst = data; - if (!inst) - return; - - state = &inst->mixer_state; e_mixer_system_get_volume(inst->sys, inst->channel, &state->left, &state->right); @@ -369,16 +359,11 @@ _mixer_popup_cb_volume_right_change(void *data, Evas_Object *obj, void *event) } static void -_mixer_popup_cb_mute_change(void *data, Evas_Object *obj, void *event) +_mixer_popup_cb_mute_change(void *data, Evas_Object *obj, void *event __UNUSED__) { - E_Mixer_Instance *inst; - E_Mixer_Channel_State *state; + E_Mixer_Instance *inst = data; + E_Mixer_Channel_State *state = &inst->mixer_state; - inst = data; - if (!inst) - return; - - state = &inst->mixer_state; state->mute = e_widget_check_checked_get(obj); e_mixer_system_set_mute(inst->sys, inst->channel, state->mute); @@ -388,9 +373,7 @@ _mixer_popup_cb_mute_change(void *data, Evas_Object *obj, void *event) static Evas_Object * _mixer_popup_add_slider(E_Mixer_Instance *inst, int value, void (*cb) (void *data, Evas_Object *obj, void *event_info)) { - Evas_Object *slider; - - slider = e_slider_add(inst->popup->win->evas); + Evas_Object *slider = e_slider_add(inst->popup->win->evas); evas_object_show(slider); e_slider_orientation_set(slider, 0); e_slider_value_set(slider, value); @@ -402,7 +385,7 @@ _mixer_popup_add_slider(E_Mixer_Instance *inst, int value, void (*cb) (void *dat } static void -_mixer_app_cb_del(E_Dialog *dialog, void *data) +_mixer_app_cb_del(E_Dialog *dialog __UNUSED__, void *data) { E_Mixer_Module_Context *ctxt = data; ctxt->mixer_dialog = NULL; @@ -411,7 +394,7 @@ _mixer_app_cb_del(E_Dialog *dialog, void *data) static void _mixer_popup_del(E_Mixer_Instance *inst); static int -_mixer_popup_input_window_mouse_up_cb(void *data, int type, void *event) +_mixer_popup_input_window_mouse_up_cb(void *data, int type __UNUSED__, void *event) { Ecore_Event_Mouse_Button *ev = event; E_Mixer_Instance *inst = data; @@ -425,7 +408,7 @@ _mixer_popup_input_window_mouse_up_cb(void *data, int type, void *event) } static int -_mixer_popup_input_window_key_down_cb(void *data, int type, void *event) +_mixer_popup_input_window_key_down_cb(void *data, int type __UNUSED__, void *event) { Ecore_Event_Key *ev = event; E_Mixer_Instance *inst = data; @@ -515,7 +498,7 @@ _mixer_app_select_current(E_Dialog *dialog, E_Mixer_Instance *inst) static void -_mixer_popup_cb_mixer(void *data, void *data2) +_mixer_popup_cb_mixer(void *data, void *data2 __UNUSED__) { E_Mixer_Instance *inst = data; E_Mixer_Module_Context *ctxt; @@ -616,11 +599,9 @@ _mixer_popup_new(E_Mixer_Instance *inst) } static void -_mixer_menu_cb_post(void *data, E_Menu *menu) +_mixer_menu_cb_post(void *data, E_Menu *menu __UNUSED__) { - E_Mixer_Instance *inst; - - inst = data; + E_Mixer_Instance *inst = data; if ((!inst) || (!inst->menu)) return; if (inst->menu) @@ -631,14 +612,11 @@ _mixer_menu_cb_post(void *data, E_Menu *menu) } static void -_mixer_menu_cb_cfg(void *data, E_Menu *menu, E_Menu_Item *mi) +_mixer_menu_cb_cfg(void *data, E_Menu *menu __UNUSED__, E_Menu_Item *mi __UNUSED__) { - E_Mixer_Instance *inst; + E_Mixer_Instance *inst = data; E_Container *con; - inst = data; - if (!inst) - return; if (inst->popup) _mixer_popup_del(inst); con = e_container_current_get(e_manager_current_get()); @@ -673,16 +651,11 @@ _mixer_menu_new(E_Mixer_Instance *inst, Evas_Event_Mouse_Down *ev) } static void -_mixer_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event) +_mixer_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event) { - E_Mixer_Instance *inst; - Evas_Event_Mouse_Down *ev; + E_Mixer_Instance *inst = data; + Evas_Event_Mouse_Down *ev = event; - inst = data; - if (!inst) - return; - - ev = event; if (ev->button == 1) { if (!inst->popup) @@ -697,16 +670,11 @@ _mixer_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event) } static void -_mixer_cb_mouse_wheel(void *data, Evas *evas, Evas_Object *obj, void *event) +_mixer_cb_mouse_wheel(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event) { - E_Mixer_Instance *inst; - Evas_Event_Mouse_Wheel *ev; + E_Mixer_Instance *inst = data; + Evas_Event_Mouse_Wheel *ev = event; - inst = data; - if (!inst) - return; - - ev = event; if (ev->direction == 0) { if (ev->z > 0) @@ -746,11 +714,9 @@ _mixer_sys_setup(E_Mixer_Instance *inst) } static int -_mixer_system_cb_update(void *data, E_Mixer_System *sys) +_mixer_system_cb_update(void *data, E_Mixer_System *sys __UNUSED__) { - E_Mixer_Instance *inst; - - inst = data; + E_Mixer_Instance *inst = data; e_mixer_system_get_state(inst->sys, inst->channel, &inst->mixer_state); _mixer_gadget_update(inst); @@ -943,30 +909,28 @@ _gc_shutdown(E_Gadcon_Client *gcc) } static void -_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient) +_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__) { e_gadcon_client_aspect_set(gcc, 16, 16); e_gadcon_client_min_size_set(gcc, 16, 16); } static char * -_gc_label(E_Gadcon_Client_Class *client_class) +_gc_label(E_Gadcon_Client_Class *client_class __UNUSED__) { return _(_e_mixer_Name); } static Evas_Object * -_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas) +_gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas) { - Evas_Object *o; - - o = edje_object_add(evas); + Evas_Object *o = edje_object_add(evas); edje_object_file_set(o, e_mixer_theme_path(), "icon"); return o; } static const char * -_gc_id_new(E_Gadcon_Client_Class *client_class) +_gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__) { E_Mixer_Module_Context *ctxt; Eina_List *instances; @@ -998,7 +962,7 @@ static const E_Gadcon_Client_Class _gc_class = EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, _e_mixer_Name}; static void -_mixer_cb_volume_increase(E_Object *obj, const char *params) +_mixer_cb_volume_increase(E_Object *obj __UNUSED__, const char *params __UNUSED__) { E_Mixer_Module_Context *ctxt; @@ -1014,7 +978,7 @@ _mixer_cb_volume_increase(E_Object *obj, const char *params) } static void -_mixer_cb_volume_decrease(E_Object *obj, const char *params) +_mixer_cb_volume_decrease(E_Object *obj __UNUSED__, const char *params __UNUSED__) { E_Mixer_Module_Context *ctxt; @@ -1030,7 +994,7 @@ _mixer_cb_volume_decrease(E_Object *obj, const char *params) } static void -_mixer_cb_volume_mute(E_Object *obj, const char *params) +_mixer_cb_volume_mute(E_Object *obj __UNUSED__, const char *params __UNUSED__) { E_Mixer_Module_Context *ctxt; @@ -1254,9 +1218,7 @@ _mixer_instances_free(E_Mixer_Module_Context *ctxt) { while (ctxt->instances) { - E_Mixer_Instance *inst; - - inst = ctxt->instances->data; + E_Mixer_Instance *inst = ctxt->instances->data; e_object_del(E_OBJECT(inst->gcc)); } } diff --git a/src/modules/mixer/sys_alsa.c b/src/modules/mixer/sys_alsa.c index 19066a328..a72a8cfb9 100644 --- a/src/modules/mixer/sys_alsa.c +++ b/src/modules/mixer/sys_alsa.c @@ -5,6 +5,7 @@ #include #include #include "e_mod_system.h" +#include "e.h" struct e_mixer_callback_desc { @@ -32,7 +33,7 @@ _cb_dispatch(void *data) desc->idler = NULL; if (!r) - _mixer_callback_del(desc->self, desc); /* desc is invalid then. */ + _mixer_callback_del(desc->self, desc); /* desc is invalid then. */ return 0; } @@ -45,25 +46,25 @@ _cb_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) desc = data; if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) - { - desc->handlers = eina_list_remove(desc->handlers, fd_handler); - if (!desc->handlers) - { - E_Mixer_System *s; - int (*f)(void *, E_Mixer_System *); - void *d; + { + desc->handlers = eina_list_remove(desc->handlers, fd_handler); + if (!desc->handlers) + { + E_Mixer_System *s; + int (*f)(void *, E_Mixer_System *); + void *d; - s = desc->self; - f = desc->func; - d = desc->data; - _mixer_callback_del(s, desc); - _mixer_callback_add(s, f, d); - } - return 0; - } + s = desc->self; + f = desc->func; + d = desc->data; + _mixer_callback_del(s, desc); + _mixer_callback_add(s, f, d); + } + return 0; + } if (!desc->idler) - desc->idler = ecore_idler_add(_cb_dispatch, desc); + desc->idler = ecore_idler_add(_cb_dispatch, desc); return 1; } @@ -76,11 +77,11 @@ _mixer_callback_add(E_Mixer_System *self, int (*func)(void *data, E_Mixer_System len = snd_mixer_poll_descriptors_count(self); if (len <= 0) - return 0; + return 0; desc = malloc(sizeof(struct e_mixer_callback_desc)); if (!desc) - return 0; + return 0; desc->func = func; desc->data = data; @@ -91,20 +92,20 @@ _mixer_callback_add(E_Mixer_System *self, int (*func)(void *data, E_Mixer_System pfds = alloca(len * sizeof(struct pollfd)); len = snd_mixer_poll_descriptors(self, pfds, len); if (len <= 0) - { - free(desc); - return 0; - } + { + free(desc); + return 0; + } while (len > 0) - { - Ecore_Fd_Handler *fd_handler; + { + Ecore_Fd_Handler *fd_handler; - len--; - fd_handler = ecore_main_fd_handler_add( - pfds[len].fd, ECORE_FD_READ, _cb_fd_handler, desc, NULL, NULL); - desc->handlers = eina_list_prepend(desc->handlers, fd_handler); - } + len--; + fd_handler = ecore_main_fd_handler_add( + pfds[len].fd, ECORE_FD_READ, _cb_fd_handler, desc, NULL, NULL); + desc->handlers = eina_list_prepend(desc->handlers, fd_handler); + } snd_mixer_set_callback_private(self, desc); @@ -119,7 +120,7 @@ _mixer_callback_del(E_Mixer_System *self, struct e_mixer_callback_desc *desc) snd_mixer_set_callback_private(self, NULL); EINA_LIST_FREE(desc->handlers, handler) - ecore_main_fd_handler_del(handler); + ecore_main_fd_handler_del(handler); free(desc); @@ -127,7 +128,7 @@ _mixer_callback_del(E_Mixer_System *self, struct e_mixer_callback_desc *desc) } static int -_mixer_callback_replace(E_Mixer_System *self, struct e_mixer_callback_desc *desc, int (*func)(void *data, E_Mixer_System *self), void *data) +_mixer_callback_replace(E_Mixer_System *self __UNUSED__, struct e_mixer_callback_desc *desc, int (*func)(void *data, E_Mixer_System *self), void *data) { desc->func = func; desc->data = data; @@ -142,29 +143,29 @@ e_mixer_system_new(const char *name) int err; if (!name) - return NULL; + return NULL; err = snd_mixer_open(&handle, 0); if (err < 0) - goto error_open; + goto error_open; err = snd_mixer_attach(handle, name); if (err < 0) - goto error_load; + goto error_load; err = snd_mixer_selem_register(handle, NULL, NULL); if (err < 0) - goto error_load; + goto error_load; err = snd_mixer_load(handle); if (err < 0) - goto error_load; + goto error_load; return handle; -error_load: + error_load: snd_mixer_close(handle); -error_open: + error_open: fprintf(stderr, "MIXER: Cannot get hardware info: %s\n", snd_strerror(err)); return NULL; } @@ -174,12 +175,12 @@ e_mixer_system_del(E_Mixer_System *self) { struct e_mixer_callback_desc *desc; - if (self <= 0) - return; + if (!self) + return; desc = snd_mixer_get_callback_private(self); if (desc) - _mixer_callback_del(self, desc); + _mixer_callback_del(self, desc); snd_mixer_close(self); } @@ -190,22 +191,22 @@ e_mixer_system_callback_set(E_Mixer_System *self, int (*func)(void *data, E_Mixe struct e_mixer_callback_desc *desc; if (!self) - return 0; + return 0; desc = snd_mixer_get_callback_private(self); if (!desc) - { - if (func) - return _mixer_callback_add(self, func, data); - return 1; - } + { + if (func) + return _mixer_callback_add(self, func, data); + return 1; + } else - { - if (func) - return _mixer_callback_replace(self, desc, func, data); - else - return _mixer_callback_del(self, desc); - } + { + if (func) + return _mixer_callback_replace(self, desc, func, data); + else + return _mixer_callback_del(self, desc); + } } Eina_List * @@ -217,21 +218,21 @@ e_mixer_system_get_cards(void) cards = NULL; card_num = -1; while (((err = snd_card_next(&card_num)) == 0) && (card_num >= 0)) - { - snd_ctl_t *control; - char buf[256]; + { + snd_ctl_t *control; + char buf[256]; - snprintf(buf, sizeof(buf), "hw:%d", card_num); + snprintf(buf, sizeof(buf), "hw:%d", card_num); - if (snd_ctl_open(&control, buf, 0) < 0) - break; - snd_ctl_close(control); - cards = eina_list_append(cards, eina_stringshare_add(buf)); - } + if (snd_ctl_open(&control, buf, 0) < 0) + break; + snd_ctl_close(control); + cards = eina_list_append(cards, eina_stringshare_add(buf)); + } if (err < 0) - fprintf(stderr, "MIXER: Cannot get available card number: %s\n", - snd_strerror(err)); + fprintf(stderr, "MIXER: Cannot get available card number: %s\n", + snd_strerror(err)); return cards; } @@ -242,7 +243,7 @@ e_mixer_system_free_cards(Eina_List *cards) const char *card; EINA_LIST_FREE(cards, card) - eina_stringshare_del(card); + eina_stringshare_del(card); } const char * @@ -252,7 +253,7 @@ e_mixer_system_get_default_card(void) snd_ctl_t *control; if (snd_ctl_open(&control, buf, 0) < 0) - return NULL; + return NULL; snd_ctl_close(control); return eina_stringshare_add(buf); } @@ -266,30 +267,30 @@ e_mixer_system_get_card_name(const char *card) int err; if (!card) - return NULL; + return NULL; snd_ctl_card_info_alloca(&hw_info); err = snd_ctl_open(&control, card, 0); if (err < 0) - return NULL; + return NULL; err = snd_ctl_card_info(control, hw_info); if (err < 0) - { - fprintf(stderr, "MIXER: Cannot get hardware info: %s: %s\n", card, - snd_strerror(err)); - snd_ctl_close(control); - return NULL; - } + { + fprintf(stderr, "MIXER: Cannot get hardware info: %s: %s\n", card, + snd_strerror(err)); + snd_ctl_close(control); + return NULL; + } snd_ctl_close(control); name = snd_ctl_card_info_get_name(hw_info); if (!name) - { - fprintf(stderr, "MIXER: Cannot get hardware name: %s\n", card); - return NULL; - } + { + fprintf(stderr, "MIXER: Cannot get hardware name: %s\n", card); + return NULL; + } return eina_stringshare_add(name); } @@ -301,19 +302,19 @@ e_mixer_system_get_channels(E_Mixer_System *self) snd_mixer_elem_t *elem; if (!self) - return NULL; + return NULL; channels = NULL; elem = snd_mixer_first_elem(self); for (; elem != NULL; elem = snd_mixer_elem_next(elem)) - { - if ((!snd_mixer_selem_is_active(elem)) || + { + if ((!snd_mixer_selem_is_active(elem)) || (!snd_mixer_selem_has_playback_volume(elem))) - continue; + continue; - channels = eina_list_append(channels, elem); - } + channels = eina_list_append(channels, elem); + } return channels; } @@ -332,24 +333,24 @@ e_mixer_system_get_channels_names(E_Mixer_System *self) snd_mixer_selem_id_t *sid; if (!self) - return NULL; + return NULL; channels = NULL; snd_mixer_selem_id_alloca(&sid); elem = snd_mixer_first_elem(self); for (; elem != NULL; elem = snd_mixer_elem_next(elem)) - { - const char *name; - if ((!snd_mixer_selem_is_active(elem)) || + { + const char *name; + if ((!snd_mixer_selem_is_active(elem)) || (!snd_mixer_selem_has_playback_volume(elem))) - continue; + continue; - snd_mixer_selem_get_id(elem, sid); - name = snd_mixer_selem_id_get_name(sid); - if (name) - channels = eina_list_append(channels, eina_stringshare_add(name)); - } + snd_mixer_selem_get_id(elem, sid); + name = snd_mixer_selem_id_get_name(sid); + if (name) + channels = eina_list_append(channels, eina_stringshare_add(name)); + } return channels; } @@ -360,7 +361,7 @@ e_mixer_system_free_channels_names(Eina_List *channels_names) const char *channel; EINA_LIST_FREE(channels_names, channel) - eina_stringshare_del(channel); + eina_stringshare_del(channel); } const char * @@ -370,23 +371,23 @@ e_mixer_system_get_default_channel_name(E_Mixer_System *self) snd_mixer_selem_id_t *sid; if (!self) - return NULL; + return NULL; snd_mixer_selem_id_alloca(&sid); elem = snd_mixer_first_elem(self); for (; elem != NULL; elem = snd_mixer_elem_next(elem)) - { - const char *name; - if ((!snd_mixer_selem_is_active(elem)) || + { + const char *name; + if ((!snd_mixer_selem_is_active(elem)) || (!snd_mixer_selem_has_playback_volume(elem))) - continue; + continue; - snd_mixer_selem_get_id(elem, sid); - name = snd_mixer_selem_id_get_name(sid); - if (name) - return eina_stringshare_add(name); - } + snd_mixer_selem_get_id(elem, sid); + name = snd_mixer_selem_id_get_name(sid); + if (name) + return eina_stringshare_add(name); + } return NULL; } @@ -398,29 +399,29 @@ e_mixer_system_get_channel_by_name(E_Mixer_System *self, const char *name) snd_mixer_selem_id_t *sid; if ((!self) || (!name)) - return NULL; + return NULL; snd_mixer_selem_id_alloca(&sid); elem = snd_mixer_first_elem(self); for (; elem != NULL; elem = snd_mixer_elem_next(elem)) - { - const char *n; - if ((!snd_mixer_selem_is_active(elem)) || + { + const char *n; + if ((!snd_mixer_selem_is_active(elem)) || (!snd_mixer_selem_has_playback_volume(elem))) - continue; + continue; - snd_mixer_selem_get_id(elem, sid); - n = snd_mixer_selem_id_get_name(sid); - if (n && (strcmp(n, name) == 0)) - return elem; - } + snd_mixer_selem_get_id(elem, sid); + n = snd_mixer_selem_id_get_name(sid); + if (n && (strcmp(n, name) == 0)) + return elem; + } return NULL; } void -e_mixer_system_channel_del(E_Mixer_Channel *channel) +e_mixer_system_channel_del(E_Mixer_Channel *channel __UNUSED__) { } @@ -431,7 +432,7 @@ e_mixer_system_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel) const char *name; if ((!self) || (!channel)) - return NULL; + return NULL; snd_mixer_selem_id_alloca(&sid); snd_mixer_selem_get_id(channel, sid); @@ -446,27 +447,27 @@ e_mixer_system_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *l long lvol, rvol, range, min, max; if ((!self) || (!channel) || (!left) || (!right)) - return 0; + return 0; snd_mixer_handle_events(self); snd_mixer_selem_get_playback_volume_range(channel, &min, &max); range = max - min; if (range < 1) - return 0; + return 0; if (snd_mixer_selem_has_playback_channel(channel, 0)) - snd_mixer_selem_get_playback_volume(channel, 0, &lvol); + snd_mixer_selem_get_playback_volume(channel, 0, &lvol); else - lvol = min; + lvol = min; if (snd_mixer_selem_has_playback_channel(channel, 1)) - snd_mixer_selem_get_playback_volume(channel, 1, &rvol); + snd_mixer_selem_get_playback_volume(channel, 1, &rvol); else - rvol = min; + rvol = min; if (snd_mixer_selem_is_playback_mono(channel) || - snd_mixer_selem_has_playback_volume_joined(channel)) - rvol = lvol; + snd_mixer_selem_has_playback_volume_joined(channel)) + rvol = lvol; *left = rint((double)(lvol - min) * 100 / (double)range); *right = rint((double)(rvol - min) * 100 / (double)range); @@ -481,44 +482,44 @@ e_mixer_system_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int le int mode; if ((!self) || (!channel)) - return 0; + return 0; snd_mixer_handle_events(self); snd_mixer_selem_get_playback_volume_range(channel, &min, &max); div = 100 + min; if (div == 0) - { - div = 1; /* no zero-division */ - min++; - } + { + div = 1; /* no zero-division */ + min++; + } range = max - min; if (range < 1) - return 0; + return 0; mode = 0; if (left >= 0) - { - left = (((range * left) + (range / 2)) / div) - min; - mode |= 1; - } + { + left = (((range * left) + (range / 2)) / div) - min; + mode |= 1; + } if (right >= 0) - { - right = (((range * right) + (range / 2)) / div) - min; - mode |= 2; - } + { + right = (((range * right) + (range / 2)) / div) - min; + mode |= 2; + } if (mode & 1) - snd_mixer_selem_set_playback_volume(channel, 0, left); + snd_mixer_selem_set_playback_volume(channel, 0, left); if ((!snd_mixer_selem_is_playback_mono(channel)) && - (!snd_mixer_selem_has_playback_volume_joined(channel)) && - (mode & 2)) - { - if (snd_mixer_selem_has_playback_channel(channel, 1)) - snd_mixer_selem_set_playback_volume(channel, 1, right); - } + (!snd_mixer_selem_has_playback_volume_joined(channel)) && + (mode & 2)) + { + if (snd_mixer_selem_has_playback_channel(channel, 1)) + snd_mixer_selem_set_playback_volume(channel, 1, right); + } return 1; } @@ -527,7 +528,7 @@ int e_mixer_system_can_mute(E_Mixer_System *self, E_Mixer_Channel *channel) { if ((!self) || (!channel)) - return 0; + return 0; snd_mixer_handle_events(self); return (snd_mixer_selem_has_playback_switch(channel) || @@ -538,22 +539,22 @@ int e_mixer_system_get_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int *mute) { if ((!self) || (!channel) || (!mute)) - return 0; + return 0; snd_mixer_handle_events(self); if (snd_mixer_selem_has_playback_switch(channel) || - snd_mixer_selem_has_playback_switch_joined(channel)) - { - int m; + snd_mixer_selem_has_playback_switch_joined(channel)) + { + int m; - /* XXX: not checking for return, always returns 0 even if it worked. - * alsamixer also don't check it. Bug? - */ - snd_mixer_selem_get_playback_switch(channel, 0, &m); - *mute = !m; - } + /* XXX: not checking for return, always returns 0 even if it worked. + * alsamixer also don't check it. Bug? + */ + snd_mixer_selem_get_playback_switch(channel, 0, &m); + *mute = !m; + } else - *mute = 0; + *mute = 0; return 1; } @@ -562,14 +563,14 @@ int e_mixer_system_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int mute) { if ((!self) || (!channel)) - return 0; + return 0; snd_mixer_handle_events(self); if (snd_mixer_selem_has_playback_switch(channel) || - snd_mixer_selem_has_playback_switch_joined(channel)) - return snd_mixer_selem_set_playback_switch_all(channel, !mute); + snd_mixer_selem_has_playback_switch_joined(channel)) + return snd_mixer_selem_set_playback_switch_all(channel, !mute); else - return 0; + return 0; } int @@ -578,7 +579,7 @@ e_mixer_system_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer int r; if (!state) - return 0; + return 0; r = e_mixer_system_get_mute(self, channel, &state->mute); r &= e_mixer_system_get_volume(self, channel, &state->left, &state->right); @@ -591,7 +592,7 @@ e_mixer_system_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E int r; if (!state) - return 0; + return 0; r = e_mixer_system_set_mute(self, channel, state->mute); r &= e_mixer_system_set_volume(self, channel, state->left, state->right); @@ -602,7 +603,7 @@ int e_mixer_system_has_capture(E_Mixer_System *self, E_Mixer_Channel *channel) { if ((!self) || (!channel)) - return 0; + return 0; return snd_mixer_selem_has_capture_switch(channel); }