[alsa-devel] [PATCH 0/8] Even more hdspmixer fixes
Hi!
After some feedback with a couple of users, here's another round of fixes for hdspmixer.
Anybody interested in a clean rewrite-from-scratch with GTK or Qt? ;)
Cheers
Adrian Knoth (8): hdspmixer: Replace hardcoded 3 by MAX_CARDS hdspmixer: Fix preset activation segfault on AES(32) hdspmixer: Adjust playback channel count on Multiface. hdspmixer: Introduce output channel count for all cards. hdspmixer: Provide headphones out on Multiface/Digiface hdspmixer: Fix code indentation hdspmixer: [cosmetics] Break code into logic blocks hdspmixer: Show cardname in window title
hdspmixer/src/HDSPMixerCard.cxx | 391 +++++++++++++++++-------------- hdspmixer/src/HDSPMixerCard.h | 5 +- hdspmixer/src/HDSPMixerCardSelector.cxx | 1 + hdspmixer/src/HDSPMixerIOMixer.cxx | 2 +- hdspmixer/src/HDSPMixerWindow.cxx | 65 ++++-- hdspmixer/src/HDSPMixerWindow.h | 2 + hdspmixer/src/channelmap.cxx | 11 +- hdspmixer/src/hdspmixer.cxx | 21 +- 8 files changed, 284 insertions(+), 214 deletions(-)
We have a define for the number of cards. Use it.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerIOMixer.cxx b/hdspmixer/src/HDSPMixerIOMixer.cxx index a81f4a2..987be41 100644 --- a/hdspmixer/src/HDSPMixerIOMixer.cxx +++ b/hdspmixer/src/HDSPMixerIOMixer.cxx @@ -37,7 +37,7 @@ HDSPMixerIOMixer::HDSPMixerIOMixer(int x, int y, int w, int h, int ch, int type) relative_num = channel_num-1; p_iomixer_xpm = iomixer_r_xpm; } - for (int j = 0; j < 3; ++j) { + for (int j = 0; j < MAX_CARDS; ++j) { for (int i = 0; i < 8; ++i) { data[j][0][i] = new HDSPMixerStripData(); data[j][1][i] = new HDSPMixerStripData(); diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index 27003a0..f52470f 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -344,7 +344,7 @@ void HDSPMixerWindow::save() inputs->buttons->presets->save_preset(current_preset+1); } for (int speed = 0; speed < 3; ++speed) { - for (int card = 0; card < 3; ++card) { + for (int card = 0; card < MAX_CARDS; ++card) { for (int preset = 0; preset < 8; ++preset) { for (int channel = 0; channel < HDSP_MAX_CHANNELS; ++channel) { /* inputs pans and volumes */ @@ -440,7 +440,7 @@ void HDSPMixerWindow::load() return; } for (int speed = 0; speed < 3; ++speed) { - for (int card = 0; card < 3; ++card) { + for (int card = 0; card < MAX_CARDS; ++card) { for (int preset = 0; preset < 8; ++preset) { for (int channel = 0; channel < HDSP_MAX_CHANNELS; ++channel) { /* inputs pans and volumes */ @@ -705,7 +705,7 @@ HDSPMixerWindow::HDSPMixerWindow(int x, int y, int w, int h, const char *label, prefs->flush(); } } - for (int j = 0; j < 3; ++j) { + for (int j = 0; j < MAX_CARDS; j++) { for (int i = 0; i < 8; ++i) { data[j][0][i] = new HDSPMixerPresetData(); data[j][1][i] = new HDSPMixerPresetData();
When selecting preset 6 or 7 on AES(32), hdspmixer has caused a segfault due to indirect out of bound access on the destination label array.
The amount of destinations is the number of physical stereo pairs, so it's usually half the channel count, in some cases one more if there are additional headphone jacks.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index f52470f..8c057e0 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -582,9 +582,9 @@ void HDSPMixerWindow::restoreDefaults(int card) chnls[0] = 16; chnls[1] = 16; chnls[2] = 16; - maxdest[0] = 16; - maxdest[1] = 16; - maxdest[2] = 16; + maxdest[0] = 8; + maxdest[1] = 8; + maxdest[2] = 8; num_modes = 3; break; case HDSPeAIO: @@ -610,6 +610,7 @@ void HDSPMixerWindow::restoreDefaults(int card) /* should never happen */ return; } + for (int preset = 0; preset < 8; ++preset) { for (int speed = 0; speed < num_modes; ++speed) { for (int i = 0; i < chnls[speed]; i+=2) {
The multiface has 18/14 (SS/DS) playback channels, matching the native 18/14 I/O ports. Headphones don't count (only for #destinations).
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index eb51155..cd6a922 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -211,14 +211,14 @@ void HDSPMixerCard::adjustSettings() { switch (speed_mode) { case 0: channels_input = 18; - channels_playback = 20; + channels_playback = 18; channel_map_input = channel_map_playback = channel_map_mf_ss; dest_map = dest_map_mf_ss; meter_map_input = meter_map_playback = channel_map_mf_ss; break; case 1: channels_input = 14; - channels_playback = 16; + channels_playback = 14; channel_map_input = channel_map_playback = meter_map_ds; dest_map = dest_map_ds; meter_map_input = meter_map_playback = meter_map_ds;
Some cards (like multiface) have more physical output ports than playback ports, mostly because of additional headphones out.
For those cards, the old abstraction model of channels_input and channels_output doesn't fit, so let's introduce channels_output.
Of course, channels_output is always 2*max_dest at the given speed_mode (SS/DS/QS), so one could extend this idea, store all destination settings in channels_output[3] (one for each speed mode) and rip off the massive code duplication for setting maxdest or max_dest respectively.
Note that dest_map_whatever_speed_mode's array size indirectly defines the right value for channels_output (read: even more unwanted redundancy)
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index cd6a922..3ddbf62 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -212,6 +212,7 @@ void HDSPMixerCard::adjustSettings() { case 0: channels_input = 18; channels_playback = 18; + channels_output = 20; /* SS 8xAnalog+8xADAT+2xSPDIF+2xHeadphone */ channel_map_input = channel_map_playback = channel_map_mf_ss; dest_map = dest_map_mf_ss; meter_map_input = meter_map_playback = channel_map_mf_ss; @@ -219,6 +220,7 @@ void HDSPMixerCard::adjustSettings() { case 1: channels_input = 14; channels_playback = 14; + channels_output = 16; /* DS 8xAnalog+4xADAT(SMUX)+2xSPDIF+2xHeadphone */ channel_map_input = channel_map_playback = meter_map_ds; dest_map = dest_map_ds; meter_map_input = meter_map_playback = meter_map_ds; @@ -231,12 +233,14 @@ void HDSPMixerCard::adjustSettings() { switch (speed_mode) { case 0: channels_input = channels_playback = 26; + channels_output = 28; /* SS 3x8xADAT+2xSPDIF+2xHeadphone */ channel_map_input = channel_map_playback = channel_map_df_ss; dest_map = dest_map_df_ss; meter_map_input = meter_map_playback = channel_map_df_ss; break; case 1: channels_input = channels_playback = 14; + channels_output = 16; /* DS 3x4xADAT(SMUX)+2xSPDIF+2xHeadphone */ channel_map_input = channel_map_playback = meter_map_ds; dest_map = dest_map_ds; meter_map_input = meter_map_playback = meter_map_ds; @@ -249,12 +253,14 @@ void HDSPMixerCard::adjustSettings() { switch (speed_mode) { case 0: channels_input = channels_playback = 26; + channels_output = 26; /* SS like Digiface, but no Headphones */ channel_map_input = channel_map_playback = channel_map_df_ss; dest_map = dest_map_h9652_ss; meter_map_input = meter_map_playback = channel_map_df_ss; break; case 1: channels_input = channels_playback = 14; + channels_output = 14; /* DS like Digiface, but no Headphones */ channel_map_input = channel_map_playback = channel_map_ds; dest_map = dest_map_h9652_ds; meter_map_input = meter_map_playback = meter_map_ds; @@ -267,18 +273,21 @@ void HDSPMixerCard::adjustSettings() { switch (speed_mode) { case 0: channels_input = channels_playback = 12 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ channel_map_input = channel_map_playback = channel_map_h9632_ss; dest_map = dest_map_h9632_ss; meter_map_input = meter_map_playback = channel_map_h9632_ss; break; case 1: channels_input = channels_playback = 8 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ channel_map_input = channel_map_playback = channel_map_h9632_ds; dest_map = dest_map_h9632_ds; meter_map_input = meter_map_playback = channel_map_h9632_ds; break; case 2: channels_input = channels_playback = 4 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ channel_map_input = channel_map_playback = channel_map_h9632_qs; dest_map = dest_map_h9632_qs; meter_map_input = meter_map_playback = channel_map_h9632_qs; @@ -290,18 +299,21 @@ void HDSPMixerCard::adjustSettings() { switch (speed_mode) { case 0: // SS channels_input = channels_playback = 64; + channels_output = channels_input; /* SS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ channel_map_input = channel_map_playback = channel_map_unity_ss; dest_map = dest_map_unity; meter_map_input = meter_map_playback = channel_map_unity_ss; break; case 1: // DS channels_input = channels_playback = 32; + channels_output = channels_input; /* DS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ channel_map_input = channel_map_playback = channel_map_unity_ss; dest_map = dest_map_unity; meter_map_input = meter_map_playback = channel_map_unity_ss; break; case 2: // QS channels_input = channels_playback = 16; + channels_output = channels_input; /* QS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ channel_map_input = channel_map_playback = channel_map_unity_ss; dest_map = dest_map_unity; meter_map_input = meter_map_playback = channel_map_unity_ss; @@ -315,6 +327,7 @@ void HDSPMixerCard::adjustSettings() { case 0: // SS channels_input = 14; channels_playback = 16; + channels_output = 16; /* SS 2xAnalog+2xAES+2xSPDIF+4xADAT+2xHeadphones */ channel_map_input = channel_map_aio_in_ss; channel_map_playback = channel_map_aio_out_ss; dest_map = dest_map_aio_ss; @@ -324,6 +337,7 @@ void HDSPMixerCard::adjustSettings() { case 1: // DS channels_input = 10; channels_playback = 12; + channels_output = 12; /* DS 2xAnalog+2xAES+2xSPDIF+4xADAT(SMUX)+2xHeadphones */ channel_map_input = channel_map_aio_in_ds; channel_map_playback = channel_map_aio_out_ds; dest_map = dest_map_aio_ds; @@ -333,6 +347,7 @@ void HDSPMixerCard::adjustSettings() { case 2: // QS channels_input = 8; channels_playback = 10; + channels_output = 10; /* QS 2xAnalog+2xAES+2xSPDIF+2xADAT(SMUX)+2xHeadphones */ channel_map_input = channel_map_aio_in_qs; channel_map_playback = channel_map_aio_out_qs; dest_map = dest_map_aio_qs; @@ -347,6 +362,7 @@ void HDSPMixerCard::adjustSettings() { /* 16 channels for all modes */ channels_input = 16; channels_playback = 16; + channels_output = 16; channel_map_input = channel_map_aes32; channel_map_playback = channel_map_aes32; dest_map = dest_map_aes32; @@ -360,13 +376,15 @@ void HDSPMixerCard::adjustSettings() { case 0: // SS channels_input = 36; channels_playback = 36; + channels_output = 36; /* SS 4x8xADAT+2xAES/EBU+2xSPDIF */ channel_map_input = channel_map_playback = channel_map_raydat_ss; dest_map = dest_map_raydat_ss; meter_map_input = meter_map_playback = channel_map_raydat_ss; break; case 1: // DS channels_input = 20; - channels_playback = 20; + channels_playback = 20; + channels_output = 20; /* DS 4x4xADAT(SMUX)+2xAES/EBU+2xSPDIF */ channel_map_input = channel_map_playback = channel_map_raydat_ds; dest_map = dest_map_raydat_ds; meter_map_input = meter_map_playback = channel_map_raydat_ds; @@ -374,6 +392,7 @@ void HDSPMixerCard::adjustSettings() { case 2: // QS channels_input = 12; channels_playback = 12; + channels_output = 12; /* QS 4x2xADAT(SMUX)+2xAES/EBU+2xSPDIF */ channel_map_input = channel_map_playback = channel_map_raydat_qs; dest_map = dest_map_raydat_qs; meter_map_input = meter_map_playback = channel_map_raydat_qs; @@ -397,7 +416,9 @@ void HDSPMixerCard::setMode(int mode) } for (int i = 0; i < channels_playback; ++i) { basew->playbacks->strips[i]->targets->setLabels(); - basew->outputs->strips[i]->setLabels(); + } + for (int i = 0; i < channels_output; ++i) { + basew->outputs->strips[i]->setLabels(); }
if (h9632_aeb.aebo && !h9632_aeb.aebi) { @@ -435,11 +456,16 @@ void HDSPMixerCard::actualizeStrips() } else { basew->inputs->strips[i]->hide(); } + if (i < channels_playback) { basew->playbacks->strips[i]->show(); - basew->outputs->strips[i]->show(); } else { basew->playbacks->strips[i]->hide(); + } + + if (i < channels_output) { + basew->outputs->strips[i]->show(); + } else { basew->outputs->strips[i]->hide(); } } diff --git a/hdspmixer/src/HDSPMixerCard.h b/hdspmixer/src/HDSPMixerCard.h index cfb2402..b721bd9 100644 --- a/hdspmixer/src/HDSPMixerCard.h +++ b/hdspmixer/src/HDSPMixerCard.h @@ -44,6 +44,7 @@ public: char name[6]; HDSPMixerCard(int cardtype, int id); int channels_input, channels_playback, window_width, window_height, card_id; + int channels_output; int type; char *channel_map_input, *channel_map_playback; char *dest_map; diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index 8c057e0..8f44c99 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -109,7 +109,7 @@ static void readregisters_cb(void *arg) }
if (w->inputs->buttons->output) { - for (int i = 0; i < w->cards[w->current_card]->channels_playback; ++i) { + for (int i = 0; i < w->cards[w->current_card]->channels_output; ++i) { w->outputs->strips[i]->meter->update(output_peaks[(w->cards[w->current_card]->meter_map_playback[i])] & 0xffffff00, output_peaks[(w->cards[w->current_card]->meter_map_playback[i])] & 0xf, output_rms[(w->cards[w->current_card]->meter_map_playback[i])]); @@ -738,7 +738,7 @@ HDSPMixerWindow::HDSPMixerWindow(int x, int y, int w, int h, const char *label, inputs->buttons->submix = 1; inputs->buttons->playback = 1; playbacks = new HDSPMixerPlaybacks(0, MENU_HEIGHT+FULLSTRIP_HEIGHT, w, FULLSTRIP_HEIGHT, cards[0]->channels_playback); - outputs = new HDSPMixerOutputs(0, MENU_HEIGHT+FULLSTRIP_HEIGHT*2, w, SMALLSTRIP_HEIGHT, cards[0]->channels_playback); + outputs = new HDSPMixerOutputs(0, MENU_HEIGHT+FULLSTRIP_HEIGHT*2, w, SMALLSTRIP_HEIGHT, cards[0]->channels_output); scroll->end(); end(); setup = new HDSPMixerSetup(400, 260, "Level Meters Setup", this);
Both, Multiface and Digiface feature a separate headphone submix, so reflect this additional pair of channels in the corresponding maps.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/channelmap.cxx b/hdspmixer/src/channelmap.cxx index f2f0585..598be56 100644 --- a/hdspmixer/src/channelmap.cxx +++ b/hdspmixer/src/channelmap.cxx @@ -54,15 +54,18 @@ char channel_map_mf_ss[26] = { 0, 1, 2, 3, 4, 5, 6, 7, /* Line in */ 16, 17, 18, 19, 20, 21, 22, 23, /* ADAT */ 24, 25, /* SPDIF */ - -1, -1, -1, -1, -1, -1, -1, -1 + 26, 27, /* Phones L+R, only a destination channel */ + -1, -1, -1, -1, -1, -1 };
// Digiface/Multiface
char meter_map_ds[26] = { - 0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, - 24, 25, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + 0, 1, 2, 3, 8, 9, 10, 11, /* analog 1-8 on Multiface, ADAT1+2 on Digiface*/ + 16, 17, 18, 19, /* ADAT on Multiface, ADAT3 on Digiface */ + 24, 25, /* SPDIF */ + 26, 27, /* Headphones */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
char channel_map_ds[26] = {
Only cosmetics, no changed semantics. Indent the whole function to get rid of a mixture of tabs and spaces.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index 3ddbf62..bf7009f 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -208,202 +208,202 @@ void HDSPMixerCard::getAeb() {
void HDSPMixerCard::adjustSettings() { if (type == Multiface) { - switch (speed_mode) { - case 0: - channels_input = 18; - channels_playback = 18; - channels_output = 20; /* SS 8xAnalog+8xADAT+2xSPDIF+2xHeadphone */ - channel_map_input = channel_map_playback = channel_map_mf_ss; - dest_map = dest_map_mf_ss; - meter_map_input = meter_map_playback = channel_map_mf_ss; - break; - case 1: - channels_input = 14; - channels_playback = 14; - channels_output = 16; /* DS 8xAnalog+4xADAT(SMUX)+2xSPDIF+2xHeadphone */ - channel_map_input = channel_map_playback = meter_map_ds; - dest_map = dest_map_ds; - meter_map_input = meter_map_playback = meter_map_ds; - break; - case 2: - /* should never happen */ - break; - } + switch (speed_mode) { + case 0: + channels_input = 18; + channels_playback = 18; + channels_output = 20; /* SS 8xAnalog+8xADAT+2xSPDIF+2xHeadphone */ + channel_map_input = channel_map_playback = channel_map_mf_ss; + dest_map = dest_map_mf_ss; + meter_map_input = meter_map_playback = channel_map_mf_ss; + break; + case 1: + channels_input = 14; + channels_playback = 14; + channels_output = 16; /* DS 8xAnalog+4xADAT(SMUX)+2xSPDIF+2xHeadphone */ + channel_map_input = channel_map_playback = meter_map_ds; + dest_map = dest_map_ds; + meter_map_input = meter_map_playback = meter_map_ds; + break; + case 2: + /* should never happen */ + break; + } } else if (type == Digiface) { - switch (speed_mode) { - case 0: - channels_input = channels_playback = 26; - channels_output = 28; /* SS 3x8xADAT+2xSPDIF+2xHeadphone */ - channel_map_input = channel_map_playback = channel_map_df_ss; - dest_map = dest_map_df_ss; - meter_map_input = meter_map_playback = channel_map_df_ss; - break; - case 1: - channels_input = channels_playback = 14; - channels_output = 16; /* DS 3x4xADAT(SMUX)+2xSPDIF+2xHeadphone */ - channel_map_input = channel_map_playback = meter_map_ds; - dest_map = dest_map_ds; - meter_map_input = meter_map_playback = meter_map_ds; - break; - case 2: - /* should never happen */ - break; - } + switch (speed_mode) { + case 0: + channels_input = channels_playback = 26; + channels_output = 28; /* SS 3x8xADAT+2xSPDIF+2xHeadphone */ + channel_map_input = channel_map_playback = channel_map_df_ss; + dest_map = dest_map_df_ss; + meter_map_input = meter_map_playback = channel_map_df_ss; + break; + case 1: + channels_input = channels_playback = 14; + channels_output = 16; /* DS 3x4xADAT(SMUX)+2xSPDIF+2xHeadphone */ + channel_map_input = channel_map_playback = meter_map_ds; + dest_map = dest_map_ds; + meter_map_input = meter_map_playback = meter_map_ds; + break; + case 2: + /* should never happen */ + break; + } } else if (type == H9652) { - switch (speed_mode) { - case 0: - channels_input = channels_playback = 26; - channels_output = 26; /* SS like Digiface, but no Headphones */ - channel_map_input = channel_map_playback = channel_map_df_ss; - dest_map = dest_map_h9652_ss; - meter_map_input = meter_map_playback = channel_map_df_ss; - break; - case 1: - channels_input = channels_playback = 14; - channels_output = 14; /* DS like Digiface, but no Headphones */ - channel_map_input = channel_map_playback = channel_map_ds; - dest_map = dest_map_h9652_ds; - meter_map_input = meter_map_playback = meter_map_ds; - break; - case 2: - /* should never happen */ - break; - } + switch (speed_mode) { + case 0: + channels_input = channels_playback = 26; + channels_output = 26; /* SS like Digiface, but no Headphones */ + channel_map_input = channel_map_playback = channel_map_df_ss; + dest_map = dest_map_h9652_ss; + meter_map_input = meter_map_playback = channel_map_df_ss; + break; + case 1: + channels_input = channels_playback = 14; + channels_output = 14; /* DS like Digiface, but no Headphones */ + channel_map_input = channel_map_playback = channel_map_ds; + dest_map = dest_map_h9652_ds; + meter_map_input = meter_map_playback = meter_map_ds; + break; + case 2: + /* should never happen */ + break; + } } else if (type == H9632) { - switch (speed_mode) { - case 0: - channels_input = channels_playback = 12 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); - channels_output = channels_playback; /* untested, no idea about this card */ - channel_map_input = channel_map_playback = channel_map_h9632_ss; - dest_map = dest_map_h9632_ss; - meter_map_input = meter_map_playback = channel_map_h9632_ss; - break; - case 1: - channels_input = channels_playback = 8 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); - channels_output = channels_playback; /* untested, no idea about this card */ - channel_map_input = channel_map_playback = channel_map_h9632_ds; - dest_map = dest_map_h9632_ds; - meter_map_input = meter_map_playback = channel_map_h9632_ds; - break; - case 2: - channels_input = channels_playback = 4 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); - channels_output = channels_playback; /* untested, no idea about this card */ - channel_map_input = channel_map_playback = channel_map_h9632_qs; - dest_map = dest_map_h9632_qs; - meter_map_input = meter_map_playback = channel_map_h9632_qs; - break; - } + switch (speed_mode) { + case 0: + channels_input = channels_playback = 12 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ + channel_map_input = channel_map_playback = channel_map_h9632_ss; + dest_map = dest_map_h9632_ss; + meter_map_input = meter_map_playback = channel_map_h9632_ss; + break; + case 1: + channels_input = channels_playback = 8 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ + channel_map_input = channel_map_playback = channel_map_h9632_ds; + dest_map = dest_map_h9632_ds; + meter_map_input = meter_map_playback = channel_map_h9632_ds; + break; + case 2: + channels_input = channels_playback = 4 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); + channels_output = channels_playback; /* untested, no idea about this card */ + channel_map_input = channel_map_playback = channel_map_h9632_qs; + dest_map = dest_map_h9632_qs; + meter_map_input = meter_map_playback = channel_map_h9632_qs; + break; + } } else if (HDSPeMADI == type) { - playbacks_offset = 64; + playbacks_offset = 64;
- switch (speed_mode) { - case 0: // SS - channels_input = channels_playback = 64; - channels_output = channels_input; /* SS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ - channel_map_input = channel_map_playback = channel_map_unity_ss; - dest_map = dest_map_unity; - meter_map_input = meter_map_playback = channel_map_unity_ss; - break; - case 1: // DS - channels_input = channels_playback = 32; - channels_output = channels_input; /* DS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ - channel_map_input = channel_map_playback = channel_map_unity_ss; - dest_map = dest_map_unity; - meter_map_input = meter_map_playback = channel_map_unity_ss; - break; - case 2: // QS - channels_input = channels_playback = 16; - channels_output = channels_input; /* QS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ - channel_map_input = channel_map_playback = channel_map_unity_ss; - dest_map = dest_map_unity; - meter_map_input = meter_map_playback = channel_map_unity_ss; - break; - } + switch (speed_mode) { + case 0: // SS + channels_input = channels_playback = 64; + channels_output = channels_input; /* SS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ + channel_map_input = channel_map_playback = channel_map_unity_ss; + dest_map = dest_map_unity; + meter_map_input = meter_map_playback = channel_map_unity_ss; + break; + case 1: // DS + channels_input = channels_playback = 32; + channels_output = channels_input; /* DS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ + channel_map_input = channel_map_playback = channel_map_unity_ss; + dest_map = dest_map_unity; + meter_map_input = meter_map_playback = channel_map_unity_ss; + break; + case 2: // QS + channels_input = channels_playback = 16; + channels_output = channels_input; /* QS headphones missing, at least HDSPe MADI has some, MADIface hasn't */ + channel_map_input = channel_map_playback = channel_map_unity_ss; + dest_map = dest_map_unity; + meter_map_input = meter_map_playback = channel_map_unity_ss; + break; + }
} else if (HDSPeAIO == type) { - playbacks_offset = 64; + playbacks_offset = 64;
- switch (speed_mode) { - case 0: // SS - channels_input = 14; - channels_playback = 16; - channels_output = 16; /* SS 2xAnalog+2xAES+2xSPDIF+4xADAT+2xHeadphones */ - channel_map_input = channel_map_aio_in_ss; - channel_map_playback = channel_map_aio_out_ss; - dest_map = dest_map_aio_ss; - meter_map_input = channel_map_aio_in_ss; - meter_map_playback = channel_map_aio_out_ss; - break; - case 1: // DS - channels_input = 10; - channels_playback = 12; - channels_output = 12; /* DS 2xAnalog+2xAES+2xSPDIF+4xADAT(SMUX)+2xHeadphones */ - channel_map_input = channel_map_aio_in_ds; - channel_map_playback = channel_map_aio_out_ds; - dest_map = dest_map_aio_ds; - meter_map_input = channel_map_aio_in_ds; - meter_map_playback = channel_map_aio_out_ds; - break; - case 2: // QS - channels_input = 8; - channels_playback = 10; - channels_output = 10; /* QS 2xAnalog+2xAES+2xSPDIF+2xADAT(SMUX)+2xHeadphones */ - channel_map_input = channel_map_aio_in_qs; - channel_map_playback = channel_map_aio_out_qs; - dest_map = dest_map_aio_qs; - meter_map_input = channel_map_aio_in_qs; - meter_map_playback = channel_map_aio_out_qs; - break; - } + switch (speed_mode) { + case 0: // SS + channels_input = 14; + channels_playback = 16; + channels_output = 16; /* SS 2xAnalog+2xAES+2xSPDIF+4xADAT+2xHeadphones */ + channel_map_input = channel_map_aio_in_ss; + channel_map_playback = channel_map_aio_out_ss; + dest_map = dest_map_aio_ss; + meter_map_input = channel_map_aio_in_ss; + meter_map_playback = channel_map_aio_out_ss; + break; + case 1: // DS + channels_input = 10; + channels_playback = 12; + channels_output = 12; /* DS 2xAnalog+2xAES+2xSPDIF+4xADAT(SMUX)+2xHeadphones */ + channel_map_input = channel_map_aio_in_ds; + channel_map_playback = channel_map_aio_out_ds; + dest_map = dest_map_aio_ds; + meter_map_input = channel_map_aio_in_ds; + meter_map_playback = channel_map_aio_out_ds; + break; + case 2: // QS + channels_input = 8; + channels_playback = 10; + channels_output = 10; /* QS 2xAnalog+2xAES+2xSPDIF+2xADAT(SMUX)+2xHeadphones */ + channel_map_input = channel_map_aio_in_qs; + channel_map_playback = channel_map_aio_out_qs; + dest_map = dest_map_aio_qs; + meter_map_input = channel_map_aio_in_qs; + meter_map_playback = channel_map_aio_out_qs; + break; + }
} else if (HDSP_AES == type) { - playbacks_offset = 64; /* not sure about this one? */ + playbacks_offset = 64; /* not sure about this one? */
- /* 16 channels for all modes */ - channels_input = 16; - channels_playback = 16; - channels_output = 16; - channel_map_input = channel_map_aes32; - channel_map_playback = channel_map_aes32; - dest_map = dest_map_aes32; - meter_map_input = channel_map_aes32; - meter_map_playback = channel_map_aes32; + /* 16 channels for all modes */ + channels_input = 16; + channels_playback = 16; + channels_output = 16; + channel_map_input = channel_map_aes32; + channel_map_playback = channel_map_aes32; + dest_map = dest_map_aes32; + meter_map_input = channel_map_aes32; + meter_map_playback = channel_map_aes32;
} else if (HDSPeRayDAT == type) { - playbacks_offset = 64; + playbacks_offset = 64;
- switch (speed_mode) { - case 0: // SS - channels_input = 36; - channels_playback = 36; - channels_output = 36; /* SS 4x8xADAT+2xAES/EBU+2xSPDIF */ - channel_map_input = channel_map_playback = channel_map_raydat_ss; - dest_map = dest_map_raydat_ss; - meter_map_input = meter_map_playback = channel_map_raydat_ss; - break; - case 1: // DS - channels_input = 20; - channels_playback = 20; - channels_output = 20; /* DS 4x4xADAT(SMUX)+2xAES/EBU+2xSPDIF */ - channel_map_input = channel_map_playback = channel_map_raydat_ds; - dest_map = dest_map_raydat_ds; - meter_map_input = meter_map_playback = channel_map_raydat_ds; - break; - case 2: // QS - channels_input = 12; - channels_playback = 12; - channels_output = 12; /* QS 4x2xADAT(SMUX)+2xAES/EBU+2xSPDIF */ - channel_map_input = channel_map_playback = channel_map_raydat_qs; - dest_map = dest_map_raydat_qs; - meter_map_input = meter_map_playback = channel_map_raydat_qs; - break; - } + switch (speed_mode) { + case 0: // SS + channels_input = 36; + channels_playback = 36; + channels_output = 36; /* SS 4x8xADAT+2xAES/EBU+2xSPDIF */ + channel_map_input = channel_map_playback = channel_map_raydat_ss; + dest_map = dest_map_raydat_ss; + meter_map_input = meter_map_playback = channel_map_raydat_ss; + break; + case 1: // DS + channels_input = 20; + channels_playback = 20; + channels_output = 20; /* DS 4x4xADAT(SMUX)+2xAES/EBU+2xSPDIF */ + channel_map_input = channel_map_playback = channel_map_raydat_ds; + dest_map = dest_map_raydat_ds; + meter_map_input = meter_map_playback = channel_map_raydat_ds; + break; + case 2: // QS + channels_input = 12; + channels_playback = 12; + channels_output = 12; /* QS 4x2xADAT(SMUX)+2xAES/EBU+2xSPDIF */ + channel_map_input = channel_map_playback = channel_map_raydat_qs; + dest_map = dest_map_raydat_qs; + meter_map_input = meter_map_playback = channel_map_raydat_qs; + break; + }
}
window_width = (channels_playback+2)*STRIP_WIDTH; window_height = FULLSTRIP_HEIGHT*2+SMALLSTRIP_HEIGHT+MENU_HEIGHT; -} +}
void HDSPMixerCard::setMode(int mode) {
Convert the if-then-else-if chain into standalone if-then blocks to improve readability. A switch-case statement would also do the trick, but it's less readable.
No (intended) semantic change.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index bf7009f..b754b20 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -229,7 +229,9 @@ void HDSPMixerCard::adjustSettings() { /* should never happen */ break; } - } else if (type == Digiface) { + } + + if (type == Digiface) { switch (speed_mode) { case 0: channels_input = channels_playback = 26; @@ -249,7 +251,9 @@ void HDSPMixerCard::adjustSettings() { /* should never happen */ break; } - } else if (type == H9652) { + } + + if (type == H9652) { switch (speed_mode) { case 0: channels_input = channels_playback = 26; @@ -269,7 +273,9 @@ void HDSPMixerCard::adjustSettings() { /* should never happen */ break; } - } else if (type == H9632) { + } + + if (type == H9632) { switch (speed_mode) { case 0: channels_input = channels_playback = 12 + ((h9632_aeb.aebi || h9632_aeb.aebo) ? 4 : 0); @@ -293,7 +299,9 @@ void HDSPMixerCard::adjustSettings() { meter_map_input = meter_map_playback = channel_map_h9632_qs; break; } - } else if (HDSPeMADI == type) { + } + + if (HDSPeMADI == type) { playbacks_offset = 64;
switch (speed_mode) { @@ -320,7 +328,9 @@ void HDSPMixerCard::adjustSettings() { break; }
- } else if (HDSPeAIO == type) { + } + + if (HDSPeAIO == type) { playbacks_offset = 64;
switch (speed_mode) { @@ -356,7 +366,9 @@ void HDSPMixerCard::adjustSettings() { break; }
- } else if (HDSP_AES == type) { + } + + if (HDSP_AES == type) { playbacks_offset = 64; /* not sure about this one? */
/* 16 channels for all modes */ @@ -369,7 +381,9 @@ void HDSPMixerCard::adjustSettings() { meter_map_input = channel_map_aes32; meter_map_playback = channel_map_aes32;
- } else if (HDSPeRayDAT == type) { + } + + if (HDSPeRayDAT == type) { playbacks_offset = 64;
switch (speed_mode) {
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
diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index b754b20..f3205b9 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -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) { diff --git a/hdspmixer/src/HDSPMixerCard.h b/hdspmixer/src/HDSPMixerCard.h index b721bd9..032c61f 100644 --- a/hdspmixer/src/HDSPMixerCard.h +++ b/hdspmixer/src/HDSPMixerCard.h @@ -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; diff --git a/hdspmixer/src/HDSPMixerCardSelector.cxx b/hdspmixer/src/HDSPMixerCardSelector.cxx index 0e31847..d83c4c9 100644 --- a/hdspmixer/src/HDSPMixerCardSelector.cxx +++ b/hdspmixer/src/HDSPMixerCardSelector.cxx @@ -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 (); }
diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index 8f44c99..364d727 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -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; } }
diff --git a/hdspmixer/src/HDSPMixerWindow.h b/hdspmixer/src/HDSPMixerWindow.h index 0eb6f1a..dfc7d59 100644 --- a/hdspmixer/src/HDSPMixerWindow.h +++ b/hdspmixer/src/HDSPMixerWindow.h @@ -93,6 +93,8 @@ public: void refreshMixerStrip(int idx, int src); void save(); void load(); + void setTitle(std::string suffix); + void setTitleWithFilename(); };
#endif diff --git a/hdspmixer/src/hdspmixer.cxx b/hdspmixer/src/hdspmixer.cxx index d57fe4c..4929863 100644 --- a/hdspmixer/src/hdspmixer.cxx +++ b/hdspmixer/src/hdspmixer.cxx @@ -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");
At Mon, 7 Mar 2011 19:03:01 +0100, Adrian Knoth wrote:
Hi!
After some feedback with a couple of users, here's another round of fixes for hdspmixer.
All applied now. Thanks.
Anybody interested in a clean rewrite-from-scratch with GTK or Qt? ;)
I'd like to hear it from someone, too ;)
Takashi
Cheers
Adrian Knoth (8): hdspmixer: Replace hardcoded 3 by MAX_CARDS hdspmixer: Fix preset activation segfault on AES(32) hdspmixer: Adjust playback channel count on Multiface. hdspmixer: Introduce output channel count for all cards. hdspmixer: Provide headphones out on Multiface/Digiface hdspmixer: Fix code indentation hdspmixer: [cosmetics] Break code into logic blocks hdspmixer: Show cardname in window title
hdspmixer/src/HDSPMixerCard.cxx | 391 +++++++++++++++++-------------- hdspmixer/src/HDSPMixerCard.h | 5 +- hdspmixer/src/HDSPMixerCardSelector.cxx | 1 + hdspmixer/src/HDSPMixerIOMixer.cxx | 2 +- hdspmixer/src/HDSPMixerWindow.cxx | 65 ++++-- hdspmixer/src/HDSPMixerWindow.h | 2 + hdspmixer/src/channelmap.cxx | 11 +- hdspmixer/src/hdspmixer.cxx | 21 +- 8 files changed, 284 insertions(+), 214 deletions(-)
-- 1.7.4.1
participants (2)
-
Adrian Knoth
-
Takashi Iwai