Enlightenment CVS committal Author : devilhorns Project : e_modules Module : mixer
Dir : e_modules/mixer Modified Files: alsa_mixer.c alsa_mixer.h e_mod_main.c Log Message: Make sure we setup a default config if there is none. Some work on get/set volume for alsa (not done yet). =================================================================== RCS file: /cvs/e/e_modules/mixer/alsa_mixer.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- alsa_mixer.c 11 Sep 2006 11:21:43 -0000 1.4 +++ alsa_mixer.c 11 Sep 2006 12:00:11 -0000 1.5 @@ -259,8 +259,13 @@ int alsa_get_volume(int card_id, int channel_id) { - Mixer_Card *card; - Mixer_Channel *chan; + Mixer_Card *card; + Mixer_Channel *chan; + snd_mixer_elem_t *elem; + snd_mixer_t *handle; + snd_mixer_selem_id_t *sid; + int err, i; + long vol = 0; card = alsa_get_card(card_id); if (!card) return 0; @@ -268,7 +273,31 @@ chan = _alsa_card_get_channel(card, channel_id); if (!chan) return 0; - printf("Get Volume\n"); + printf("\n\nGet Volume\n"); + if ((err = snd_mixer_open(&handle, 0)) < 0) + { + printf("Cannot open mixer: %s\n", snd_strerror(err)); + return 0; + } + + for (i = 0, elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) + { + snd_mixer_selem_get_id(elem, sid); + if (!snd_mixer_selem_is_active(elem)) continue; + + if (snd_mixer_selem_has_playback_volume(elem)) + { + const char *name; + + name = snd_mixer_selem_id_get_name(sid); + if (!strcmp(name, chan->name)) + { + snd_mixer_selem_get_playback_volume(elem, 0, &vol); + break; + } + } + } + return (int)vol; } int =================================================================== RCS file: /cvs/e/e_modules/mixer/alsa_mixer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- alsa_mixer.h 11 Sep 2006 11:21:43 -0000 1.4 +++ alsa_mixer.h 11 Sep 2006 12:00:11 -0000 1.5 @@ -21,7 +21,7 @@ void *alsa_card_get_channel (void *data, int channel_id); void alsa_free_cards (void *data); -int alsa_get_volume (int card_id, int channel_id); -int alsa_set_volume (int card_id, int channel_id, int vol); +int alsa_get_volume (int card_id, int channel_id); +int alsa_set_volume (int card_id, int channel_id, int vol); #endif =================================================================== RCS file: /cvs/e/e_modules/mixer/e_mod_main.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- e_mod_main.c 11 Sep 2006 11:21:43 -0000 1.12 +++ e_mod_main.c 11 Sep 2006 12:00:11 -0000 1.13 @@ -225,7 +225,9 @@ ci = E_NEW(Config_Item, 1); ci->id = evas_stringshare_add(id); - + ci->card_id = 0; + ci->channel_id = 0; + mixer_config->items = evas_list_append(mixer_config->items, ci); return ci; } @@ -292,9 +294,19 @@ E_CONFIG_LIST(D, T, items, conf_item_edd); mixer_config = e_config_domain_load("module.mixer", conf_edd); - if (!mixer_config) - mixer_config = E_NEW(Config, 1); - + if (!mixer_config) + { + Config_Item *ci; + + mixer_config = E_NEW(Config, 1); + ci = E_NEW(Config_Item, 1); + ci->id = evas_stringshare_add("0"); + ci->card_id = 0; + ci->channel_id = 0; + + mixer_config->items = evas_list_append(mixer_config->items, ci); + } + mixer_config->module = m; e_gadcon_provider_register(&_gc_class); @@ -366,14 +378,18 @@ _mixer_window_simple_pop_up(Instance *inst) { E_Container *con; + Config_Item *ci; Mixer_Win_Simple *win; Evas_Coord ox, oy, ow, oh; Evas_Coord sw, sh; - int cx, cy, cw, ch; + int cx, cy, cw, ch, vol; if (!inst || !inst->mixer) return; if (!(con = e_container_current_get(e_manager_current_get()))) return; + ci = _mixer_config_item_get(inst->gcc->id); + if (!ci) return; + evas_object_geometry_get(inst->mixer->base, &ox, &oy, &ow, &oh); if (!(win = inst->mixer->simple_win)) @@ -413,7 +429,14 @@ evas_object_show(win->slider); evas_object_smart_callback_add(win->slider, "changed", _mixer_window_simple_changed_cb, win); - + if (inst->mixer->mix_sys->get_volume) + { +// vol = inst->mixer->mix_sys->get_volume(ci->card_id, ci->channel_id); +// vol = vol * 100; +// printf("\n\nVolume: %i\n\n", vol); +// e_slider_value_set(win->slider, (double)vol); + } + e_slider_min_size_get(win->slider, &sw, &sh); if (sw < ow) sw = ow; if (sh < 150) sh = 150; @@ -555,7 +578,7 @@ Mixer_Win_Simple *win; Mixer *mixer; Config_Item *ci; - double val; + long val; if (!(win = data)) return; ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs