mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 02:46:30 +01:00
fixes for coping with zero elements or groups
This commit is contained in:
parent
c1f35c1425
commit
0dcb344612
3 changed files with 11 additions and 9 deletions
|
@ -5,7 +5,7 @@ GtkWidget *window;
|
||||||
GtkWidget *main_vbox;
|
GtkWidget *main_vbox;
|
||||||
GtkWidget *mixer_container;
|
GtkWidget *mixer_container;
|
||||||
GtkWidget *exit_item;
|
GtkWidget *exit_item;
|
||||||
unsigned char *nomem_msg = N_("No enough ememory.\n");
|
unsigned char *nomem_msg = N_("No enough memory.\n");
|
||||||
|
|
||||||
int main(int , char **);
|
int main(int , char **);
|
||||||
int disp_mixer( void );
|
int disp_mixer( void );
|
||||||
|
|
|
@ -83,7 +83,7 @@ gint probe_mixer( void ) {
|
||||||
}
|
}
|
||||||
groups.pgroups = (snd_mixer_gid_t *)g_malloc(groups.groups_over
|
groups.pgroups = (snd_mixer_gid_t *)g_malloc(groups.groups_over
|
||||||
*sizeof(snd_mixer_eid_t));
|
*sizeof(snd_mixer_eid_t));
|
||||||
if( groups.pgroups == NULL ) {
|
if( groups.pgroups == NULL && groups.groups_over) {
|
||||||
fprintf(stderr,nomem_msg);
|
fprintf(stderr,nomem_msg);
|
||||||
snd_ctl_close(p_handle);
|
snd_ctl_close(p_handle);
|
||||||
snd_mixer_close(m_handle);
|
snd_mixer_close(m_handle);
|
||||||
|
@ -107,7 +107,7 @@ gint probe_mixer( void ) {
|
||||||
}
|
}
|
||||||
es.pelements = (snd_mixer_eid_t *)g_malloc(
|
es.pelements = (snd_mixer_eid_t *)g_malloc(
|
||||||
es.elements_over * sizeof(snd_mixer_eid_t));
|
es.elements_over * sizeof(snd_mixer_eid_t));
|
||||||
if( es.pelements == NULL ) {
|
if( es.pelements == NULL && es.elements_over) {
|
||||||
fprintf(stderr,nomem_msg);
|
fprintf(stderr,nomem_msg);
|
||||||
snd_ctl_close(p_handle);
|
snd_ctl_close(p_handle);
|
||||||
snd_mixer_close(m_handle);
|
snd_mixer_close(m_handle);
|
||||||
|
@ -123,7 +123,7 @@ gint probe_mixer( void ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
es_nums = (int *)g_malloc(es.elements * sizeof(int));
|
es_nums = (int *)g_malloc(es.elements * sizeof(int));
|
||||||
if( es_nums == NULL ) {
|
if( es_nums == NULL && es.elements) {
|
||||||
fprintf(stderr,nomem_msg);
|
fprintf(stderr,nomem_msg);
|
||||||
snd_ctl_close(p_handle);
|
snd_ctl_close(p_handle);
|
||||||
snd_mixer_close(m_handle);
|
snd_mixer_close(m_handle);
|
||||||
|
@ -176,7 +176,7 @@ gint probe_mixer( void ) {
|
||||||
}
|
}
|
||||||
group->g.pelements = (snd_mixer_eid_t *)g_malloc(
|
group->g.pelements = (snd_mixer_eid_t *)g_malloc(
|
||||||
group->g.elements_over*sizeof(snd_mixer_eid_t));
|
group->g.elements_over*sizeof(snd_mixer_eid_t));
|
||||||
if( group->g.pelements == NULL ) {
|
if( group->g.pelements == NULL && group->g.elements_over) {
|
||||||
snd_ctl_close(p_handle);
|
snd_ctl_close(p_handle);
|
||||||
fprintf(stderr,nomem_msg);
|
fprintf(stderr,nomem_msg);
|
||||||
snd_mixer_close(m_handle);
|
snd_mixer_close(m_handle);
|
||||||
|
@ -193,7 +193,7 @@ gint probe_mixer( void ) {
|
||||||
}
|
}
|
||||||
group->e=(s_element_t *)g_malloc(group->g.elements_size*
|
group->e=(s_element_t *)g_malloc(group->g.elements_size*
|
||||||
sizeof(s_element_t));
|
sizeof(s_element_t));
|
||||||
if( group->e == NULL ) {
|
if( group->e == NULL && group->g.elements_size) {
|
||||||
fprintf(stderr,nomem_msg);
|
fprintf(stderr,nomem_msg);
|
||||||
snd_ctl_close(p_handle);
|
snd_ctl_close(p_handle);
|
||||||
snd_mixer_close(m_handle);
|
snd_mixer_close(m_handle);
|
||||||
|
|
|
@ -62,7 +62,9 @@ GtkWidget *create_mixer_page(int card_num, int mixer_num)
|
||||||
w = (int)(1.5 *
|
w = (int)(1.5 *
|
||||||
(float)card[i].mixer[j].info.elements /
|
(float)card[i].mixer[j].info.elements /
|
||||||
(float)card[i].mixer[j].info.groups);
|
(float)card[i].mixer[j].info.groups);
|
||||||
|
if (w == 0)
|
||||||
|
col = 0;
|
||||||
|
else
|
||||||
/* Compute the number of groups in a column */
|
/* Compute the number of groups in a column */
|
||||||
col = (card[i].mixer[j].info.groups + w - 1)/ w;
|
col = (card[i].mixer[j].info.groups + w - 1)/ w;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue