revert mixer back to a working state -> rev 83903

SVN revision: 84013
This commit is contained in:
Carsten Haitzler 2013-02-17 03:31:45 +00:00
parent 8425ee72ef
commit cb2b350872
12 changed files with 778 additions and 797 deletions

View File

@ -11,11 +11,10 @@ mixer_module_la_CFLAGS = $(AM_CFLAGS) @SOUND_CFLAGS@
mixer_module_la_SOURCES = mixer/e_mod_main.c \
mixer/e_mod_main.h \
mixer/e_mod_system.h \
mixer/app_mixer.c \
mixer/conf_gadget.c \
mixer/conf_module.c \
mixer/e_mod_mixer.h \
mixer/e_mod_mixer.c \
mixer/msg.c \
mixer/Pulse.h \
mixer/pa.h \

View File

@ -5,12 +5,12 @@ extern const char _e_mixer_Name[];
typedef struct E_Mixer_App_Dialog_Data
{
E_Mixer_System *sys;
const char *sys_card_name;
const char *card;
const char *channel_name;
int lock_sliders;
Eina_List *cards;
Eina_List *channel_infos;
E_Mixer_Channel_Info *channel_info;
Eina_List *channels_infos;
struct channel_info *channel_info;
E_Mixer_Channel_State state;
struct e_mixer_app_ui
@ -51,6 +51,14 @@ typedef struct E_Mixer_App_Dialog_Data
} del;
} E_Mixer_App_Dialog_Data;
struct channel_info
{
int has_capture;
const char *name;
E_Mixer_Channel *id;
E_Mixer_App_Dialog_Data *app;
};
static void
_cb_changed_left(void *data, Evas_Object *obj __UNUSED__)
{
@ -65,7 +73,7 @@ _cb_changed_left(void *data, Evas_Object *obj __UNUSED__)
state->right);
}
e_mod_mixer_volume_set(app->sys, app->channel_info,
e_mod_mixer_volume_set(app->sys, app->channel_info->id,
state->left, state->right);
}
@ -83,7 +91,7 @@ _cb_changed_right(void *data, Evas_Object *obj __UNUSED__)
state->left);
}
e_mod_mixer_volume_set(app->sys, app->channel_info,
e_mod_mixer_volume_set(app->sys, app->channel_info->id,
state->left, state->right);
}
@ -92,7 +100,7 @@ _cb_changed_mute(void *data, Evas_Object *obj __UNUSED__)
{
E_Mixer_App_Dialog_Data *app = data;
e_mod_mixer_mute_set(app->sys, app->channel_info, app->state.mute);
e_mod_mixer_mute_set(app->sys, app->channel_info->id, app->state.mute);
}
static void
@ -112,7 +120,7 @@ _cb_changed_lock_sliders(void *data, Evas_Object *obj __UNUSED__)
e_widget_slider_value_int_set(app->ui.channel_editor.left, state->left);
e_widget_slider_value_int_set(app->ui.channel_editor.right, state->right);
e_mod_mixer_volume_set(app->sys, app->channel_info,
e_mod_mixer_volume_set(app->sys, app->channel_info->id,
state->left, state->right);
}
@ -141,23 +149,23 @@ _update_channel_editor_state(E_Mixer_App_Dialog_Data *app, const E_Mixer_Channel
{
struct e_mixer_app_ui_channel_editor *ui = &app->ui.channel_editor;
if (!e_mod_mixer_channel_has_no_volume(app->channel_info))
{
if (e_mod_mixer_channel_is_mono(app->channel_info))
{
e_widget_slider_value_int_set(ui->left, state.left);
}
else
{
e_widget_slider_value_int_set(ui->left, state.left);
e_widget_slider_value_int_set(ui->right, state.right);
}
}
e_widget_disabled_set(ui->left, 0);
e_widget_disabled_set(ui->right, 0);
e_widget_disabled_set(ui->lock_sliders, 0);
if (e_mod_mixer_channel_is_mutable(app->channel_info))
e_widget_slider_value_int_set(ui->left, state.left);
e_widget_slider_value_int_set(ui->right, state.right);
if (e_mod_mixer_mutable_get(app->sys, app->channel_info->id))
{
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);
}
}
static void
@ -165,69 +173,37 @@ _populate_channel_editor(E_Mixer_App_Dialog_Data *app)
{
struct e_mixer_app_ui_channel_editor *ui = &app->ui.channel_editor;
E_Mixer_Channel_State state;
const char *card_name;
if ((!app->sys_card_name) || (!app->channel_name))
card_name = e_mod_mixer_card_name_get(app->card);
if (!card_name)
{
_disable_channel_editor(app);
return;
}
e_widget_entry_text_set(ui->card, app->sys_card_name);
e_widget_entry_text_set(ui->card, card_name);
eina_stringshare_del(card_name);
e_widget_entry_text_set(ui->channel, app->channel_name);
if (e_mod_mixer_channel_is_boost(app->channel_info))
e_widget_entry_text_set(ui->type, _("Boost"));
else if (e_mod_mixer_channel_has_playback(app->channel_info))
e_widget_entry_text_set(ui->type, _("Playback"));
else if (e_mod_mixer_channel_has_capture(app->channel_info))
e_widget_entry_text_set(ui->type, _("Capture"));
if (e_mod_mixer_capture_get(app->sys, app->channel_info->id))
e_widget_entry_text_set(ui->type, _("Capture"));
else
e_widget_entry_text_set(ui->type, _("Switch"));
e_widget_entry_text_set(ui->type, _("Playback"));
e_mod_mixer_state_get(app->sys, app->channel_info, &state);
e_mod_mixer_state_get(app->sys, app->channel_info->id, &state);
_update_channel_editor_state(app, state);
if (e_mod_mixer_channel_is_mutable(app->channel_info))
{
e_widget_disabled_set(ui->mute, 0);
}
else
{
e_widget_disabled_set(ui->mute, 1);
e_widget_check_checked_set(ui->mute, 0);
}
if (e_mod_mixer_channel_has_no_volume(app->channel_info))
{
app->lock_sliders = 1;
e_widget_slider_value_int_set(ui->left, 0);
e_widget_slider_value_int_set(ui->right, 0);
e_widget_disabled_set(ui->lock_sliders, 1);
e_widget_disabled_set(ui->left, 1);
e_widget_disabled_set(ui->right, 1);
}
else if (e_mod_mixer_channel_is_mono(app->channel_info))
{
app->lock_sliders = 0;
e_widget_slider_value_int_set(ui->right, 0);
e_widget_disabled_set(ui->lock_sliders, 1);
e_widget_disabled_set(ui->left, 0);
e_widget_disabled_set(ui->right, 1);
}
else
{
app->lock_sliders = (state.left == state.right);
e_widget_disabled_set(ui->lock_sliders, 0);
e_widget_disabled_set(ui->left, 0);
e_widget_disabled_set(ui->right, 0);
}
app->lock_sliders = (state.left == state.right);
e_widget_check_checked_set(ui->lock_sliders, app->lock_sliders);
}
static void
_cb_channel_selected(void *data)
{
E_Mixer_Channel_Info *info = data;
struct channel_info *info = data;
E_Mixer_App_Dialog_Data *app;
app = info->app;
@ -235,6 +211,54 @@ _cb_channel_selected(void *data)
_populate_channel_editor(app);
}
static int
_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;
else if (a->has_capture > b->has_capture)
return 1;
return strcmp(a->name, b->name);
}
static Eina_List *
_channels_info_new(E_Mixer_System *sys)
{
Eina_List *channels, *channels_infos, *l;
channels = e_mod_mixer_channels_get(sys);
channels_infos = NULL;
for (l = channels; l; l = l->next)
{
struct channel_info *info;
info = malloc(sizeof(*info));
info->id = l->data;
info->name = e_mod_mixer_channel_name_get(sys, info->id);
info->has_capture = e_mod_mixer_capture_get(sys, info->id);
channels_infos = eina_list_append(channels_infos, info);
}
e_mod_mixer_channels_free(channels);
return eina_list_sort(channels_infos, -1, _channel_info_cmp);
}
static void
_channels_info_free(Eina_List *list)
{
struct channel_info *info;
EINA_LIST_FREE(list, info)
{
eina_stringshare_del(info->name);
free(info);
}
}
static int
_cb_system_update(void *data, E_Mixer_System *sys __UNUSED__)
{
@ -244,7 +268,7 @@ _cb_system_update(void *data, E_Mixer_System *sys __UNUSED__)
if ((!app->sys) || (!app->channel_info))
return 1;
e_mod_mixer_state_get(app->sys, app->channel_info, &state);
e_mod_mixer_state_get(app->sys, app->channel_info->id, &state);
_update_channel_editor_state(app, state);
return 1;
@ -256,7 +280,7 @@ _populate_channels(E_Mixer_App_Dialog_Data *app)
Eina_List *l;
Evas_Object *ilist;
int header_input;
int i, selected;
int i;
ilist = app->ui.channels.list;
edje_freeze();
@ -265,61 +289,75 @@ _populate_channels(E_Mixer_App_Dialog_Data *app)
if (app->sys)
e_mod_mixer_del(app->sys);
app->sys = e_mod_mixer_new(app->sys_card_name);
app->sys = e_mod_mixer_new(app->card);
if (_mixer_using_default)
e_mixer_alsa_callback_set(app->sys, _cb_system_update, app);
e_mixer_system_callback_set(app->sys, _cb_system_update, app);
if (app->channel_infos)
e_mod_mixer_channel_infos_free(app->channel_infos);
app->channel_infos = e_mod_mixer_channel_infos_get(app->sys);
eina_stringshare_del(app->channel_name);
app->channel_name = e_mod_mixer_channel_default_name_get(app->sys);
i = 0;
selected = 0;
header_input = 0;
for (l = app->channel_infos; l; l = l->next, i++)
if (app->channels_infos)
_channels_info_free(app->channels_infos);
app->channels_infos = _channels_info_new(app->sys);
if (app->channels_infos)
{
E_Mixer_Channel_Info *info = l->data;
if (header_input != e_mod_mixer_channel_group_get(info))
struct channel_info *info = app->channels_infos->data;
if (info->has_capture)
{
if (e_mod_mixer_channel_is_boost(info))
e_widget_ilist_header_append(ilist, NULL, _("Boost"));
else if (e_mod_mixer_channel_has_playback(info))
e_widget_ilist_header_append(ilist, NULL, _("Playback"));
else if (e_mod_mixer_channel_has_capture(info))
e_widget_ilist_header_append(ilist, NULL, _("Capture"));
else
e_widget_ilist_header_append(ilist, NULL, _("Switch"));
header_input = e_mod_mixer_channel_group_get(info);
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; l = l->next, i++)
{
struct channel_info *info = l->data;
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 ((selected == 0) && app->channel_name && 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;
selected = 1;
}
}
if ((selected == 0) && (i > 0))
e_widget_ilist_selected_set(ilist, 0);
else
app->channel_name = NULL;
e_widget_ilist_go(ilist);
e_widget_ilist_thaw(ilist);
edje_thaw();
}
static void
select_card(E_Mixer_App_Dialog_Data *app)
{
_populate_channels(app);
if (e_widget_ilist_count(app->ui.channels.list) > 0)
e_widget_ilist_selected_set(app->ui.channels.list, 1);
else
_disable_channel_editor(app);
}
static void
_cb_card_selected(void *data)
{
_populate_channels(data);
select_card(data);
}
static void
@ -329,11 +367,12 @@ _create_cards(E_Dialog *dialog __UNUSED__, Evas *evas, E_Mixer_App_Dialog_Data *
const char *card;
Eina_List *l;
app->cards = e_mod_mixer_card_names_get();
app->card = e_mod_mixer_card_default_get();
app->cards = e_mod_mixer_cards_get();
if (eina_list_count(app->cards) < 2)
return;
ui->list = e_widget_ilist_add(evas, 32, 32, &app->sys_card_name);
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)
@ -434,6 +473,12 @@ _create_ui(E_Dialog *dialog, E_Mixer_App_Dialog_Data *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);
else
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;
@ -448,13 +493,12 @@ _mixer_app_dialog_del(E_Dialog *dialog, E_Mixer_App_Dialog_Data *app)
if (app->del.func)
app->del.func(dialog, app->del.data);
if ((!app->ui.cards.list) && (app->ui.channels.list))
eina_stringshare_del(app->sys_card_name);
eina_stringshare_del(app->card);
eina_stringshare_del(app->channel_name);
if (app->cards)
e_mod_mixer_card_names_free(app->cards);
if (app->channel_infos)
e_mod_mixer_channel_infos_free(app->channel_infos);
e_mod_mixer_cards_free(app->cards);
if (app->channels_infos)
_channels_info_free(app->channels_infos);
e_mod_mixer_del(app->sys);
e_util_defer_object_del(E_OBJECT(dialog));
@ -514,47 +558,84 @@ e_mixer_app_dialog_new(E_Container *con, void (*func)(E_Dialog *dialog, void *da
return dialog;
}
int
e_mixer_app_dialog_select(E_Dialog *dialog, const char *sys_card_name, const char *channel_name)
static inline int
_find_card_by_name(E_Mixer_App_Dialog_Data *app, const char *card_name)
{
int n, i;
Eina_List *l;
int i;
if (!card_name)
return 0;
for (i = 0, l = app->cards; l; i++, l = l->next)
if (strcmp(card_name, l->data) == 0)
return i;
return -1;
}
static inline int
_find_channel_by_name(E_Mixer_App_Dialog_Data *app, const char *channel_name)
{
struct channel_info *info;
Eina_List *l;
int i = 0;
int header_input;
if (!channel_name)
return 0;
if (app->channels_infos)
{
info = app->channels_infos->data;
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 (strcmp(channel_name, info->name) == 0)
return i;
++i;
}
return -1;
}
int
e_mixer_app_dialog_select(E_Dialog *dialog, const char *card_name, const char *channel_name)
{
E_Mixer_App_Dialog_Data *app;
int n;
if (!dialog)
return 0;
if ((!sys_card_name) || (!channel_name))
if ((!card_name) || (!channel_name))
return 0;
app = dialog->data;
if (!app)
return 0;
n = -1;
for (i = 0, l = app->cards; l; i++, l = l->next)
{
if (strcmp(sys_card_name, l->data) == 0)
n = i;
break;
}
n = _find_card_by_name(app, card_name);
if (n < 0)
{
/* FIXME device disappeared, very bad !! */
return 0;
}
/* app->channel_name will be overriden by selection in _populate_channels */
app->channel_name = channel_name;
return 0;
if (app->ui.cards.list)
e_widget_ilist_selected_set(app->ui.cards.list, n);
else if (app->ui.channels.list)
{
app->sys_card_name = eina_stringshare_add(sys_card_name);
_populate_channels(app);
}
n = _find_channel_by_name(app, channel_name);
if (n < 0)
return 0;
e_widget_ilist_selected_set(app->ui.channels.list, n);
return 1;
}

View File

@ -12,8 +12,8 @@ struct _E_Config_Dialog_Data
const char *card;
const char *channel_name;
Eina_List *cards;
Eina_List *card_names;
Eina_List *channel_names;
Eina_List *cards_names;
Eina_List *channels_names;
struct mixer_config_ui
{
Evas_Object *table;
@ -42,7 +42,7 @@ struct _E_Config_Dialog_Data
};
static void
_mixer_fill_card_infos(E_Config_Dialog_Data *cfdata)
_mixer_fill_cards_info(E_Config_Dialog_Data *cfdata)
{
const char *card;
const char *name;
@ -50,8 +50,8 @@ _mixer_fill_card_infos(E_Config_Dialog_Data *cfdata)
int i = 0;
cfdata->card_num = -1;
cfdata->cards = e_mod_mixer_card_names_get();
cfdata->card_names = NULL;
cfdata->cards = e_mod_mixer_cards_get();
cfdata->cards_names = NULL;
EINA_LIST_FOREACH(cfdata->cards, l, card)
{
name = e_mod_mixer_card_name_get(card);
@ -59,7 +59,7 @@ _mixer_fill_card_infos(E_Config_Dialog_Data *cfdata)
(strcmp(card, cfdata->card) == 0))
cfdata->card_num = i;
cfdata->card_names = eina_list_append(cfdata->card_names, name);
cfdata->cards_names = eina_list_append(cfdata->cards_names, name);
i++;
}
@ -69,7 +69,7 @@ _mixer_fill_card_infos(E_Config_Dialog_Data *cfdata)
}
static void
_mixer_fill_channel_infos(E_Config_Dialog_Data *cfdata)
_mixer_fill_channels_info(E_Config_Dialog_Data *cfdata)
{
E_Mixer_System *sys;
const char *channel;
@ -82,8 +82,8 @@ _mixer_fill_channel_infos(E_Config_Dialog_Data *cfdata)
cfdata->channel = 0;
cfdata->channel_name = eina_stringshare_add(cfdata->conf->channel_name);
cfdata->channel_names = e_mod_mixer_channel_names_get(sys);
EINA_LIST_FOREACH(cfdata->channel_names, l, channel)
cfdata->channels_names = e_mod_mixer_channels_names_get(sys);
EINA_LIST_FOREACH(cfdata->channels_names, l, channel)
{
if (channel && cfdata->channel_name &&
(channel == cfdata->channel_name ||
@ -114,8 +114,8 @@ _create_data(E_Config_Dialog *dialog)
cfdata->show_locked = conf->show_locked;
cfdata->keybindings_popup = conf->keybindings_popup;
cfdata->card = eina_stringshare_add(conf->card);
_mixer_fill_card_infos(cfdata);
_mixer_fill_channel_infos(cfdata);
_mixer_fill_cards_info(cfdata);
_mixer_fill_channels_info(cfdata);
return cfdata;
}
@ -132,13 +132,13 @@ _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata)
if (!cfdata)
return;
EINA_LIST_FREE(cfdata->card_names, card)
EINA_LIST_FREE(cfdata->cards_names, card)
eina_stringshare_del(card);
if (cfdata->channel_names)
e_mod_mixer_channel_names_free(cfdata->channel_names);
if (cfdata->channels_names)
e_mod_mixer_channels_free(cfdata->channels_names);
if (cfdata->cards)
e_mod_mixer_card_names_free(cfdata->cards);
e_mod_mixer_cards_free(cfdata->cards);
eina_stringshare_del(cfdata->card);
eina_stringshare_del(cfdata->channel_name);
@ -166,7 +166,7 @@ _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata)
conf->card = eina_stringshare_ref(card);
}
channel = eina_list_nth(cfdata->channel_names, cfdata->channel);
channel = eina_list_nth(cfdata->channels_names, cfdata->channel);
if (channel)
{
eina_stringshare_del(conf->channel_name);
@ -227,7 +227,7 @@ _fill_channels(Evas *evas, E_Config_Dialog_Data *cfdata)
int i = 0;
ui->radio = e_widget_radio_group_new(&cfdata->channel);
EINA_LIST_FOREACH(cfdata->channel_names, l, name)
EINA_LIST_FOREACH(cfdata->channels_names, l, name)
{
Evas_Object *ow;
@ -293,13 +293,13 @@ _card_change(void *data, Evas_Object *obj, void *event __UNUSED__)
eina_stringshare_del(cfdata->card);
e_mod_mixer_channel_names_free(cfdata->channel_names);
e_mod_mixer_channels_free(cfdata->channels_names);
eina_stringshare_del(cfdata->channel_name);
card = eina_list_nth(cfdata->cards, cfdata->card_num);
cfdata->card = eina_stringshare_add(card);
_mixer_fill_channel_infos(cfdata);
_mixer_fill_channels_info(cfdata);
evas = evas_object_evas_get(obj);
_clear_channels(cfdata);
@ -316,7 +316,7 @@ _basic_create_cards(Evas *evas, E_Config_Dialog_Data *cfdata)
ui->frame = e_widget_framelist_add(evas, _("Sound Cards"), 0);
ui->radio = e_widget_radio_group_new(&cfdata->card_num);
EINA_LIST_FOREACH(cfdata->card_names, l, card)
EINA_LIST_FOREACH(cfdata->cards_names, l, card)
{
Evas_Object *ow;

View File

@ -105,7 +105,7 @@ _basic_create_general(E_Config_Dialog *dialog, Evas *evas, E_Config_Dialog_Data
inst = l->data;
conf = inst->conf;
card_name = e_mixer_alsa_get_card_name(conf->card);
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);

View File

@ -9,6 +9,28 @@ static char tmpbuf[4096]; /* general purpose buffer, just use immediately */
static const char _conf_domain[] = "module.mixer";
static const char _name[] = "mixer";
const char _e_mixer_Name[] = N_("Mixer");
Eina_Bool _mixer_using_default = EINA_FALSE;
E_Mixer_Volume_Get_Cb e_mod_mixer_volume_get;
E_Mixer_Volume_Set_Cb e_mod_mixer_volume_set;
E_Mixer_Mute_Get_Cb e_mod_mixer_mute_get;
E_Mixer_Mute_Set_Cb e_mod_mixer_mute_set;
E_Mixer_Capture_Cb e_mod_mixer_mutable_get;
E_Mixer_State_Get_Cb e_mod_mixer_state_get;
E_Mixer_Capture_Cb e_mod_mixer_capture_get;
E_Mixer_Cb e_mod_mixer_new;
E_Mixer_Cb e_mod_mixer_del;
E_Mixer_Cb e_mod_mixer_channel_default_name_get;
E_Mixer_Cb e_mod_mixer_channel_get_by_name;
E_Mixer_Cb e_mod_mixer_channel_name_get;
E_Mixer_Cb e_mod_mixer_channel_del;
E_Mixer_Cb e_mod_mixer_channel_free;
E_Mixer_Cb e_mod_mixer_channels_free;
E_Mixer_Cb e_mod_mixer_channels_get;
E_Mixer_Cb e_mod_mixer_channels_names_get;
E_Mixer_Cb e_mod_mixer_card_name_get;
E_Mixer_Cb e_mod_mixer_cards_get;
E_Mixer_Cb e_mod_mixer_cards_free;
E_Mixer_Cb e_mod_mixer_card_default_get;
static void _mixer_actions_unregister(E_Mixer_Module_Context *ctxt);
static void _mixer_actions_register(E_Mixer_Module_Context *ctxt);
@ -251,7 +273,7 @@ _mixer_balance_left(E_Mixer_Instance *inst)
E_Mixer_Channel_State *state;
state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
if (state->left >= 0)
{
@ -268,7 +290,7 @@ _mixer_balance_left(E_Mixer_Instance *inst)
state->right = 100;
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
_mixer_gadget_update(inst);
}
@ -279,7 +301,7 @@ _mixer_balance_right(E_Mixer_Instance *inst)
E_Mixer_Channel_State *state;
state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
if (state->left >= 0)
{
@ -295,7 +317,7 @@ _mixer_balance_right(E_Mixer_Instance *inst)
else
state->right = 0;
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
_mixer_gadget_update(inst);
}
@ -306,7 +328,7 @@ _mixer_volume_increase(E_Mixer_Instance *inst, Eina_Bool non_ui)
E_Mixer_Channel_State *state;
state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
if (state->left >= 0)
{
@ -324,7 +346,7 @@ _mixer_volume_increase(E_Mixer_Instance *inst, Eina_Bool non_ui)
state->right = 100;
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
_mixer_gadget_update(inst);
if (non_ui)
@ -337,7 +359,7 @@ _mixer_volume_decrease(E_Mixer_Instance *inst, Eina_Bool non_ui)
E_Mixer_Channel_State *state;
state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
if (state->left >= 0)
{
@ -354,7 +376,7 @@ _mixer_volume_decrease(E_Mixer_Instance *inst, Eina_Bool non_ui)
state->right = 0;
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
_mixer_gadget_update(inst);
if (non_ui)
@ -366,14 +388,14 @@ _mixer_toggle_mute(E_Mixer_Instance *inst, Eina_Bool non_ui)
{
E_Mixer_Channel_State *state;
if (!e_mod_mixer_channel_is_mutable(inst->channel_info))
if (!e_mod_mixer_mutable_get(inst->sys, inst->channel))
return;
state = &inst->mixer_state;
e_mod_mixer_mute_get(inst->sys, inst->channel_info, &state->mute);
e_mod_mixer_mute_get(inst->sys, inst->channel, &state->mute);
state->mute = !state->mute;
e_mod_mixer_mute_set(inst->sys, inst->channel_info, state->mute);
if (!state->mute) e_mod_mixer_volume_set(inst->sys, inst->channel_info, state->left, state->right);
e_mod_mixer_mute_set(inst->sys, inst->channel, state->mute);
if (!state->mute) e_mod_mixer_volume_set(inst->sys, inst->channel, state->left, state->right);
_mixer_gadget_update(inst);
if (non_ui)
{
@ -390,7 +412,7 @@ _mixer_popup_cb_volume_left_change(void *data, Evas_Object *obj, void *event __U
E_Mixer_Instance *inst = data;
E_Mixer_Channel_State *state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
state->left = (int)e_slider_value_get(obj);
@ -400,7 +422,7 @@ _mixer_popup_cb_volume_left_change(void *data, Evas_Object *obj, void *event __U
e_slider_value_set(inst->ui.right, state->right);
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
if (!_mixer_using_default) _mixer_gadget_update(inst);
}
@ -411,7 +433,7 @@ _mixer_popup_cb_volume_right_change(void *data, Evas_Object *obj, void *event __
E_Mixer_Instance *inst = data;
E_Mixer_Channel_State *state = &inst->mixer_state;
e_mod_mixer_volume_get(inst->sys, inst->channel_info,
e_mod_mixer_volume_get(inst->sys, inst->channel,
&state->left, &state->right);
state->right = (int)e_slider_value_get(obj);
@ -421,7 +443,7 @@ _mixer_popup_cb_volume_right_change(void *data, Evas_Object *obj, void *event __
e_slider_value_set(inst->ui.left, state->left);
}
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
state->left, state->right);
if (!_mixer_using_default) _mixer_gadget_update(inst);
}
@ -433,7 +455,7 @@ _mixer_popup_cb_mute_change(void *data, Evas_Object *obj, void *event __UNUSED__
E_Mixer_Channel_State *state = &inst->mixer_state;
state->mute = e_widget_check_checked_get(obj);
e_mod_mixer_mute_set(inst->sys, inst->channel_info, state->mute);
e_mod_mixer_mute_set(inst->sys, inst->channel, state->mute);
if (!_mixer_using_default) _mixer_gadget_update(inst);
}
@ -619,8 +641,7 @@ _mixer_popup_cb_mixer(void *data, void *data2 __UNUSED__)
ctxt = mixer_mod->data;
if (ctxt->mixer_dialog)
{
/* maybe not update mixer dialog current selection */
/* _mixer_app_select_current(ctxt->mixer_dialog, inst); */
_mixer_app_select_current(ctxt->mixer_dialog, inst);
e_dialog_show(ctxt->mixer_dialog);
return;
}
@ -643,14 +664,13 @@ _mixer_popup_new(E_Mixer_Instance *inst)
return;
state = &inst->mixer_state;
e_mod_mixer_state_get(inst->sys, inst->channel_info, state);
e_mod_mixer_state_get(inst->sys, inst->channel, state);
if (e_mod_mixer_channel_has_no_volume(inst->channel_info) ||
e_mod_mixer_channel_is_mono(inst->channel_info) ||
(inst->conf->lock_sliders && !inst->conf->show_locked))
colspan = 1;
else
if ((state->right >= 0) &&
(inst->conf->show_locked || (!inst->conf->lock_sliders)))
colspan = 2;
else
colspan = 1;
inst->popup = e_gadcon_popup_new(inst->gcc);
evas = inst->popup->win->evas;
@ -661,38 +681,28 @@ _mixer_popup_new(E_Mixer_Instance *inst)
e_widget_table_object_append(inst->ui.table, inst->ui.label,
0, 0, colspan, 1, 0, 0, 0, 0);
if (colspan==1)
if (state->left >= 0)
{
if (e_mod_mixer_channel_has_no_volume(inst->channel_info))
{
inst->ui.left = _mixer_popup_add_slider(inst, 0, NULL);
e_widget_table_object_append(inst->ui.table, inst->ui.left,
0, 1, 1, 1, 1, 1, 1, 1);
e_slider_disabled_set(inst->ui.left, 1);
}
else
{
inst->ui.left = _mixer_popup_add_slider(inst, state->left,
_mixer_popup_cb_volume_left_change);
e_widget_table_object_append(inst->ui.table, inst->ui.left,
0, 1, 1, 1, 1, 1, 1, 1);
}
inst->ui.right = NULL;
}
else
{
inst->ui.left = _mixer_popup_add_slider(inst, state->left,
_mixer_popup_cb_volume_left_change);
inst->ui.left = _mixer_popup_add_slider(
inst, state->left, _mixer_popup_cb_volume_left_change);
e_widget_table_object_append(inst->ui.table, inst->ui.left,
0, 1, 1, 1, 1, 1, 1, 1);
inst->ui.right = _mixer_popup_add_slider(inst, state->right,
_mixer_popup_cb_volume_right_change);
e_widget_table_object_append(inst->ui.table, inst->ui.right,
1, 1, 1, 1, 1, 1, 1, 1);
}
else
inst->ui.left = NULL;
if (e_mod_mixer_channel_is_mutable(inst->channel_info))
if ((state->right >= 0) &&
(inst->conf->show_locked || (!inst->conf->lock_sliders)))
{
inst->ui.right = _mixer_popup_add_slider(
inst, state->right, _mixer_popup_cb_volume_right_change);
e_widget_table_object_append(inst->ui.table, inst->ui.right,
1, 1, 1, 1, 1, 1, 1, 1);
}
else
inst->ui.right = NULL;
if (e_mod_mixer_mutable_get(inst->sys, inst->channel))
{
inst->ui.mute = e_widget_check_add(evas, _("Mute"), &state->mute);
evas_object_show(inst->ui.mute);
@ -847,19 +857,19 @@ _mixer_sys_setup(E_Mixer_Instance *inst)
inst->sys = e_mod_mixer_new(conf->card);
if (!inst->sys)
{
inst->channel_info = NULL;
inst->channel = NULL;
return 0;
}
inst->channel_info = e_mod_mixer_channel_info_get_by_name(inst->sys, conf->channel_name);
return !!inst->channel_info->id;
inst->channel = e_mod_mixer_channel_get_by_name(inst->sys, conf->channel_name);
return !!inst->channel;
}
static int
_mixer_system_cb_update(void *data, E_Mixer_System *sys __UNUSED__)
{
E_Mixer_Instance *inst = data;
e_mod_mixer_state_get(inst->sys, inst->channel_info, &inst->mixer_state);
e_mod_mixer_state_get(inst->sys, inst->channel, &inst->mixer_state);
_mixer_gadget_update(inst);
return 1;
@ -876,7 +886,7 @@ e_mixer_update(E_Mixer_Instance *inst)
r = _mixer_sys_setup(inst);
if (r && _mixer_using_default)
e_mixer_alsa_callback_set(inst->sys, _mixer_system_cb_update, inst);
e_mixer_system_callback_set(inst->sys, _mixer_system_cb_update, inst);
return r;
}
@ -923,8 +933,8 @@ _mixer_sys_setup_default_channel(E_Mixer_Instance *inst)
if (!channel_name)
goto error;
inst->channel_info = e_mod_mixer_channel_info_get_by_name(inst->sys, channel_name);
if (!inst->channel_info)
inst->channel = e_mod_mixer_channel_get_by_name(inst->sys, channel_name);
if (!inst->channel)
goto system_error;
conf->channel_name = channel_name;
@ -947,27 +957,8 @@ _mixer_sys_setup_defaults(E_Mixer_Instance *inst)
return _mixer_sys_setup_default_channel(inst);
}
static void
_mixer_pulse_setup(void)
{
E_Mixer_Instance *inst;
E_Mixer_Module_Context *ctxt;
Eina_List *l;
e_mixer_pulse_setup();
if (!mixer_mod) return;
ctxt = mixer_mod->data;
EINA_LIST_FOREACH(ctxt->instances, l, inst)
{
if (!inst->conf->card)
_mixer_gadget_configuration_defaults(inst->conf);
}
}
void
e_sys_pulse_ready_cb(Eina_Bool ready)
e_mod_mixer_pulse_ready(Eina_Bool ready)
{
E_Mixer_Instance *inst;
E_Mixer_Module_Context *ctxt;
@ -983,13 +974,13 @@ e_sys_pulse_ready_cb(Eina_Bool ready)
{
EINA_LIST_FOREACH(ctxt->instances, l, inst)
{
e_mod_mixer_channel_info_free(inst->channel_info);
e_mod_mixer_channel_del(inst->channel);
e_mod_mixer_del(inst->sys);
inst->channel_info = NULL;
inst->channel = NULL;
inst->sys = NULL;
}
}
if (ready) _mixer_pulse_setup();
if (ready) e_mixer_pulse_setup();
else e_mixer_default_setup();
EINA_LIST_FOREACH(ctxt->instances, l, inst)
@ -1003,25 +994,20 @@ e_sys_pulse_ready_cb(Eina_Bool ready)
inst->sys = NULL;
return;
}
if (_mixer_using_default)
e_mixer_alsa_callback_set(inst->sys, _mixer_system_cb_update, inst);
if (_mixer_using_default) e_mixer_system_callback_set(inst->sys, _mixer_system_cb_update, inst);
else e_mixer_system_callback_set(inst->sys, NULL, NULL);
if ((inst->mixer_state.left > -1) && (inst->mixer_state.right > -1) && (inst->mixer_state.mute > -1))
e_mod_mixer_volume_set(inst->sys, inst->channel,
inst->mixer_state.left, inst->mixer_state.right);
else
e_mixer_alsa_callback_set(inst->sys, NULL, NULL);
if (inst->channel_info)
{
if ((inst->mixer_state.left > -1) && (inst->mixer_state.right > -1) && (inst->mixer_state.mute > -1))
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
inst->mixer_state.left, inst->mixer_state.right);
else
e_mod_mixer_state_get(inst->sys, inst->channel_info, &inst->mixer_state);
}
e_mod_mixer_state_get(inst->sys, inst->channel, &inst->mixer_state);
_mixer_gadget_update(inst);
}
called = EINA_TRUE;
}
void
e_sys_pulse_update_cb(void)
e_mod_mixer_pulse_update(void)
{
E_Mixer_Instance *inst;
E_Mixer_Module_Context *ctxt;
@ -1034,7 +1020,7 @@ e_sys_pulse_update_cb(void)
{
if (inst->conf->using_default)
_mixer_sys_setup_default_card(inst);
e_mod_mixer_state_get(inst->sys, inst->channel_info, &inst->mixer_state);
e_mod_mixer_state_get(inst->sys, inst->channel, &inst->mixer_state);
_mixer_gadget_update(inst);
}
}
@ -1087,7 +1073,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
return NULL;
}
if (_mixer_using_default) e_mixer_alsa_callback_set(inst->sys, _mixer_system_cb_update, inst);
if (_mixer_using_default) e_mixer_system_callback_set(inst->sys, _mixer_system_cb_update, inst);
inst->ui.gadget = edje_object_add(gc->evas);
e_theme_edje_object_set(inst->ui.gadget, "base/theme/modules/mixer",
@ -1105,10 +1091,10 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
if (_mixer_using_default &&
((inst->mixer_state.left > -1) && (inst->mixer_state.right > -1) && (inst->mixer_state.mute > -1)))
e_mod_mixer_volume_set(inst->sys, inst->channel_info,
e_mod_mixer_volume_set(inst->sys, inst->channel,
inst->mixer_state.left, inst->mixer_state.right);
else
e_mod_mixer_state_get(inst->sys, inst->channel_info, &inst->mixer_state);
e_mod_mixer_state_get(inst->sys, inst->channel, &inst->mixer_state);
_mixer_gadget_update(inst);
}
@ -1147,7 +1133,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
inst->conf->state.left = inst->mixer_state.left;
inst->conf->state.right = inst->mixer_state.right;
evas_object_del(inst->ui.gadget);
e_mod_mixer_channel_info_free(inst->channel_info);
e_mod_mixer_channel_del(inst->channel);
e_mod_mixer_del(inst->sys);
inst->conf->instance = NULL;
@ -1480,6 +1466,71 @@ _mixer_actions_unregister(E_Mixer_Module_Context *ctxt)
}
}
void
e_mixer_default_setup(void)
{
e_mod_mixer_volume_get = (void *)e_mixer_system_get_volume;
e_mod_mixer_volume_set = (void *)e_mixer_system_set_volume;
e_mod_mixer_mute_get = (void *)e_mixer_system_get_mute;
e_mod_mixer_mute_set = (void *)e_mixer_system_set_mute;
e_mod_mixer_mutable_get = (void *)e_mixer_system_can_mute;
e_mod_mixer_state_get = (void *)e_mixer_system_get_state;
e_mod_mixer_capture_get = (void *)e_mixer_system_has_capture;
e_mod_mixer_new = (void *)e_mixer_system_new;
e_mod_mixer_del = (void *)e_mixer_system_del;
e_mod_mixer_channel_default_name_get = (void *)e_mixer_system_get_default_channel_name;
e_mod_mixer_channel_get_by_name = (void *)e_mixer_system_get_channel_by_name;
e_mod_mixer_channel_name_get = (void *)e_mixer_system_get_channel_name;
e_mod_mixer_channel_del = (void *)e_mixer_system_channel_del;
e_mod_mixer_channels_free = (void *)e_mixer_system_free_channels;
e_mod_mixer_channels_get = (void *)e_mixer_system_get_channels;
e_mod_mixer_channels_names_get = (void *)e_mixer_system_get_channels_names;
e_mod_mixer_card_name_get = (void *)e_mixer_system_get_card_name;
e_mod_mixer_cards_get = (void *)e_mixer_system_get_cards;
e_mod_mixer_cards_free = (void *)e_mixer_system_free_cards;
e_mod_mixer_card_default_get = (void *)e_mixer_system_get_default_card;
_mixer_using_default = EINA_TRUE;
}
void
e_mixer_pulse_setup(void)
{
E_Mixer_Instance *inst;
E_Mixer_Module_Context *ctxt;
Eina_List *l;
e_mod_mixer_volume_get = (void *)e_mixer_pulse_get_volume;
e_mod_mixer_volume_set = (void *)e_mixer_pulse_set_volume;
e_mod_mixer_mute_get = (void *)e_mixer_pulse_get_mute;
e_mod_mixer_mute_set = (void *)e_mixer_pulse_set_mute;
e_mod_mixer_mutable_get = (void *)e_mixer_pulse_can_mute;
e_mod_mixer_state_get = (void *)e_mixer_pulse_get_state;
e_mod_mixer_capture_get = (void *)e_mixer_pulse_has_capture;
e_mod_mixer_new = (void *)e_mixer_pulse_new;
e_mod_mixer_del = (void *)e_mixer_pulse_del;
e_mod_mixer_channel_default_name_get = (void *)e_mixer_pulse_get_default_channel_name;
e_mod_mixer_channel_get_by_name = (void *)e_mixer_pulse_get_channel_by_name;
e_mod_mixer_channel_name_get = (void *)e_mixer_pulse_get_channel_name;
e_mod_mixer_channel_del = (void *)e_mixer_pulse_channel_del;
e_mod_mixer_channels_free = (void *)e_mixer_pulse_free_channels;
e_mod_mixer_channels_get = (void *)e_mixer_pulse_get_channels;
e_mod_mixer_channels_names_get = (void *)e_mixer_pulse_get_channels_names;
e_mod_mixer_card_name_get = (void *)e_mixer_pulse_get_card_name;
e_mod_mixer_cards_get = (void *)e_mixer_pulse_get_cards;
e_mod_mixer_cards_free = (void *)e_mixer_pulse_free_cards;
e_mod_mixer_card_default_get = (void *)e_mixer_pulse_get_default_card;
_mixer_using_default = EINA_FALSE;
if (!mixer_mod) return;
ctxt = mixer_mod->data;
EINA_LIST_FOREACH(ctxt->instances, l, inst)
{
if (!inst->conf->card)
_mixer_gadget_configuration_defaults(inst->conf);
}
}
EAPI void *
e_modapi_init(E_Module *m)
{
@ -1491,9 +1542,8 @@ e_modapi_init(E_Module *m)
_mixer_configure_registry_register();
e_gadcon_provider_register(&_gc_class);
if (!e_mixer_pulse_init((void*)e_sys_pulse_ready_cb,(void*)e_sys_pulse_update_cb))
e_mixer_default_setup();
else _mixer_pulse_setup();
if (!e_mixer_pulse_init()) e_mixer_default_setup();
else e_mixer_pulse_setup();
mixer_mod = m;
return ctxt;

View File

@ -2,7 +2,7 @@
#define E_MOD_MAIN_H
#include "e.h"
#include "e_mod_mixer.h"
#include "e_mod_system.h"
/* Increment for Major Changes */
#define MOD_CONFIG_FILE_EPOCH 1
@ -56,7 +56,7 @@ typedef struct E_Mixer_Instance
} ui;
E_Mixer_System *sys;
E_Mixer_Channel_Info *channel_info;
E_Mixer_Channel *channel;
E_Mixer_Channel_State mixer_state;
E_Mixer_Gadget_Config *conf;
@ -83,6 +83,14 @@ typedef struct E_Mixer_Module_Context
int desktop_notification;
} E_Mixer_Module_Context;
typedef int (*E_Mixer_Volume_Set_Cb)(E_Mixer_System *, E_Mixer_Channel *, int, int);
typedef int (*E_Mixer_Volume_Get_Cb)(E_Mixer_System *, E_Mixer_Channel *, int *, int *);
typedef int (*E_Mixer_Mute_Get_Cb)(E_Mixer_System *, E_Mixer_Channel *, int *);
typedef int (*E_Mixer_Mute_Set_Cb)(E_Mixer_System *, E_Mixer_Channel *, int);
typedef int (*E_Mixer_State_Get_Cb)(E_Mixer_System *, E_Mixer_Channel *, E_Mixer_Channel_State *);
typedef int (*E_Mixer_Capture_Cb)(E_Mixer_System *, E_Mixer_Channel *);
typedef void *(*E_Mixer_Cb)();
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init(E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
@ -94,9 +102,48 @@ E_Dialog *e_mixer_app_dialog_new(E_Container *con, void (*func)(E_Dialog *dialog
int e_mixer_app_dialog_select(E_Dialog *dialog, const char *card_name, const char *channel_name);
int e_mixer_update(E_Mixer_Instance *inst);
void e_mixer_default_setup(void);
void e_mixer_pulse_setup(void);
const char *e_mixer_theme_path(void);
void e_sys_pulse_ready_cb(Eina_Bool);
void e_sys_pulse_update_cb(void);
void e_mod_mixer_pulse_ready(Eina_Bool);
void e_mod_mixer_pulse_update(void);
extern Eina_Bool _mixer_using_default;
extern E_Mixer_Volume_Get_Cb e_mod_mixer_volume_get;
extern E_Mixer_Volume_Set_Cb e_mod_mixer_volume_set;
extern E_Mixer_Mute_Get_Cb e_mod_mixer_mute_get;
extern E_Mixer_Mute_Set_Cb e_mod_mixer_mute_set;
extern E_Mixer_Capture_Cb e_mod_mixer_mutable_get;
extern E_Mixer_State_Get_Cb e_mod_mixer_state_get;
extern E_Mixer_Capture_Cb e_mod_mixer_capture_get;
extern E_Mixer_Cb e_mod_mixer_new;
extern E_Mixer_Cb e_mod_mixer_del;
extern E_Mixer_Cb e_mod_mixer_channel_default_name_get;
extern E_Mixer_Cb e_mod_mixer_channel_get_by_name;
extern E_Mixer_Cb e_mod_mixer_channel_name_get;
extern E_Mixer_Cb e_mod_mixer_channel_del;
extern E_Mixer_Cb e_mod_mixer_channel_free;
extern E_Mixer_Cb e_mod_mixer_channels_free;
extern E_Mixer_Cb e_mod_mixer_channels_get;
extern E_Mixer_Cb e_mod_mixer_channels_names_get;
extern E_Mixer_Cb e_mod_mixer_card_name_get;
extern E_Mixer_Cb e_mod_mixer_cards_get;
extern E_Mixer_Cb e_mod_mixer_cards_free;
extern E_Mixer_Cb e_mod_mixer_card_default_get;
/**
* @addtogroup Optional_Devices
* @{
*
* @defgroup Module_Mixer Audio Mixer (Volume Control)
*
* Controls the audio volume and mute status for both playback
* (output) and record (input) devices.
*
* Can work with ALSA (http://www.alsa-project.org/) or PulseAudio
* (http://www.pulseaudio.org/).
*
* @}
*/
#endif

View File

@ -1,115 +0,0 @@
#include "e_mod_mixer.h"
Eina_Bool _mixer_using_default = EINA_FALSE;
E_Mixer_Volume_Get_Cb e_mod_mixer_volume_get;
E_Mixer_Volume_Set_Cb e_mod_mixer_volume_set;
E_Mixer_Mute_Get_Cb e_mod_mixer_mute_get;
E_Mixer_Mute_Set_Cb e_mod_mixer_mute_set;
E_Mixer_State_Get_Cb e_mod_mixer_state_get;
E_Mixer_Cb e_mod_mixer_new;
E_Mixer_Cb e_mod_mixer_del;
E_Mixer_Cb e_mod_mixer_channel_default_name_get;
E_Mixer_Cb e_mod_mixer_channel_info_get_by_name;
E_Mixer_Cb e_mod_mixer_channels_get;
E_Mixer_Cb e_mod_mixer_channel_names_get;
E_Mixer_Cb e_mod_mixer_card_name_get;
E_Mixer_Cb e_mod_mixer_card_names_get;
E_Mixer_Cb e_mod_mixer_card_default_get;
void
e_mixer_default_setup(void)
{
e_mod_mixer_volume_get = (void *)e_mixer_alsa_get_volume;
e_mod_mixer_volume_set = (void *)e_mixer_alsa_set_volume;
e_mod_mixer_mute_get = (void *)e_mixer_alsa_get_mute;
e_mod_mixer_mute_set = (void *)e_mixer_alsa_set_mute;
e_mod_mixer_state_get = (void *)e_mixer_alsa_get_state;
e_mod_mixer_new = (void *)e_mixer_alsa_new;
e_mod_mixer_del = (void *)e_mixer_alsa_del;
e_mod_mixer_channel_default_name_get = (void *)e_mixer_alsa_get_default_channel_name;
e_mod_mixer_channel_info_get_by_name = (void *)e_mixer_alsa_get_channel_by_name;
e_mod_mixer_channels_get = (void *)e_mixer_alsa_get_channels;
e_mod_mixer_channel_names_get = (void *)e_mixer_alsa_get_channel_names;
e_mod_mixer_card_name_get = (void *)e_mixer_alsa_get_card_name;
e_mod_mixer_card_names_get = (void *)e_mixer_alsa_get_cards;
e_mod_mixer_card_default_get = (void *)e_mixer_alsa_get_default_card;
_mixer_using_default = EINA_TRUE;
}
void
e_mixer_pulse_setup()
{
e_mod_mixer_volume_get = (void *)e_mixer_pulse_get_volume;
e_mod_mixer_volume_set = (void *)e_mixer_pulse_set_volume;
e_mod_mixer_mute_get = (void *)e_mixer_pulse_get_mute;
e_mod_mixer_mute_set = (void *)e_mixer_pulse_set_mute;
e_mod_mixer_state_get = (void *)e_mixer_pulse_get_state;
e_mod_mixer_new = (void *)e_mixer_pulse_new;
e_mod_mixer_del = (void *)e_mixer_pulse_del;
e_mod_mixer_channel_default_name_get = (void *)e_mixer_pulse_get_default_channel_name;
e_mod_mixer_channel_info_get_by_name = (void *)e_mixer_pulse_get_channel_by_name;
e_mod_mixer_channels_get = (void *)e_mixer_pulse_get_channels;
e_mod_mixer_channel_names_get = (void *)e_mixer_pulse_get_channel_names;
e_mod_mixer_card_name_get = (void *)e_mixer_pulse_get_card_name;
e_mod_mixer_card_names_get = (void *)e_mixer_pulse_get_cards;
e_mod_mixer_card_default_get = (void *)e_mixer_pulse_get_default_card;
_mixer_using_default = EINA_FALSE;
}
static int
_channel_info_cmp(const void *data_a, const void *data_b)
{
const E_Mixer_Channel_Info *a = data_a, *b = data_b;
if (e_mod_mixer_channel_group_get(a) == e_mod_mixer_channel_group_get(b))
return strcmp(a->name, b->name);
if (e_mod_mixer_channel_is_boost(a))
return 1;
if (e_mod_mixer_channel_is_boost(b))
return -1;
if (e_mod_mixer_channel_group_get(a) < e_mod_mixer_channel_group_get(b))
return 1;
return -1;
}
void e_mod_mixer_channel_info_free(E_Mixer_Channel_Info* info)
{
if (!info) return;
eina_stringshare_del(info->name);
free(info);
}
Eina_List *
e_mod_mixer_channel_infos_get(E_Mixer_System *sys)
{
return eina_list_sort(e_mod_mixer_channels_get(sys), -1, _channel_info_cmp);
}
void
e_mod_mixer_channel_infos_free(Eina_List *list)
{
E_Mixer_Channel_Info *info;
EINA_LIST_FREE(list, info)
{
eina_stringshare_del(info->name);
free(info);
}
}
void
e_mod_mixer_channel_names_free(Eina_List *list)
{
const char *str;
EINA_LIST_FREE(list, str)
eina_stringshare_del(str);
}
void
e_mod_mixer_card_names_free(Eina_List *list)
{
const char *str;
EINA_LIST_FREE(list, str)
eina_stringshare_del(str);
}

View File

@ -1,143 +0,0 @@
#ifndef E_MOD_MIXER_H
#define E_MOD_MIXER_H
#include "e.h"
typedef void E_Mixer_App;
typedef void E_Mixer_System;
typedef void E_Mixer_Channel;
typedef struct _E_Mixer_Channel_State
{
int mute;
int left;
int right;
} E_Mixer_Channel_State;
#define E_MIXER_CHANNEL_CAN_MUTE 0x01
#define E_MIXER_CHANNEL_IS_MONO 0x02
#define E_MIXER_CHANNEL_HAS_CAPTURE 0x04
#define E_MIXER_CHANNEL_HAS_PLAYBACK 0x08
#define E_MIXER_CHANNEL_GROUP_MASK 0xFC
#define E_MIXER_CHANNEL_USABLE_MASK 0xFD
#define e_mod_mixer_channel_is_mutable(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_CAN_MUTE )!=0 )
#define e_mod_mixer_channel_is_mono(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_IS_MONO )!=0 )
#define e_mod_mixer_channel_has_capture(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_HAS_CAPTURE )!=0 )
#define e_mod_mixer_channel_has_playback(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_HAS_PLAYBACK )!=0 )
#define e_mod_mixer_channel_is_boost(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_HAS_PLAYBACK )!=0 && \
((_ch)->capabilities & E_MIXER_CHANNEL_HAS_CAPTURE )!=0 )
#define e_mod_mixer_channel_has_no_volume(_ch) \
( ((_ch)->capabilities & E_MIXER_CHANNEL_HAS_PLAYBACK )==0 && \
((_ch)->capabilities & E_MIXER_CHANNEL_HAS_CAPTURE )==0 )
#define e_mod_mixer_channel_group_get(_ch) \
( (_ch)->capabilities & E_MIXER_CHANNEL_GROUP_MASK )
#define e_mod_mixer_capabilities_usable(_capa) \
( ((_capa) & E_MIXER_CHANNEL_USABLE_MASK)!=0 )
typedef struct _E_Mixer_Channel_Info
{
int capabilities;
const char *name;
E_Mixer_Channel *id;
E_Mixer_App *app;
} E_Mixer_Channel_Info;
typedef int (*E_Mixer_Volume_Set_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *, int, int);
typedef int (*E_Mixer_Volume_Get_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *, int *, int *);
typedef int (*E_Mixer_Mute_Get_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *, int *);
typedef int (*E_Mixer_Mute_Set_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *, int);
typedef int (*E_Mixer_State_Get_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *, E_Mixer_Channel_State *);
typedef void *(*E_Mixer_Cb)();
typedef void *(*E_Mixer_Ready_Cb)(Eina_Bool);
extern Eina_Bool _mixer_using_default;
extern E_Mixer_Volume_Get_Cb e_mod_mixer_volume_get;
extern E_Mixer_Volume_Set_Cb e_mod_mixer_volume_set;
extern E_Mixer_Mute_Get_Cb e_mod_mixer_mute_get;
extern E_Mixer_Mute_Set_Cb e_mod_mixer_mute_set;
extern E_Mixer_State_Get_Cb e_mod_mixer_state_get;
extern E_Mixer_Cb e_mod_mixer_new;
extern E_Mixer_Cb e_mod_mixer_del;
extern E_Mixer_Cb e_mod_mixer_channel_default_name_get;
extern E_Mixer_Cb e_mod_mixer_channel_info_get_by_name;
extern E_Mixer_Cb e_mod_mixer_channel_names_get;
extern E_Mixer_Cb e_mod_mixer_card_name_get;
extern E_Mixer_Cb e_mod_mixer_card_names_get;
extern E_Mixer_Cb e_mod_mixer_card_default_get;
void e_mod_mixer_channel_info_free(E_Mixer_Channel_Info*);
Eina_List *e_mod_mixer_channel_infos_get(E_Mixer_System *sys);
void e_mod_mixer_channel_infos_free(Eina_List*);
void e_mod_mixer_channel_names_free(Eina_List*);
void e_mod_mixer_card_names_free(Eina_List*);
void e_mixer_default_setup(void);
void e_mixer_pulse_setup();
/* ALSA */
int e_mixer_alsa_callback_set(E_Mixer_System *self, int (*func)(void *data, E_Mixer_System *self), void *data);
E_Mixer_System *e_mixer_alsa_new(const char *card);
void e_mixer_alsa_del(E_Mixer_System *self);
Eina_List *e_mixer_alsa_get_cards(void);
const char *e_mixer_alsa_get_default_card(void);
const char *e_mixer_alsa_get_card_name(const char *card);
Eina_List *e_mixer_alsa_get_channels(E_Mixer_System *self);
Eina_List *e_mixer_alsa_get_channel_names(E_Mixer_System *self);
const char *e_mixer_alsa_get_default_channel_name(E_Mixer_System *self);
E_Mixer_Channel_Info *e_mixer_alsa_get_channel_by_name(E_Mixer_System *self, const char *name);
int e_mixer_alsa_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *left, int *right);
int e_mixer_alsa_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int left, int right);
int e_mixer_alsa_get_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *mute);
int e_mixer_alsa_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int mute);
int e_mixer_alsa_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_Mixer_Channel_State *state);
/* PULSE */
Eina_Bool e_mixer_pulse_ready(void);
Eina_Bool e_mixer_pulse_init(E_Mixer_Ready_Cb e_sys_pulse_ready_cb, E_Mixer_Cb e_sys_pulse_update_cb);
void e_mixer_pulse_shutdown(void);
E_Mixer_System *e_mixer_pulse_new(const char *name);
void e_mixer_pulse_del(E_Mixer_System *self);
Eina_List *e_mixer_pulse_get_cards(void);
const char *e_mixer_pulse_get_default_card(void);
const char *e_mixer_pulse_get_card_name(const char *card);
Eina_List *e_mixer_pulse_get_channels(E_Mixer_System *self);
Eina_List *e_mixer_pulse_get_channel_names(E_Mixer_System *self);
const char *e_mixer_pulse_get_default_channel_name(E_Mixer_System *self);
E_Mixer_Channel_Info *e_mixer_pulse_get_channel_by_name(E_Mixer_System *self, const char *name);
int e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *left, int *right);
int e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int left, int right);
int e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *mute);
int e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int mute);
int e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_Mixer_Channel_State *state);
/**
* @addtogroup Optional_Devices
* @{
*
* @defgroup Module_Mixer Audio Mixer (Volume Control)
*
* Controls the audio volume and mute status for both playback
* (output) and record (input) devices.
*
* Can work with ALSA (http://www.alsa-project.org/) or PulseAudio
* (http://www.pulseaudio.org/).
*
* @}
*/
#endif /* E_MOD_SYSTEM_H */

View File

@ -0,0 +1,75 @@
#ifndef E_MOD_SYSTEM_H
#define E_MOD_SYSTEM_H
#include "e.h"
typedef void E_Mixer_System;
typedef void E_Mixer_Channel;
struct E_Mixer_Channel_State
{
int mute;
int left;
int right;
};
typedef struct E_Mixer_Channel_State E_Mixer_Channel_State;
Eina_List *e_mixer_system_get_cards(void);
void e_mixer_system_free_cards(Eina_List *cards);
const char *e_mixer_system_get_default_card(void);
const char *e_mixer_system_get_card_name(const char *card);
Eina_Bool e_mixer_pulse_init(void);
E_Mixer_System *e_mixer_system_new(const char *card);
void e_mixer_system_del(E_Mixer_System *self);
int e_mixer_system_callback_set(E_Mixer_System *self, int (*func)(void *data, E_Mixer_System *self), void *data);
Eina_List *e_mixer_system_get_channels(E_Mixer_System *self);
void e_mixer_system_free_channels(Eina_List *channels);
Eina_List *e_mixer_system_get_channels_names(E_Mixer_System *self);
void e_mixer_system_free_channels_names(Eina_List *channels_names);
const char *e_mixer_system_get_default_channel_name(E_Mixer_System *self);
E_Mixer_Channel *e_mixer_system_get_channel_by_name(E_Mixer_System *self, const char *name);
const char *e_mixer_system_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel);
void e_mixer_system_channel_del(E_Mixer_Channel *channel);
int e_mixer_system_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_Channel_State *state);
int e_mixer_system_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_Mixer_Channel_State *state);
int e_mixer_system_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *left, int *right);
int e_mixer_system_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int left, int right);
int e_mixer_system_get_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int *mute);
int e_mixer_system_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int mute);
int e_mixer_system_can_mute(E_Mixer_System *self, E_Mixer_Channel *channel);
int e_mixer_system_has_capture(E_Mixer_System *self, E_Mixer_Channel *channel);
int pulse_init(void);
Eina_Bool e_mixer_pulse_ready(void);
Eina_Bool e_mixer_pulse_init(void);
void e_mixer_pulse_shutdown(void);
E_Mixer_System *e_mixer_pulse_new(const char *name);
void e_mixer_pulse_del(E_Mixer_System *self);
Eina_List *e_mixer_pulse_get_cards(void);
void e_mixer_pulse_free_cards(Eina_List *cards);
const char *e_mixer_pulse_get_default_card(void);
const char *e_mixer_pulse_get_card_name(const char *card);
Eina_List *e_mixer_pulse_get_channels(E_Mixer_System *self);
void e_mixer_pulse_free_channels(Eina_List *channels);
Eina_List *e_mixer_pulse_get_channels_names(E_Mixer_System *self);
void e_mixer_pulse_free_channels_names(Eina_List *channels_names);
const char *e_mixer_pulse_get_default_channel_name(E_Mixer_System *self);
E_Mixer_Channel *e_mixer_pulse_get_channel_by_name(E_Mixer_System *self, const char *name);
void e_mixer_pulse_channel_del(E_Mixer_Channel *channel);
const char *e_mixer_pulse_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel);
int e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *left, int *right);
int e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int left, int right);
int e_mixer_pulse_can_mute(E_Mixer_System *self, E_Mixer_Channel *channel);
int e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int *mute);
int e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel, int mute);
int e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_Channel_State *state);
int e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_Mixer_Channel_State *state);
int e_mixer_pulse_has_capture(E_Mixer_System *self, E_Mixer_Channel *channel);
#endif /* E_MOD_SYSTEM_H */

View File

@ -1,4 +1,4 @@
#include "e_mod_mixer.h"
#include "e_mod_system.h"
#include <alsa/asoundlib.h>
#include <poll.h>
@ -143,7 +143,7 @@ _mixer_callback_replace(E_Mixer_System *self __UNUSED__,
}
E_Mixer_System *
e_mixer_alsa_new(const char *name)
e_mixer_system_new(const char *name)
{
snd_mixer_t *handle;
int err;
@ -177,7 +177,7 @@ error_open:
}
void
e_mixer_alsa_del(E_Mixer_System *self)
e_mixer_system_del(E_Mixer_System *self)
{
struct e_mixer_callback_desc *desc;
@ -192,7 +192,7 @@ e_mixer_alsa_del(E_Mixer_System *self)
}
int
e_mixer_alsa_callback_set(E_Mixer_System *self,
e_mixer_system_callback_set(E_Mixer_System *self,
int (*func)(void *data, E_Mixer_System *self),
void *data)
{
@ -218,7 +218,7 @@ e_mixer_alsa_callback_set(E_Mixer_System *self,
}
Eina_List *
e_mixer_alsa_get_cards(void)
e_mixer_system_get_cards(void)
{
int err, card_num;
Eina_List *cards;
@ -245,8 +245,17 @@ e_mixer_alsa_get_cards(void)
return cards;
}
void
e_mixer_system_free_cards(Eina_List *cards)
{
const char *card;
EINA_LIST_FREE(cards, card)
eina_stringshare_del(card);
}
const char *
e_mixer_alsa_get_default_card(void)
e_mixer_system_get_default_card(void)
{
static const char buf[] = "hw:0";
snd_ctl_t *control;
@ -258,7 +267,7 @@ e_mixer_alsa_get_default_card(void)
}
const char *
e_mixer_alsa_get_card_name(const char *card)
e_mixer_system_get_card_name(const char *card)
{
snd_ctl_card_info_t *hw_info;
const char *name;
@ -294,55 +303,11 @@ e_mixer_alsa_get_card_name(const char *card)
return eina_stringshare_add(name);
}
static int
_mixer_channel_has_capabilities(snd_mixer_elem_t *elem)
{
if (!snd_mixer_selem_is_active(elem)) return 0;
if (snd_mixer_selem_has_playback_volume(elem)) return 1;
if (snd_mixer_selem_has_capture_volume(elem)) return 1;
if (snd_mixer_selem_has_playback_switch(elem)) return 1;
if (snd_mixer_selem_has_capture_switch(elem)) return 1;
return 0;
}
static int
_mixer_channel_capabilities(snd_mixer_elem_t *elem)
{
int capabilities = 0;
/*
* never vol_joined if not mono
* -> mono is enough
* never switch_joined if not switch
* -> switch is enough
* never common_vol if not (playback_vol && capture vol)
* -> palyback_vol & capture_vol is enough
*/
if (!snd_mixer_selem_is_active(elem))
return 0;
if (snd_mixer_selem_has_capture_volume(elem))
capabilities |= E_MIXER_CHANNEL_HAS_CAPTURE;
if (snd_mixer_selem_has_playback_volume(elem))
capabilities |= E_MIXER_CHANNEL_HAS_PLAYBACK;
if (snd_mixer_selem_has_playback_switch(elem) ||
snd_mixer_selem_has_capture_switch(elem))
capabilities |= E_MIXER_CHANNEL_CAN_MUTE;
if (snd_mixer_selem_is_playback_mono(elem)==1 ||
snd_mixer_selem_is_capture_mono(elem)==1)
capabilities |= E_MIXER_CHANNEL_IS_MONO;
return capabilities;
}
Eina_List *
e_mixer_alsa_get_channels(E_Mixer_System *self)
e_mixer_system_get_channels(E_Mixer_System *self)
{
int capabilities;
Eina_List *channels;
snd_mixer_elem_t *elem;
E_Mixer_Channel_Info *ch_info;
if (!self)
return NULL;
@ -352,23 +317,24 @@ e_mixer_alsa_get_channels(E_Mixer_System *self)
elem = snd_mixer_first_elem(self);
for (; elem; elem = snd_mixer_elem_next(elem))
{
capabilities = _mixer_channel_capabilities(elem);
if (!e_mod_mixer_capabilities_usable(capabilities))
if ((!snd_mixer_selem_is_active(elem)) ||
(!snd_mixer_selem_has_playback_volume(elem)))
continue;
ch_info = malloc(sizeof(*ch_info));
ch_info->id = elem;
ch_info->name = eina_stringshare_add(snd_mixer_selem_get_name(elem));
ch_info->capabilities = capabilities;
channels = eina_list_append(channels, ch_info);
channels = eina_list_append(channels, elem);
}
return channels;
}
void
e_mixer_system_free_channels(Eina_List *channels)
{
eina_list_free(channels);
}
Eina_List *
e_mixer_alsa_get_channel_names(E_Mixer_System *self)
e_mixer_system_get_channels_names(E_Mixer_System *self)
{
Eina_List *channels;
snd_mixer_elem_t *elem;
@ -384,7 +350,8 @@ e_mixer_alsa_get_channel_names(E_Mixer_System *self)
for (; elem; elem = snd_mixer_elem_next(elem))
{
const char *name;
if (!_mixer_channel_has_capabilities(elem))
if ((!snd_mixer_selem_is_active(elem)) ||
(!snd_mixer_selem_has_playback_volume(elem)))
continue;
snd_mixer_selem_get_id(elem, sid);
@ -396,8 +363,17 @@ e_mixer_alsa_get_channel_names(E_Mixer_System *self)
return channels;
}
void
e_mixer_system_free_channels_names(Eina_List *channels_names)
{
const char *channel;
EINA_LIST_FREE(channels_names, channel)
eina_stringshare_del(channel);
}
const char *
e_mixer_alsa_get_default_channel_name(E_Mixer_System *self)
e_mixer_system_get_default_channel_name(E_Mixer_System *self)
{
snd_mixer_elem_t *elem;
snd_mixer_selem_id_t *sid;
@ -411,7 +387,8 @@ e_mixer_alsa_get_default_channel_name(E_Mixer_System *self)
for (; elem; elem = snd_mixer_elem_next(elem))
{
const char *name;
if (!_mixer_channel_has_capabilities(elem))
if ((!snd_mixer_selem_is_active(elem)) ||
(!snd_mixer_selem_has_playback_volume(elem)))
continue;
snd_mixer_selem_get_id(elem, sid);
@ -423,14 +400,12 @@ e_mixer_alsa_get_default_channel_name(E_Mixer_System *self)
return NULL;
}
E_Mixer_Channel_Info *
e_mixer_alsa_get_channel_by_name(E_Mixer_System *self,
E_Mixer_Channel *
e_mixer_system_get_channel_by_name(E_Mixer_System *self,
const char *name)
{
int capabilities;
snd_mixer_elem_t *elem;
snd_mixer_selem_id_t *sid;
E_Mixer_Channel_Info *ch_info;
if ((!self) || (!name))
return NULL;
@ -441,46 +416,44 @@ e_mixer_alsa_get_channel_by_name(E_Mixer_System *self,
for (; elem; elem = snd_mixer_elem_next(elem))
{
const char *n;
capabilities = _mixer_channel_capabilities(elem);
if (!e_mod_mixer_capabilities_usable(capabilities))
if ((!snd_mixer_selem_is_active(elem)) ||
(!snd_mixer_selem_has_playback_volume(elem)))
continue;
snd_mixer_selem_get_id(elem, sid);
n = snd_mixer_selem_id_get_name(sid);
if (n && (strcmp(n, name) == 0))
{
ch_info = malloc(sizeof(*ch_info));
ch_info->id = elem;
ch_info->name = eina_stringshare_add(n);
ch_info->capabilities = capabilities;
return ch_info;
}
return elem;
}
return NULL;
}
/* const char * */
/* e_mixer_alsa_get_channel_name(E_Mixer_System *self, */
/* E_Mixer_Channel_Info *channel) */
/* { */
/* snd_mixer_selem_id_t *sid; */
/* const char *name; */
/**/
/* if ((!self) || (!channel)) */
/* return NULL; */
/**/
/* snd_mixer_selem_id_alloca(&sid); */
/* snd_mixer_selem_get_id(channel->id, sid); */
/* name = eina_stringshare_add(snd_mixer_selem_id_get_name(sid)); */
/**/
/* return name; */
/* } */
void
e_mixer_system_channel_del(E_Mixer_Channel *channel __UNUSED__)
{
}
const char *
e_mixer_system_get_channel_name(E_Mixer_System *self,
E_Mixer_Channel *channel)
{
snd_mixer_selem_id_t *sid;
const char *name;
if ((!self) || (!channel))
return NULL;
snd_mixer_selem_id_alloca(&sid);
snd_mixer_selem_get_id(channel, sid);
name = eina_stringshare_add(snd_mixer_selem_id_get_name(sid));
return name;
}
int
e_mixer_alsa_get_volume(E_Mixer_System *self,
E_Mixer_Channel_Info *channel,
e_mixer_system_get_volume(E_Mixer_System *self,
E_Mixer_Channel *channel,
int *left,
int *right)
{
@ -490,34 +463,24 @@ e_mixer_alsa_get_volume(E_Mixer_System *self,
return 0;
snd_mixer_handle_events(self);
if (e_mod_mixer_channel_has_playback(channel))
snd_mixer_selem_get_playback_volume_range(channel->id, &min, &max);
else if (e_mod_mixer_channel_has_capture(channel))
snd_mixer_selem_get_capture_volume_range(channel->id, &min, &max);
else
return 0;
snd_mixer_selem_get_playback_volume_range(channel, &min, &max);
range = max - min;
if (range < 1)
return 0;
if (e_mod_mixer_channel_has_playback(channel))
{
snd_mixer_selem_get_playback_volume(channel->id, 0, &lvol);
if (!e_mod_mixer_channel_is_mono(channel))
snd_mixer_selem_get_playback_volume(channel->id, 1, &rvol);
else
rvol = lvol;
}
if (snd_mixer_selem_has_playback_channel(channel, 0))
snd_mixer_selem_get_playback_volume(channel, 0, &lvol);
else
{
snd_mixer_selem_get_capture_volume(channel->id, 0, &lvol);
if (!e_mod_mixer_channel_is_mono(channel))
snd_mixer_selem_get_capture_volume(channel->id, 1, &rvol);
else
rvol = lvol;
}
lvol = min;
if (snd_mixer_selem_has_playback_channel(channel, 1))
snd_mixer_selem_get_playback_volume(channel, 1, &rvol);
else
rvol = min;
if (snd_mixer_selem_is_playback_mono(channel) ||
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);
@ -526,8 +489,8 @@ e_mixer_alsa_get_volume(E_Mixer_System *self,
}
int
e_mixer_alsa_set_volume(E_Mixer_System *self,
E_Mixer_Channel_Info *channel,
e_mixer_system_set_volume(E_Mixer_System *self,
E_Mixer_Channel *channel,
int left,
int right)
{
@ -538,14 +501,7 @@ e_mixer_alsa_set_volume(E_Mixer_System *self,
return 0;
snd_mixer_handle_events(self);
if (e_mod_mixer_channel_has_playback(channel))
snd_mixer_selem_get_playback_volume_range(channel->id, &min, &max);
else if (e_mod_mixer_channel_has_capture(channel))
snd_mixer_selem_get_capture_volume_range(channel->id, &min, &max);
else
return 0;
snd_mixer_selem_get_playback_volume_range(channel, &min, &max);
divide = 100 + min;
if (divide == 0)
{
@ -564,52 +520,56 @@ e_mixer_alsa_set_volume(E_Mixer_System *self,
mode |= 1;
}
if (!e_mod_mixer_channel_is_mono(channel) && (right >= 0))
if (right >= 0)
{
right = (((range * right) + (range / 2)) / divide) - min;
mode |= 2;
}
if (mode & 1)
{
if (e_mod_mixer_channel_has_playback(channel))
snd_mixer_selem_set_playback_volume(channel->id, 0, left);
else
snd_mixer_selem_set_capture_volume(channel->id, 0, left);
}
snd_mixer_selem_set_playback_volume(channel, 0, left);
if (mode & 2)
if ((!snd_mixer_selem_is_playback_mono(channel)) &&
(!snd_mixer_selem_has_playback_volume_joined(channel)) &&
(mode & 2))
{
if (e_mod_mixer_channel_has_playback(channel))
snd_mixer_selem_set_playback_volume(channel->id, 1, right);
else
snd_mixer_selem_set_capture_volume(channel->id, 1, right);
if (snd_mixer_selem_has_playback_channel(channel, 1))
snd_mixer_selem_set_playback_volume(channel, 1, right);
}
return 1;
}
int
e_mixer_alsa_get_mute(E_Mixer_System *self,
E_Mixer_Channel_Info *channel,
e_mixer_system_can_mute(E_Mixer_System *self,
E_Mixer_Channel *channel)
{
if ((!self) || (!channel))
return 0;
snd_mixer_handle_events(self);
return snd_mixer_selem_has_playback_switch(channel) ||
snd_mixer_selem_has_playback_switch_joined(channel);
}
int
e_mixer_system_get_mute(E_Mixer_System *self,
E_Mixer_Channel *channel,
int *mute)
{
if ((!self) || (!channel) || (!mute))
return 0;
snd_mixer_handle_events(self);
if (e_mod_mixer_channel_is_mutable(channel))
if (snd_mixer_selem_has_playback_switch(channel) ||
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?
*/
if (e_mod_mixer_channel_has_capture(channel))
snd_mixer_selem_get_capture_switch(channel->id, 0, &m);
else
snd_mixer_selem_get_playback_switch(channel->id, 0, &m);
snd_mixer_selem_get_playback_switch(channel, 0, &m);
*mute = !m;
}
else
@ -619,27 +579,24 @@ e_mixer_alsa_get_mute(E_Mixer_System *self,
}
int
e_mixer_alsa_set_mute(E_Mixer_System *self,
E_Mixer_Channel_Info *channel,
e_mixer_system_set_mute(E_Mixer_System *self,
E_Mixer_Channel *channel,
int mute)
{
if ((!self) || (!channel))
return 0;
if (e_mod_mixer_channel_is_mutable(channel))
{
if (e_mod_mixer_channel_has_capture(channel))
return snd_mixer_selem_set_capture_switch_all(channel->id, !mute);
else
return snd_mixer_selem_set_playback_switch_all(channel->id, !mute);
}
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);
else
return 0;
}
int
e_mixer_alsa_get_state(E_Mixer_System *self,
E_Mixer_Channel_Info *channel,
e_mixer_system_get_state(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_State *state)
{
int r;
@ -647,23 +604,33 @@ e_mixer_alsa_get_state(E_Mixer_System *self,
if (!state)
return 0;
r = e_mixer_alsa_get_mute(self, channel, &state->mute);
r &= e_mixer_alsa_get_volume(self, channel, &state->left, &state->right);
r = e_mixer_system_get_mute(self, channel, &state->mute);
r &= e_mixer_system_get_volume(self, channel, &state->left, &state->right);
return r;
}
/* int */
/* e_mixer_alsa_set_state(E_Mixer_System *self, */
/* E_Mixer_Channel *channel, */
/* const E_Mixer_Channel_State *state) */
/* { */
/* int r; */
/**/
/* if (!state) */
/* return 0; */
/**/
/* r = e_mixer_alsa_set_mute(self, channel, state->mute); */
/* r &= e_mixer_alsa_set_volume(self, channel, state->left, state->right); */
/* return r; */
/* } */
int
e_mixer_system_set_state(E_Mixer_System *self,
E_Mixer_Channel *channel,
const E_Mixer_Channel_State *state)
{
int r;
if (!state)
return 0;
r = e_mixer_system_set_mute(self, channel, state->mute);
r &= e_mixer_system_set_volume(self, channel, state->left, state->right);
return r;
}
int
e_mixer_system_has_capture(E_Mixer_System *self,
E_Mixer_Channel *channel)
{
if ((!self) || (!channel))
return 0;
return snd_mixer_selem_has_capture_switch(channel) || snd_mixer_selem_has_capture_volume(channel);
}

View File

@ -1,4 +1,4 @@
#include "e_mod_mixer.h"
#include "e_mod_system.h"
static const char *_name = NULL;
@ -12,7 +12,6 @@ E_Mixer_System *
e_mixer_system_new(const char *name)
{
_e_mixer_dummy_set();
if (!name) return NULL;
if (name == _name || strcmp(name, _name) == 0)
@ -37,7 +36,13 @@ e_mixer_system_get_cards(void)
{
_e_mixer_dummy_set();
return eina_list_append(NULL, eina_stringshare_ref(_name));
return eina_list_append(NULL, _name);
}
void
e_mixer_system_free_cards(Eina_List *cards)
{
eina_list_free(cards);
}
const char *
@ -62,16 +67,13 @@ e_mixer_system_get_card_name(const char *card)
Eina_List *
e_mixer_system_get_channels(E_Mixer_System *self __UNUSED__)
{
E_Mixer_Channel_Info *ch_info;
return eina_list_append(NULL, (void *)-2);
}
_e_mixer_dummy_set();
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)-2;
ch_info->name = eina_stringshare_ref(_name);
ch_info->capabilities = E_MIXER_CHANNEL_CAN_MUTE|E_MIXER_CHANNEL_HAS_PLAYBACK;
return eina_list_append(NULL, ch_info);
void
e_mixer_system_free_channels(Eina_List *channels)
{
eina_list_free(channels);
}
Eina_List *
@ -79,7 +81,13 @@ e_mixer_system_get_channels_names(E_Mixer_System *self __UNUSED__)
{
_e_mixer_dummy_set();
return eina_list_append(NULL, eina_stringshare_ref(_name));
return eina_list_append(NULL, _name);
}
void
e_mixer_system_free_channels_names(Eina_List *channels_names)
{
eina_list_free(channels_names);
}
const char *
@ -90,36 +98,30 @@ e_mixer_system_get_default_channel_name(E_Mixer_System *self __UNUSED__)
return eina_stringshare_ref(_name);
}
E_Mixer_Channel_Info *
E_Mixer_Channel *
e_mixer_system_get_channel_by_name(E_Mixer_System *self __UNUSED__, const char *name)
{
E_Mixer_Channel_Info *ch_info;
_e_mixer_dummy_set();
if (name == _name || strcmp(name, _name) == 0)
{
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)-2;
ch_info->name = eina_stringshare_ref(_name);
ch_info->capabilities = E_MIXER_CHANNEL_CAN_MUTE|E_MIXER_CHANNEL_HAS_PLAYBACK;
return ch_info;
}
return (E_Mixer_Channel *)-2;
else
return NULL;
}
/* const char * */
/* e_mixer_system_get_channel_name(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel) */
/* { */
/* _e_mixer_dummy_set(); */
/**/
/* if (channel == (E_Mixer_Channel *)-2) */
/* return eina_stringshare_ref(_name); */
/* else */
/* return NULL; */
/* } */
void
e_mixer_system_channel_del(E_Mixer_Channel *channel __UNUSED__)
{
}
const char *
e_mixer_system_get_channel_name(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel)
{
if (channel == (E_Mixer_Channel *)-2)
return eina_stringshare_ref(_name);
else
return NULL;
}
int
e_mixer_system_get_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, int *left, int *right)
@ -138,6 +140,12 @@ e_mixer_system_set_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *chan
return 0;
}
int
e_mixer_system_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
{
return 1;
}
int
e_mixer_system_get_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, int *mute)
{
@ -164,9 +172,15 @@ e_mixer_system_get_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *chann
return 1;
}
/* int */
/* e_mixer_system_set_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, const E_Mixer_Channel_State *state __UNUSED__) */
/* { */
/* return 0; */
/* } */
int
e_mixer_system_set_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, const E_Mixer_Channel_State *state __UNUSED__)
{
return 0;
}
int
e_mixer_system_has_capture(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
{
return 0;
}

View File

@ -1,4 +1,4 @@
#include "e_mod_mixer.h"
#include "e_mod_main.h"
#include "Pulse.h"
#define PULSE_BUS "org.PulseAudio.Core1"
@ -15,7 +15,6 @@ static Eina_List *sinks = NULL;
static Eina_List *sources = NULL;
static Ecore_Poller *pulse_poller = NULL;
static Eina_Hash *queue_states = NULL;
static const char *_name = NULL;
static EDBus_Connection *dbus = NULL;
static EDBus_Signal_Handler *dbus_handler = NULL;
@ -24,10 +23,6 @@ static Ecore_Timer *disc_timer = NULL;
static unsigned int disc_count = 0;
static unsigned int update_count = 0;
static Ecore_Timer *update_timer = NULL;
static E_Mixer_Cb sys_pulse_mixer_update_cb = NULL;
static E_Mixer_Ready_Cb sys_pulse_mixer_ready_cb = NULL;
static Eina_Bool _mixer_pulse_init(void);
static Eina_Bool
_pulse_poller_cb(void *d __UNUSED__)
@ -36,7 +31,7 @@ _pulse_poller_cb(void *d __UNUSED__)
snprintf(buf, sizeof(buf), "%s/.pulse-cookie", getenv("HOME"));
if (ecore_file_exists(buf))
return !_mixer_pulse_init();
return !e_mixer_pulse_init();
return EINA_TRUE;
}
@ -47,7 +42,7 @@ _dbus_poll(void *data EINA_UNUSED, const EDBus_Message *msg)
if (edbus_message_arguments_get(msg, "sss", &name, &from, &to))
{
if (!strcmp(name, PULSE_BUS))
_mixer_pulse_init();
e_mixer_pulse_init();
}
if (dbus_handler)
@ -79,7 +74,7 @@ _dbus_test(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pend
dbus = NULL;
edbus_shutdown();
}
if(sys_pulse_mixer_ready_cb) sys_pulse_mixer_ready_cb(EINA_FALSE);
e_mod_mixer_pulse_ready(EINA_FALSE);
return;
}
}
@ -97,16 +92,16 @@ _pulse_info_get(Pulse *d __UNUSED__, int type __UNUSED__, Pulse_Server_Info *ev)
{
if (default_sink == sink) return;
default_sink = sink;
if (!_mixer_using_default && sys_pulse_mixer_update_cb) sys_pulse_mixer_update_cb();
if (!_mixer_using_default) e_mod_mixer_pulse_update();
break;
}
if(sys_pulse_mixer_ready_cb) sys_pulse_mixer_ready_cb(EINA_FALSE);
e_mod_mixer_pulse_ready(EINA_TRUE);
}
static Eina_Bool
_pulse_update_timer(void *d EINA_UNUSED)
{
if (sys_pulse_mixer_update_cb) sys_pulse_mixer_update_cb();
e_mod_mixer_pulse_update();
update_timer = NULL;
return EINA_FALSE;
}
@ -156,7 +151,7 @@ _pulse_sinks_get(Pulse *p __UNUSED__, Pulse_Tag_Id id __UNUSED__, Eina_List *ev)
sinks = ev;
pulse_sinks_watch(conn);
if (default_sink && sys_pulse_mixer_ready_cb) sys_pulse_mixer_ready_cb(EINA_FALSE);
if (default_sink) e_mod_mixer_pulse_ready(EINA_TRUE);
}
static void
@ -215,9 +210,9 @@ _pulse_disc_timer(void *d __UNUSED__)
{
if (pulse_connect(conn)) return EINA_FALSE;
}
if (sys_pulse_mixer_ready_cb) sys_pulse_mixer_ready_cb(EINA_FALSE);
e_mod_mixer_pulse_ready(EINA_FALSE);
e_mixer_pulse_shutdown();
_mixer_pulse_init();
e_mixer_pulse_init();
disc_count = 0;
return EINA_FALSE;
}
@ -310,9 +305,9 @@ _pulse_queue_process(const Eina_Hash *h EINA_UNUSED, const char *key, E_Mixer_Ch
{
if (key != pulse_sink_name_get(s)) continue;
if ((state->left >= 0) || (state->right >= 0))
e_mixer_pulse_set_volume(s, (E_Mixer_Channel_Info*)&ch, state->left, state->right);
e_mixer_pulse_set_volume(s, &ch, state->left, state->right);
if (state->mute >= 0)
e_mixer_pulse_set_mute(s, (E_Mixer_Channel_Info*)&ch, state->mute);
e_mixer_pulse_set_mute(s, &ch, state->mute);
state->left = state->right = state->mute = -1;
return EINA_FALSE;
}
@ -336,15 +331,7 @@ e_mixer_pulse_ready(void)
}
Eina_Bool
e_mixer_pulse_init(E_Mixer_Ready_Cb e_sys_pulse_ready_cb, E_Mixer_Cb e_sys_pulse_update_cb)
{
sys_pulse_mixer_ready_cb = e_sys_pulse_ready_cb;
sys_pulse_mixer_update_cb = e_sys_pulse_update_cb;
return _mixer_pulse_init();
}
static Eina_Bool
_mixer_pulse_init(void)
e_mixer_pulse_init(void)
{
pulse_init();
conn = pulse_new();
@ -385,7 +372,6 @@ _mixer_pulse_init(void)
ph = ecore_event_handler_add(PULSE_EVENT_CONNECTED, (Ecore_Event_Handler_Cb)_pulse_connected, conn);
pch = ecore_event_handler_add(PULSE_EVENT_CHANGE, (Ecore_Event_Handler_Cb)_pulse_update, conn);
pdh = ecore_event_handler_add(PULSE_EVENT_DISCONNECTED, (Ecore_Event_Handler_Cb)_pulse_disconnected, conn);
if (!_name) _name = eina_stringshare_add("Output");
return EINA_TRUE;
error:
pulse_free(conn);
@ -431,8 +417,6 @@ e_mixer_pulse_shutdown(void)
edbus_shutdown();
}
pulse_shutdown();
if (_name) eina_stringshare_del(_name);
_name = NULL;
}
E_Mixer_System *
@ -459,6 +443,12 @@ e_mixer_pulse_get_cards(void)
return ret;
}
void
e_mixer_pulse_free_cards(Eina_List *cards)
{
E_FREE_LIST(cards, eina_stringshare_del);
}
const char *
e_mixer_pulse_get_default_card(void)
{
@ -482,50 +472,55 @@ e_mixer_pulse_get_card_name(const char *card)
Eina_List *
e_mixer_pulse_get_channels(E_Mixer_System *self EINA_UNUSED)
{
E_Mixer_Channel_Info *ch_info;
return eina_list_append(NULL, (void *)(1));
}
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)1;
ch_info->name = eina_stringshare_ref(_name);
ch_info->capabilities= E_MIXER_CHANNEL_CAN_MUTE|E_MIXER_CHANNEL_HAS_PLAYBACK;
return eina_list_append(NULL, ch_info);
void
e_mixer_pulse_free_channels(Eina_List *channels)
{
eina_list_free(channels);
}
Eina_List *
e_mixer_pulse_get_channel_names(E_Mixer_System *self EINA_UNUSED)
e_mixer_pulse_get_channels_names(E_Mixer_System *self EINA_UNUSED)
{
return eina_list_append(NULL, eina_stringshare_ref(_name));
return eina_list_append(NULL, eina_stringshare_add("Output"));
}
void
e_mixer_pulse_free_channels_names(Eina_List *channels_names)
{
const char *str;
EINA_LIST_FREE(channels_names, str)
eina_stringshare_del(str);
}
const char *
e_mixer_pulse_get_default_channel_name(E_Mixer_System *self EINA_UNUSED)
{
return eina_stringshare_ref(_name);
return eina_stringshare_add("Output");
}
E_Mixer_Channel_Info *
E_Mixer_Channel *
e_mixer_pulse_get_channel_by_name(E_Mixer_System *self EINA_UNUSED, const char *name EINA_UNUSED)
{
E_Mixer_Channel_Info *ch_info;
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)1;
ch_info->name = eina_stringshare_ref(_name);
ch_info->capabilities= E_MIXER_CHANNEL_CAN_MUTE|E_MIXER_CHANNEL_HAS_PLAYBACK;
return ch_info;
return (E_Mixer_Channel *)1;
}
/* const char * */
/* e_mixer_pulse_get_channel_name(E_Mixer_System *self EINA_UNUSED, E_Mixer_Channel_Info *channel) */
/* { */
/* if (!channel) return NULL; */
/* return eina_stringshare_ref(_name); */
/* } */
void
e_mixer_pulse_channel_del(E_Mixer_Channel *channel __UNUSED__)
{
}
const char *
e_mixer_pulse_get_channel_name(E_Mixer_System *self EINA_UNUSED, E_Mixer_Channel *channel)
{
if (!channel) return NULL;
return eina_stringshare_add("Output");
}
int
e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *left, int *right)
e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *left, int *right)
{
double volume;
int x, n;
@ -549,7 +544,7 @@ e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, in
}
int
e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int left, int right)
e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int left, int right)
{
uint32_t id = 0;
int x, n;
@ -586,14 +581,20 @@ e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, in
}
int
e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel __UNUSED__, int *mute)
e_mixer_pulse_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
{
return 1;
}
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);
return 1;
}
int
e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel __UNUSED__, int mute)
e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel __UNUSED__, int mute)
{
uint32_t id;
Eina_Bool source = EINA_FALSE;
@ -612,7 +613,7 @@ e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel __UNU
}
int
e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_Mixer_Channel_State *state)
e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_Channel_State *state)
{
if (!state) return 0;
if (!channel) return 0;
@ -621,11 +622,16 @@ e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_M
return 1;
}
/* int */
/* e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, const E_Mixer_Channel_State *state) */
/* { */
/* e_mixer_pulse_set_volume(self, channel, state->left, state->right); */
/* e_mixer_pulse_set_mute(self, channel, state->mute); */
/* return 1; */
/* } */
int
e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_Mixer_Channel_State *state)
{
e_mixer_pulse_set_volume(self, channel, state->left, state->right);
e_mixer_pulse_set_mute(self, channel, state->mute);
return 1;
}
int
e_mixer_pulse_has_capture(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
{
return 0;
}