From c1cd911c5684fec318e34f65cc280ad898a42a5d Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 20 Mar 2010 18:36:59 +0000 Subject: [PATCH] added settings save/load for sound card channel mapping settings --- ChangeLog | 2 +- src/global.h | 6 ++++++ src/settings.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++ windows/sound.cpp | 12 ++++++++---- windows/sound.h | 6 ------ 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4136b08a..88487eff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 3.1.1 -- +- added input/output audio channel mapping for ASIO audio interface 3.1.0 diff --git a/src/global.h b/src/global.h index eda8883e..be84c279 100755 --- a/src/global.h +++ b/src/global.h @@ -97,6 +97,12 @@ #define MAX_NUMBER_SOUND_CARDS 10 #define INVALID_SNC_CARD_DEVICE -1 +// define the maximum number of audio channel for input/output we can store +// channel infos for (and therefore this is the maximum number of entries in +// the channel selection combo box regardless of the actual available number +// of channels by the audio device) +#define MAX_NUM_IN_OUT_CHANNELS 32 + // maximum number of elemts in the server address combo box #define MAX_NUM_SERVER_ADDR_ITEMS 6 diff --git a/src/settings.cpp b/src/settings.cpp index 52dbdea5..0a8ab7ff 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -112,6 +112,38 @@ void CSettings::ReadIniFile ( const QString& sFileName ) pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE ); } + // sound card channel mapping settings: make sure these settings are + // set AFTER the sound card device is set, otherwise the settings are + // overwritten by the defaults + // + // sound card left input channel mapping + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", + 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + { + pClient->SetSndCrdLeftInputChannel ( iValue ); + } + + // sound card right input channel mapping + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", + 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + { + pClient->SetSndCrdRightInputChannel ( iValue ); + } + + // sound card left output channel mapping + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", + 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + { + pClient->SetSndCrdLeftOutputChannel ( iValue ); + } + + // sound card right output channel mapping + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", + 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + { + pClient->SetSndCrdRightOutputChannel ( iValue ); + } + // sound card preferred buffer size index if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) ) @@ -194,6 +226,22 @@ void CSettings::WriteIniFile ( const QString& sFileName ) SetNumericIniSet ( IniXMLDocument, "client", "auddevidx", pClient->GetSndCrdDev() ); + // sound card left input channel mapping + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", + pClient->GetSndCrdLeftInputChannel() ); + + // sound card right input channel mapping + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", + pClient->GetSndCrdRightInputChannel() ); + + // sound card left output channel mapping + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", + pClient->GetSndCrdLeftOutputChannel() ); + + // sound card right output channel mapping + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", + pClient->GetSndCrdRightOutputChannel() ); + // sound card preferred buffer size index SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", pClient->GetSndCrdPrefFrameSizeFactor() ); diff --git a/windows/sound.cpp b/windows/sound.cpp index 5d2fa948..5fe3f145 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -307,7 +307,8 @@ QString CSound::CheckDeviceCapabilities() void CSound::SetLeftInputChannel ( const int iNewChan ) { // apply parameter after input parameter check - if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) ) + if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) && + ( iNewChan != vSelectedInputChannels[1] ) ) { vSelectedInputChannels[0] = iNewChan; } @@ -316,7 +317,8 @@ void CSound::SetLeftInputChannel ( const int iNewChan ) void CSound::SetRightInputChannel ( const int iNewChan ) { // apply parameter after input parameter check - if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) ) + if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) && + ( iNewChan != vSelectedInputChannels[0] ) ) { vSelectedInputChannels[1] = iNewChan; } @@ -325,7 +327,8 @@ void CSound::SetRightInputChannel ( const int iNewChan ) void CSound::SetLeftOutputChannel ( const int iNewChan ) { // apply parameter after input parameter check - if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) ) + if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) && + ( iNewChan != vSelectedOutputChannels[1] ) ) { vSelectedOutputChannels[0] = iNewChan; } @@ -334,7 +337,8 @@ void CSound::SetLeftOutputChannel ( const int iNewChan ) void CSound::SetRightOutputChannel ( const int iNewChan ) { // apply parameter after input parameter check - if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) ) + if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) && + ( iNewChan != vSelectedOutputChannels[0] ) ) { vSelectedOutputChannels[1] = iNewChan; } diff --git a/windows/sound.h b/windows/sound.h index bda43781..05a7403d 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -43,12 +43,6 @@ // stereo for input and output #define NUM_IN_OUT_CHANNELS 2 -// define the maximum number of audio channel for input/output we can store -// channel infos for (and therefore this is the maximum number of entries in -// the channel selection combo box regardless of the actual available number -// of channels by the audio device) -#define MAX_NUM_IN_OUT_CHANNELS 32 - /* Classes ********************************************************************/ class CSound : public CSoundBase