mixer: use E_Mixer_Channel_Info as subsystem fct param

E_Mixer_Channel is only used within audio subsystems
e_mod_mixer_channel_info_get_by_name returns a E_Mixer_Channel_Info
use e_mod_mixer_channel_info_free to free a single channel_info
This commit is contained in:
Jérémy Zurcher 2013-02-27 15:24:30 +01:00
parent ab7edf7ff6
commit d75622c33c
8 changed files with 143 additions and 131 deletions

View File

@ -65,7 +65,7 @@ _cb_changed_left(void *data, Evas_Object *obj __UNUSED__)
state->right);
}
e_mod_mixer_volume_set(app->sys, app->channel_info->id,
e_mod_mixer_volume_set(app->sys, app->channel_info,
state->left, state->right);
}
@ -83,7 +83,7 @@ _cb_changed_right(void *data, Evas_Object *obj __UNUSED__)
state->left);
}
e_mod_mixer_volume_set(app->sys, app->channel_info->id,
e_mod_mixer_volume_set(app->sys, app->channel_info,
state->left, state->right);
}
@ -92,7 +92,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->id, app->state.mute);
e_mod_mixer_mute_set(app->sys, app->channel_info, app->state.mute);
}
static void
@ -112,7 +112,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->id,
e_mod_mixer_volume_set(app->sys, app->channel_info,
state->left, state->right);
}
@ -148,7 +148,7 @@ _update_channel_editor_state(E_Mixer_App_Dialog_Data *app, const E_Mixer_Channel
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))
if (e_mod_mixer_mutable_get(app->sys, app->channel_info))
{
e_widget_disabled_set(ui->mute, 0);
e_widget_check_checked_set(ui->mute, state.mute);
@ -180,12 +180,12 @@ _populate_channel_editor(E_Mixer_App_Dialog_Data *app)
e_widget_entry_text_set(ui->channel, app->channel_name);
if (e_mod_mixer_capture_get(app->sys, app->channel_info->id))
if (e_mod_mixer_capture_get(app->sys, app->channel_info))
e_widget_entry_text_set(ui->type, _("Capture"));
else
e_widget_entry_text_set(ui->type, _("Playback"));
e_mod_mixer_state_get(app->sys, app->channel_info->id, &state);
e_mod_mixer_state_get(app->sys, app->channel_info, &state);
_update_channel_editor_state(app, state);
app->lock_sliders = (state.left == state.right);
@ -212,7 +212,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->id, &state);
e_mod_mixer_state_get(app->sys, app->channel_info, &state);
_update_channel_editor_state(app, state);
return 1;

View File

