Disable controls when the underlying device disappears
This commit is contained in:
parent
efec7b606d
commit
228a102163
|
@ -209,6 +209,20 @@ void mixercontrol_set_icon(MixerControl * control, String const * icon)
|
|||
GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
|
||||
/* useful */
|
||||
/* mixercontrol_disable */
|
||||
void mixercontrol_disable(MixerControl * control)
|
||||
{
|
||||
gtk_widget_set_sensitive(control->frame, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/* mixercontrol_enable */
|
||||
void mixercontrol_enable(MixerControl * control)
|
||||
{
|
||||
gtk_widget_set_sensitive(control->frame, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* private */
|
||||
/* mixercontrol_helper_set */
|
||||
|
|
|
@ -57,4 +57,8 @@ GtkWidget * mixercontrol_get_widget(MixerControl * control);
|
|||
|
||||
void mixercontrol_set_icon(MixerControl * control, String const * icon);
|
||||
|
||||
/* useful */
|
||||
void mixercontrol_disable(MixerControl * control);
|
||||
void mixercontrol_enable(MixerControl * control);
|
||||
|
||||
#endif /* !MIXER_CONTROL_H */
|
||||
|
|
22
src/mixer.c
22
src/mixer.c
|
@ -995,7 +995,11 @@ static int _mixer_get_control(Mixer * mixer, MixerControl2 * control)
|
|||
|
||||
md.index = control->index;
|
||||
if(ioctl(mixer->fd, AUDIO_MIXER_DEVINFO, &md) != 0)
|
||||
return -_mixer_error(mixer, "AUDIO_MIXER_DEVINFO", 1);
|
||||
{
|
||||
if(errno == ENXIO)
|
||||
return -errno;
|
||||
return _mixer_error(mixer, "AUDIO_MIXER_DEVINFO", -errno);
|
||||
}
|
||||
p.dev = control->index;
|
||||
/* XXX this is necessary for some drivers and I don't like it */
|
||||
if((p.type = md.type) == AUDIO_MIXER_VALUE)
|
||||
|
@ -1071,7 +1075,7 @@ static int _mixer_get_control(Mixer * mixer, MixerControl2 * control)
|
|||
uint16_t u16;
|
||||
|
||||
if(ioctl(mixer->fd, MIXER_READ(control->index), &value) != 0)
|
||||
return -_mixer_error(NULL, "MIXER_READ", 1);
|
||||
return _mixer_error(NULL, "MIXER_READ", -errno);
|
||||
control->type = 0;
|
||||
control->un.level.delta = 1;
|
||||
control->un.level.channels_cnt = 2;
|
||||
|
@ -1233,9 +1237,17 @@ static int _set_control_widget_set(MixerControl2 * control)
|
|||
/* mixer_refresh_control */
|
||||
static int _mixer_refresh_control(Mixer * mixer, MixerControl2 * control)
|
||||
{
|
||||
if(_mixer_get_control(mixer, control) != 0)
|
||||
return -1;
|
||||
return _mixer_set_control_widget(mixer, control);
|
||||
int ret;
|
||||
|
||||
if((ret = _mixer_get_control(mixer, control)) != 0)
|
||||
{
|
||||
if(ret == -ENXIO)
|
||||
mixercontrol_disable(control->control);
|
||||
return ret;
|
||||
}
|
||||
if((ret = _mixer_set_control_widget(mixer, control)) == 0)
|
||||
mixercontrol_enable(control->control);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user