]> git.alsa-project.org Git - alsa-tools.git/commitdiff
hdspmixer: Show cardname in window title
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>
Mon, 7 Mar 2011 18:03:09 +0000 (19:03 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 8 Mar 2011 12:04:56 +0000 (13:04 +0100)
When running with more than one card, it isn't obvious which card is
shown.

Store the ALSA cardname in the corresponding class and show it in the
window title upon switching cards.

Also, don't show "(null)" but "(unsaved)" in case the user hasn't
selected a preset file.

Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
hdspmixer/src/HDSPMixerCard.cxx
hdspmixer/src/HDSPMixerCard.h
hdspmixer/src/HDSPMixerCardSelector.cxx
hdspmixer/src/HDSPMixerWindow.cxx
hdspmixer/src/HDSPMixerWindow.h
hdspmixer/src/hdspmixer.cxx

index b754b208478f00dc8a03fc15a734e52e559edfb1..f3205b9330bf8190f3b8868176d06e1b1952b85b 100644 (file)
@@ -163,11 +163,12 @@ int HDSPMixerCard::getSpeed()
     return 0;    
 }
 
-HDSPMixerCard::HDSPMixerCard(int cardtype, int id)
+HDSPMixerCard::HDSPMixerCard(int cardtype, int id, char *shortname)
 {
     type = cardtype;
     card_id = id;
     snprintf(name, 6, "hw:%i", card_id);
+    cardname = shortname;
     h9632_aeb.aebi = 0;
     h9632_aeb.aebo = 0;
     if (type == H9632) {
index b721bd939b4f1ae414b67aa982de6daadec0be0f..032c61f2e0ad84190925e7ac717e41cf73b264ab 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string>
 #include <alsa/asoundlib.h>
 #include <alsa/sound/hdsp.h>
 #include <alsa/sound/hdspm.h>
@@ -42,7 +43,8 @@ private:
 public:
     HDSPMixerWindow *basew;
     char name[6];
-    HDSPMixerCard(int cardtype, int id);
+    std::string cardname;
+    HDSPMixerCard(int cardtype, int id, char *shortname);
     int channels_input, channels_playback, window_width, window_height, card_id;
     int channels_output;
     int type;
index 0e31847c1785210981e624853fe1da959d1a7e84..d83c4c9f4745c3f07aa343503d6946d5a823a178 100644 (file)
@@ -50,6 +50,7 @@ void HDSPMixerCardSelector::ActivateCard (int i)
   card = i + 1;
   basew->current_card = i;
   basew->cards[i]->setMode (basew->cards[i]->getSpeed ());
+  basew->setTitleWithFilename();
   redraw ();
 }
 
index 8f44c99a03b3455eef442ada4129599c3c924faf..364d72746c0827f40b879100b6247a6a47d4dfa3 100644 (file)
@@ -216,8 +216,7 @@ static void save_cb(Fl_Widget *widget, void *arg)
        if (!(w->file_name = fl_file_chooser("Choose a file to save presets to :", "HDSPMixer preset file (*.mix)", NULL, 0))) return;
     }
     w->save();
-    snprintf(w->window_title, FL_PATH_MAX, "HDSPMixer - %s",  fl_filename_name(w->file_name));
-    w->label(w->window_title);
+    w->setTitleWithFilename();
 }
 
 static void make_default_cb(Fl_Widget *widget, void *arg)
@@ -241,8 +240,7 @@ static void restore_defaults_cb(Fl_Widget *widget, void *arg)
     w->prefs->deleteEntry("default_file");
     w->prefs->flush();
     w->file_name = NULL;
-    snprintf(w->window_title, FL_PATH_MAX, "HDSPMixer");
-    w->label(w->window_title);
+    w->setTitleWithFilename();
     w->resetMixer();
     while (i < MAX_CARDS && w->cards[i] != NULL) {
        w->restoreDefaults(i++);
@@ -516,8 +514,7 @@ void HDSPMixerWindow::load()
        }
     }
     fclose(file);
-    snprintf(window_title, FL_PATH_MAX, "HDSPMixer - %s",  fl_filename_name(file_name));
-    label(window_title);
+    setTitleWithFilename();
     resetMixer();
     inputs->buttons->presets->preset_change(1);
     return;
@@ -527,6 +524,29 @@ load_error:
     return;
 }
 
+void HDSPMixerWindow::setTitle(std::string suffix)
+{
+    std::string title = "HDSPMixer (";
+
+    title = title + cards[current_card]->cardname + ") "; /*cardname */
+    title = title + suffix;
+    snprintf(window_title, FL_PATH_MAX, "%s", title.c_str());
+    label(window_title);
+}
+
+void HDSPMixerWindow::setTitleWithFilename(void)
+{
+    const char *filename = fl_filename_name(file_name);
+
+    if (NULL == file_name) {
+        filename = "(unsaved)";
+    }
+
+    setTitle(filename);
+}
+
+
+
 void HDSPMixerWindow::restoreDefaults(int card)
 {
     int chnls[3];
@@ -883,16 +903,14 @@ void HDSPMixerWindow::checkState()
        corrupt++;
 
     if (corrupt) {
-       if (!dirty) {
-           dirty = 1;
-           snprintf(window_title, FL_PATH_MAX, "HDSPMixer - %s *",  fl_filename_name(file_name));
-           label(window_title);
-           Fl::add_timeout(0.3, dirty_cb, (void *)this); 
-       }
+        if (!dirty) {
+            dirty = 1;
+            setTitleWithFilename();
+            Fl::add_timeout(0.3, dirty_cb, (void *)this); 
+        }
     } else {
-       snprintf(window_title, FL_PATH_MAX, "HDSPMixer - %s",  fl_filename_name(file_name));
-       label(window_title);
-       dirty = 0;
+        setTitleWithFilename();
+        dirty = 0;
     }
 }
 
index 0eb6f1a9a0a23d891fc2eb6387215107a42cf2bd..dfc7d593996da3d81e0a0486dc5cc36140c468d9 100644 (file)
@@ -93,6 +93,8 @@ public:
     void refreshMixerStrip(int idx, int src);
     void save();
     void load();
+    void setTitle(std::string suffix);
+    void setTitleWithFilename();
 };
 
 #endif
index d57fe4c5341a0ec55488b066a40a3faf5f060a5b..49298635c160f6a77e18b20f36a013535821c5e8 100644 (file)
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
 {
     HDSPMixerWindow *window;
     HDSPMixerCard *hdsp_cards[3];
-    char *name;
+    char *name, *shortname;
     int card;
     int cards = 0;
 
@@ -55,42 +55,43 @@ int main(int argc, char **argv)
         }
 
         snd_card_get_longname(card, &name);
+        snd_card_get_name(card, &shortname);
         printf("Card %d: %s\n", card, name);
         if (!strncmp(name, "RME Hammerfall DSP + Multiface", 30)) {
             printf("Multiface found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(Multiface, card);
+            hdsp_cards[cards] = new HDSPMixerCard(Multiface, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME Hammerfall DSP + Digiface", 29)) {
             printf("Digiface found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(Digiface, card);
+            hdsp_cards[cards] = new HDSPMixerCard(Digiface, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME Hammerfall HDSP 9652", 24)) {
             printf("HDSP 9652 found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(H9652, card);
+            hdsp_cards[cards] = new HDSPMixerCard(H9652, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME Hammerfall HDSP 9632", 24)) {
             printf("HDSP 9632 found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(H9632, card);
+            hdsp_cards[cards] = new HDSPMixerCard(H9632, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME MADIface", 12)) {
             printf("RME MADIface found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(HDSPeMADI, card);
+            hdsp_cards[cards] = new HDSPMixerCard(HDSPeMADI, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME MADI", 8)) {
             printf("RME MADI found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(HDSPeMADI, card);
+            hdsp_cards[cards] = new HDSPMixerCard(HDSPeMADI, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME AES32", 8)) {
             printf("RME AES32 or HDSPe AES found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(HDSP_AES, card);
+            hdsp_cards[cards] = new HDSPMixerCard(HDSP_AES, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME RayDAT", 10)) {
             printf("RME RayDAT found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(HDSPeRayDAT, card);
+            hdsp_cards[cards] = new HDSPMixerCard(HDSPeRayDAT, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME AIO", 7)) {
             printf("RME AIO found!\n");
-            hdsp_cards[cards] = new HDSPMixerCard(HDSPeAIO, card);
+            hdsp_cards[cards] = new HDSPMixerCard(HDSPeAIO, card, shortname);
             cards++;
         } else if (!strncmp(name, "RME Hammerfall DSP", 18)) {
             printf("Uninitialized HDSP card found.\nUse hdsploader to upload configuration data to the card.\n");