@ -783,7 +783,7 @@ _mixer_sys_setup(E_Mixer_Instance *inst)
return 0;
}
inst->channel = e_mod_mixer_channel_get_by_name(inst->sys, conf->channel_name);
inst->channel = e_mod_mixer_channel_info_get_by_name(inst->sys, conf->channel_name);
return !!inst->channel;
}
@ -855,7 +855,7 @@ _mixer_sys_setup_default_channel(E_Mixer_Instance *inst)
if (!channel_name)
goto error;
inst->channel = e_mod_mixer_channel_get_by_name(inst->sys, channel_name);
inst->channel = e_mod_mixer_channel_info_get_by_name(inst->sys, channel_name);
if (!inst->channel)
goto system_error;
@ -915,7 +915,7 @@ e_mod_mixer_pulse_ready(Eina_Bool ready)
{
EINA_LIST_FOREACH(ctxt->instances, l, inst)
{
e_mod_mixer_channel_del(inst->channel);
e_mod_mixer_channel_info_free(inst->channel);
e_mod_mixer_del(inst->sys);
inst->channel = NULL;
inst->sys = NULL;
@ -1074,7 +1074,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_del(inst->channel);
e_mod_mixer_channel_info_free(inst->channel);
e_mod_mixer_del(inst->sys);
inst->conf->instance = NULL;

View File

@ -50,7 +50,7 @@ typedef struct E_Mixer_Instance
} ui;
E_Mixer_System *sys;
E_Mixer_Channel *channel;
E_Mixer_Channel_Info *channel;
E_Mixer_Channel_State mixer_state;
E_Mixer_Gadget_Config *conf;

View File

@ -11,10 +11,8 @@ 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_info_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_get;
E_Mixer_Cb e_mod_mixer_channel_names_get;
E_Mixer_Cb e_mod_mixer_card_name_get;
@ -34,9 +32,8 @@ e_mixer_default_setup(void)
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_info_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_get = (void *)e_mixer_system_get_channels;
e_mod_mixer_channel_names_get = (void *)e_mixer_system_get_channel_names;
e_mod_mixer_card_name_get = (void *)e_mixer_system_get_card_name;
@ -58,9 +55,8 @@ e_mixer_pulse_setup()
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_info_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_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;
@ -82,6 +78,13 @@ _channel_info_cmp(const void *data_a, const void *data_b)
return strcmp(a->name, b->name);
}
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)
{

View File

@ -22,12 +22,12 @@ typedef struct _E_Mixer_Channel_Info
E_Mixer_App *app;
} E_Mixer_Channel_Info;
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 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 int (*E_Mixer_Capture_Cb)(E_Mixer_System *, E_Mixer_Channel_Info *);
typedef void *(*E_Mixer_Cb)();
extern Eina_Bool _mixer_using_default;
@ -41,15 +41,14 @@ 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_info_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_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*);
@ -67,23 +66,22 @@ void e_mixer_system_del(E_Mixer_System *self);
Eina_List *e_mixer_system_get_cards(void);
const char *e_mixer_system_get_default_card(void);
const char *e_mixer_system_get_card_name(const char *card);
const char *e_mixer_system_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel);
const char *e_mixer_system_get_channel_name(E_Mixer_System *self, E_Mixer_Channel_Info *channel);
Eina_List *e_mixer_system_get_channels(E_Mixer_System *self);
Eina_List *e_mixer_system_get_channel_names(E_Mixer_System *self);
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);
void e_mixer_system_channel_del(E_Mixer_Channel *channel);
E_Mixer_Channel_Info *e_mixer_system_get_channel_by_name(E_Mixer_System *self, const char *name);
int e_mixer_system_has_capture(E_Mixer_System *self, E_Mixer_Channel *channel);
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_can_mute(E_Mixer_System *self, E_Mixer_Channel *channel);
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_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_has_capture(E_Mixer_System *self, E_Mixer_Channel_Info *channel);
int e_mixer_system_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *left, int *right);
int e_mixer_system_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int left, int right);
int e_mixer_system_can_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel);
int e_mixer_system_get_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *mute);
int e_mixer_system_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int mute);
int e_mixer_system_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_Mixer_Channel_State *state);
int e_mixer_system_set_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, const E_Mixer_Channel_State *state);
/* PULSE */
int pulse_init(void);
@ -97,23 +95,22 @@ 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);
const char *e_mixer_pulse_get_channel_name(E_Mixer_System *self, E_Mixer_Channel *channel);
const char *e_mixer_pulse_get_channel_name(E_Mixer_System *self, E_Mixer_Channel_Info *channel);
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 *e_mixer_pulse_get_channel_by_name(E_Mixer_System *self, const char *name);
void e_mixer_pulse_channel_del(E_Mixer_Channel *channel);
E_Mixer_Channel_Info *e_mixer_pulse_get_channel_by_name(E_Mixer_System *self, const char *name);
int e_mixer_pulse_has_capture(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_Info *channel);
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_can_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel);
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);
int e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, const E_Mixer_Channel_State *state);
/**
* @addtogroup Optional_Devices

View File

@ -383,12 +383,13 @@ e_mixer_system_get_default_channel_name(E_Mixer_System *self)
return NULL;
}
E_Mixer_Channel *
E_Mixer_Channel_Info *
e_mixer_system_get_channel_by_name(E_Mixer_System *self,
const char *name)
{
snd_mixer_elem_t *elem;
snd_mixer_selem_id_t *sid;
E_Mixer_Channel_Info *ch_info;
if ((!self) || (!name))
return NULL;
@ -406,29 +407,31 @@ e_mixer_system_get_channel_by_name(E_Mixer_System *self,
snd_mixer_selem_get_id(elem, sid);
n = snd_mixer_selem_id_get_name(sid);
if (n && (strcmp(n, name) == 0))
return elem;
{
ch_info = malloc(sizeof(*ch_info));
ch_info->id = elem;
ch_info->name = eina_stringshare_add(n);
ch_info->has_capture = snd_mixer_selem_has_capture_switch(elem) || snd_mixer_selem_has_capture_volume(elem);
return ch_info;
}
}
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,
E_Mixer_Channel *channel)
E_Mixer_Channel_Info *channel)
{
snd_mixer_selem_id_t *sid;
const char *name;
if ((!self) || (!channel))
if ((!self) || (!channel) || (!channel->id) )
return NULL;
snd_mixer_selem_id_alloca(&sid);
snd_mixer_selem_get_id(channel, sid);
snd_mixer_selem_get_id(channel->id, sid);
name = eina_stringshare_add(snd_mixer_selem_id_get_name(sid));
return name;
@ -436,33 +439,33 @@ e_mixer_system_get_channel_name(E_Mixer_System *self,
int
e_mixer_system_get_volume(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
int *left,
int *right)
{
long lvol, rvol, range, min, max;
if ((!self) || (!channel) || (!left) || (!right))
if ((!self) || (!channel) || (!channel->id) || (!left) || (!right))
return 0;
snd_mixer_handle_events(self);
snd_mixer_selem_get_playback_volume_range(channel, &min, &max);
snd_mixer_selem_get_playback_volume_range(channel->id, &min, &max);
range = max - min;
if (range < 1)
return 0;
if (snd_mixer_selem_has_playback_channel(channel, 0))
snd_mixer_selem_get_playback_volume(channel, 0, &lvol);
if (snd_mixer_selem_has_playback_channel(channel->id, 0))
snd_mixer_selem_get_playback_volume(channel->id, 0, &lvol);
else
lvol = min;
if (snd_mixer_selem_has_playback_channel(channel, 1))
snd_mixer_selem_get_playback_volume(channel, 1, &rvol);
if (snd_mixer_selem_has_playback_channel(channel->id, 1))
snd_mixer_selem_get_playback_volume(channel->id, 1, &rvol);
else
rvol = min;
if (snd_mixer_selem_is_playback_mono(channel) ||
snd_mixer_selem_has_playback_volume_joined(channel))
if (snd_mixer_selem_is_playback_mono(channel->id) ||
snd_mixer_selem_has_playback_volume_joined(channel->id))
rvol = lvol;
*left = rint((double)(lvol - min) * 100 / (double)range);
@ -473,18 +476,18 @@ e_mixer_system_get_volume(E_Mixer_System *self,
int
e_mixer_system_set_volume(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
int left,
int right)
{
long range, min, max, divide;
int mode;
if ((!self) || (!channel))
if ((!self) || (!channel) || (!channel->id))
return 0;
snd_mixer_handle_events(self);
snd_mixer_selem_get_playback_volume_range(channel, &min, &max);
snd_mixer_selem_get_playback_volume_range(channel->id, &min, &max);
divide = 100 + min;
if (divide == 0)
{
@ -510,14 +513,14 @@ e_mixer_system_set_volume(E_Mixer_System *self,
}
if (mode & 1)
snd_mixer_selem_set_playback_volume(channel, 0, left);
snd_mixer_selem_set_playback_volume(channel->id, 0, left);
if ((!snd_mixer_selem_is_playback_mono(channel)) &&
(!snd_mixer_selem_has_playback_volume_joined(channel)) &&
if ((!snd_mixer_selem_is_playback_mono(channel->id)) &&
(!snd_mixer_selem_has_playback_volume_joined(channel->id)) &&
(mode & 2))
{
if (snd_mixer_selem_has_playback_channel(channel, 1))
snd_mixer_selem_set_playback_volume(channel, 1, right);
if (snd_mixer_selem_has_playback_channel(channel->id, 1))
snd_mixer_selem_set_playback_volume(channel->id, 1, right);
}
return 1;
@ -525,34 +528,34 @@ e_mixer_system_set_volume(E_Mixer_System *self,
int
e_mixer_system_can_mute(E_Mixer_System *self,
E_Mixer_Channel *channel)
E_Mixer_Channel_Info *channel)
{
if ((!self) || (!channel))
if ((!self) || (!channel) || (!channel->id))
return 0;
snd_mixer_handle_events(self);
return snd_mixer_selem_has_playback_switch(channel) ||
snd_mixer_selem_has_playback_switch_joined(channel);
return snd_mixer_selem_has_playback_switch(channel->id) ||
snd_mixer_selem_has_playback_switch_joined(channel->id);
}
int
e_mixer_system_get_mute(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
int *mute)
{
if ((!self) || (!channel) || (!mute))
if ((!self) || (!channel) || (!channel->id) || (!mute))
return 0;
snd_mixer_handle_events(self);
if (snd_mixer_selem_has_playback_switch(channel) ||
snd_mixer_selem_has_playback_switch_joined(channel))
if (snd_mixer_selem_has_playback_switch(channel->id) ||
snd_mixer_selem_has_playback_switch_joined(channel->id))
{
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);
snd_mixer_selem_get_playback_switch(channel->id, 0, &m);
*mute = !m;
}
else
@ -563,23 +566,23 @@ e_mixer_system_get_mute(E_Mixer_System *self,
int
e_mixer_system_set_mute(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
int mute)
{
if ((!self) || (!channel))
if ((!self) || (!channel) || (!channel->id))
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);
if (snd_mixer_selem_has_playback_switch(channel->id) ||
snd_mixer_selem_has_playback_switch_joined(channel->id))
return snd_mixer_selem_set_playback_switch_all(channel->id, !mute);
else
return 0;
}
int
e_mixer_system_get_state(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
E_Mixer_Channel_State *state)
{
int r;
@ -594,7 +597,7 @@ e_mixer_system_get_state(E_Mixer_System *self,
int
e_mixer_system_set_state(E_Mixer_System *self,
E_Mixer_Channel *channel,
E_Mixer_Channel_Info *channel,
const E_Mixer_Channel_State *state)
{
int r;
@ -609,11 +612,11 @@ e_mixer_system_set_state(E_Mixer_System *self,
int
e_mixer_system_has_capture(E_Mixer_System *self,
E_Mixer_Channel *channel)
E_Mixer_Channel_Info *channel)
{
if ((!self) || (!channel))
if ((!self) || (!channel) || (!channel->id))
return 0;
return snd_mixer_selem_has_capture_switch(channel) || snd_mixer_selem_has_capture_volume(channel);
return snd_mixer_selem_has_capture_switch(channel->id) || snd_mixer_selem_has_capture_volume(channel->id);
}

View File

@ -90,35 +90,41 @@ e_mixer_system_get_default_channel_name(E_Mixer_System *self __UNUSED__)
return eina_stringshare_ref(_name);
}
E_Mixer_Channel *
E_Mixer_Channel_Info *
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)
return (E_Mixer_Channel *)-2;
{
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)-2;
ch_info->name = eina_stringshare_ref(_name);
ch_info->has_capture = 0;
return ch_info;
}
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)
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)
if (!channel)
return NULL;
if (channel->id == (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)
e_mixer_system_get_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__, int *left, int *right)
{
if (left)
*left = 0;
@ -129,19 +135,19 @@ e_mixer_system_get_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *chan
}
int
e_mixer_system_set_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, int left __UNUSED__, int right __UNUSED__)
e_mixer_system_set_volume(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__, int left __UNUSED__, int right __UNUSED__)
{
return 0;
}
int
e_mixer_system_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
e_mixer_system_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__)
{
return 1;
}
int
e_mixer_system_get_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, int *mute)
e_mixer_system_get_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__, int *mute)
{
if (mute)
*mute = 1;
@ -150,13 +156,13 @@ e_mixer_system_get_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channe
}
int
e_mixer_system_set_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, int mute __UNUSED__)
e_mixer_system_set_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__, int mute __UNUSED__)
{
return 0;
}
int
e_mixer_system_get_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, E_Mixer_Channel_State *state)
e_mixer_system_get_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__, E_Mixer_Channel_State *state)
{
const E_Mixer_Channel_State def = {1, 0, 0};
@ -167,13 +173,13 @@ e_mixer_system_get_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *chann
}
int
e_mixer_system_set_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__, const E_Mixer_Channel_State *state __UNUSED__)
e_mixer_system_set_state(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *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__)
e_mixer_system_has_capture(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__)
{
return 0;
}

View File

@ -297,11 +297,12 @@ static Eina_Bool
_pulse_queue_process(const Eina_Hash *h EINA_UNUSED, const char *key, E_Mixer_Channel_State *state, void *d EINA_UNUSED)
{
Eina_List *l, *list[2] = {sinks, sources};
void *s, *ch;
E_Mixer_Channel_Info ch;
void *s;
int x;
if ((state->mute == -1) && (state->left == -1) && (state->right == -1)) return EINA_TRUE;
ch = (void*)1;
ch.id = (void*)1;
for (x = 0; x < 2; x++)
EINA_LIST_FOREACH(list[x], l, s)
{
@ -493,26 +494,28 @@ e_mixer_pulse_get_default_channel_name(E_Mixer_System *self EINA_UNUSED)
return eina_stringshare_ref(_name);
}
E_Mixer_Channel *
E_Mixer_Channel_Info *
e_mixer_pulse_get_channel_by_name(E_Mixer_System *self EINA_UNUSED, const char *name EINA_UNUSED)
{
return (E_Mixer_Channel *)1;
}
E_Mixer_Channel_Info *ch_info;
void
e_mixer_pulse_channel_del(E_Mixer_Channel *channel __UNUSED__)
{
ch_info = malloc(sizeof(*ch_info));
ch_info->id = (void*)1;
ch_info->name = eina_stringshare_ref(_name);
ch_info->has_capture = 0;
return ch_info;
}
const char *
e_mixer_pulse_get_channel_name(E_Mixer_System *self EINA_UNUSED, E_Mixer_Channel *channel)
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);
}
int
e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *left, int *right)
e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int *left, int *right)
{
double volume;
int x, n;
@ -536,7 +539,7 @@ e_mixer_pulse_get_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int *le
}
int
e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int left, int right)
e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel_Info *channel, int left, int right)
{
uint32_t id = 0;
int x, n;
@ -573,20 +576,20 @@ e_mixer_pulse_set_volume(E_Mixer_System *self, E_Mixer_Channel *channel, int lef
}
int
e_mixer_pulse_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
e_mixer_pulse_can_mute(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__)
{
return 1;
}
int
e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel *channel __UNUSED__, int *mute)
e_mixer_pulse_get_mute(E_Mixer_System *self, E_Mixer_Channel_Info *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 *channel __UNUSED__, int mute)
e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel_Info *channel __UNUSED__, int mute)
{
uint32_t id;
Eina_Bool source = EINA_FALSE;
@ -605,7 +608,7 @@ e_mixer_pulse_set_mute(E_Mixer_System *self, E_Mixer_Channel *channel __UNUSED__
}
int
e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_Channel_State *state)
e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel_Info *channel, E_Mixer_Channel_State *state)
{
if (!state) return 0;
if (!channel) return 0;
@ -615,7 +618,7 @@ e_mixer_pulse_get_state(E_Mixer_System *self, E_Mixer_Channel *channel, E_Mixer_
}
int
e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_Mixer_Channel_State *state)
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);
@ -623,7 +626,7 @@ e_mixer_pulse_set_state(E_Mixer_System *self, E_Mixer_Channel *channel, const E_
}
int
e_mixer_pulse_has_capture(E_Mixer_System *self __UNUSED__, E_Mixer_Channel *channel __UNUSED__)
e_mixer_pulse_has_capture(E_Mixer_System *self __UNUSED__, E_Mixer_Channel_Info *channel __UNUSED__)
{
return 0;
}