Store the best_firmware_version in struct alsa_card

This commit is contained in:
Geoffrey D. Bennett
2024-03-12 02:11:21 +10:30
parent ba2cb557c5
commit 74b84a26be
4 changed files with 6 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
#include <sys/inotify.h> #include <sys/inotify.h>
#include "alsa.h" #include "alsa.h"
#include "scarlett2-firmware.h"
#include "stringhelper.h" #include "stringhelper.h"
#include "window-iface.h" #include "window-iface.h"
@@ -778,6 +779,7 @@ static void alsa_scan_cards(void) {
alsa_subscribe(card); alsa_subscribe(card);
alsa_get_usbid(card); alsa_get_usbid(card);
alsa_get_serial_number(card); alsa_get_serial_number(card);
card->best_firmware_version = scarlett2_get_best_firmware_version(card->pid);
if (card->serial) { if (card->serial) {

View File

@@ -155,6 +155,7 @@ struct alsa_card {
uint32_t pid; uint32_t pid;
char *serial; char *serial;
char *name; char *name;
int best_firmware_version;
snd_ctl_t *handle; snd_ctl_t *handle;
struct pollfd pfd; struct pollfd pfd;
GArray *elems; GArray *elems;

View File

@@ -25,10 +25,7 @@ GtkWidget *create_iface_update_main(struct alsa_card *card) {
gtk_widget_add_css_class(w, "window-title"); gtk_widget_add_css_class(w, "window-title");
gtk_box_append(GTK_BOX(content), w); gtk_box_append(GTK_BOX(content), w);
uint32_t best_firmware_version = if (!card->best_firmware_version) {
scarlett2_get_best_firmware_version(card->pid);
if (!best_firmware_version) {
w = gtk_label_new(NULL); w = gtk_label_new(NULL);
gtk_label_set_markup( gtk_label_set_markup(
GTK_LABEL(w), GTK_LABEL(w),

View File

@@ -5,7 +5,6 @@
#include "device-update-firmware.h" #include "device-update-firmware.h"
#include "gtkhelper.h" #include "gtkhelper.h"
#include "scarlett2.h" #include "scarlett2.h"
#include "scarlett2-firmware.h"
#include "scarlett2-ioctls.h" #include "scarlett2-ioctls.h"
#include "widget-boolean.h" #include "widget-boolean.h"
#include "window-startup.h" #include "window-startup.h"
@@ -273,10 +272,8 @@ static void add_reset_actions(
return; return;
int firmware_version = alsa_get_elem_value(firmware_elem); int firmware_version = alsa_get_elem_value(firmware_elem);
uint32_t best_firmware_version =
scarlett2_get_best_firmware_version(card->pid);
if (firmware_version >= best_firmware_version) if (firmware_version >= card->best_firmware_version)
return; return;
char *s = g_strdup_printf( char *s = g_strdup_printf(
@@ -284,7 +281,7 @@ static void add_reset_actions(
"factory default settings and update the firmware from version " "factory default settings and update the firmware from version "
"%d to %d.", "%d to %d.",
firmware_version, firmware_version,
best_firmware_version card->best_firmware_version
); );
add_reset_action( add_reset_action(
card, card,