Check Firmware Version before enabling Levels menu item
The level meters don't work correctly on earlier kernel versions, so they shouldn't be displayed in that case. The "Firmware Version" ALSA control was added to the kernel at the same time as the level meters were fixed, so use the presence of that to determine whether or not to enable the menu item.
This commit is contained in:
@@ -470,6 +470,14 @@ static void alsa_add_card_callback(struct alsa_card *card) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void alsa_get_firmware_version(struct alsa_card *card) {
|
||||||
|
struct alsa_elem *elem = get_elem_by_name(card->elems, "Firmware Version");
|
||||||
|
|
||||||
|
if (!elem)
|
||||||
|
return;
|
||||||
|
card->firmware_version = alsa_get_elem_value(elem);
|
||||||
|
}
|
||||||
|
|
||||||
static void alsa_subscribe(struct alsa_card *card) {
|
static void alsa_subscribe(struct alsa_card *card) {
|
||||||
int count = snd_ctl_poll_descriptors_count(card->handle);
|
int count = snd_ctl_poll_descriptors_count(card->handle);
|
||||||
|
|
||||||
@@ -524,6 +532,7 @@ void alsa_scan_cards(void) {
|
|||||||
card->handle = ctl;
|
card->handle = ctl;
|
||||||
|
|
||||||
alsa_get_elem_list(card);
|
alsa_get_elem_list(card);
|
||||||
|
alsa_get_firmware_version(card);
|
||||||
alsa_subscribe(card);
|
alsa_subscribe(card);
|
||||||
|
|
||||||
create_card_window(card);
|
create_card_window(card);
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ struct alsa_card {
|
|||||||
char *name;
|
char *name;
|
||||||
snd_ctl_t *handle;
|
snd_ctl_t *handle;
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
|
int firmware_version;
|
||||||
GArray *elems;
|
GArray *elems;
|
||||||
struct alsa_elem *sample_capture_elem;
|
struct alsa_elem *sample_capture_elem;
|
||||||
struct alsa_elem *level_meter_elem;
|
struct alsa_elem *level_meter_elem;
|
||||||
|
|||||||
14
src/menu.c
14
src/menu.c
@@ -149,7 +149,10 @@ void add_startup_action_map(struct alsa_card *card) {
|
|||||||
|
|
||||||
static const GActionEntry mixer_entries[] = {
|
static const GActionEntry mixer_entries[] = {
|
||||||
{"routing", activate_routing, NULL, "false"},
|
{"routing", activate_routing, NULL, "false"},
|
||||||
{"mixer", activate_mixer, NULL, "false"},
|
{"mixer", activate_mixer, NULL, "false"}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const GActionEntry levels_entries[] = {
|
||||||
{"levels", activate_levels, NULL, "false"}
|
{"levels", activate_levels, NULL, "false"}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,4 +163,13 @@ void add_mixer_action_map(struct alsa_card *card) {
|
|||||||
G_N_ELEMENTS(mixer_entries),
|
G_N_ELEMENTS(mixer_entries),
|
||||||
card
|
card
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (card->firmware_version) {
|
||||||
|
g_action_map_add_action_entries(
|
||||||
|
G_ACTION_MAP(card->window_main),
|
||||||
|
levels_entries,
|
||||||
|
G_N_ELEMENTS(levels_entries),
|
||||||
|
card
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user