diff --git a/src/soundbase.cpp b/src/soundbase.cpp index 5151b5d7..5a478539 100755 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -26,6 +26,21 @@ /* Implementation *************************************************************/ +CSoundBase::CSoundBase ( const bool bNewIsCallbackAudioInterface, + void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), + void* pParg ) : + fpProcessCallback ( fpNewProcessCallback ), + pProcessCallbackArg ( pParg ), bRun ( false ), + bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ) +{ + // initializations for the sound card names (default) + lNumDevs = 1; + strDriverNames[0] = "Default"; + + // set current device + lCurDev = 0; // default device +} + int CSoundBase::Init ( const int iNewPrefMonoBufferSize ) { // init audio sound card buffer diff --git a/src/soundbase.h b/src/soundbase.h index 7d067ffc..865c722f 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -26,6 +26,7 @@ #define SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_ #include +#include #include "global.h" #include "util.h" @@ -38,19 +39,19 @@ class CSoundBase : public QThread public: CSoundBase ( const bool bNewIsCallbackAudioInterface, void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), - void* pParg ) : fpProcessCallback ( fpNewProcessCallback ), - pProcessCallbackArg ( pParg ), bRun ( false ), - bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ) {} + void* pParg ); virtual int Init ( const int iNewPrefMonoBufferSize ); virtual void Start(); virtual void Stop(); + // device selection + virtual int GetNumDev() { return lNumDevs; } + virtual QString GetDeviceName ( const int iDiD ) { return strDriverNames[iDiD]; } + // dummy implementations in base class - virtual int GetNumDev() { return 1; } - virtual QString GetDeviceName ( const int ) { return "Default"; } virtual QString SetDev ( const int ) { return ""; } - virtual int GetDev() { return 0; } + virtual int GetDev() { return lCurDev; } virtual int GetNumInputChannels() { return 2; } virtual QString GetInputChannelName ( const int ) { return "Default"; } @@ -96,6 +97,10 @@ protected: CVector vecsAudioSndCrdStereo; + long lNumDevs; + long lCurDev; + QString strDriverNames[MAX_NUMBER_SOUND_CARDS]; + signals: void ReinitRequest(); }; diff --git a/windows/sound.cpp b/windows/sound.cpp index a55c812e..fd054ee1 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -539,6 +539,7 @@ CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), // get available ASIO driver names in system for ( i = 0; i < MAX_NUMBER_SOUND_CARDS; i++ ) { + // allocate memory for driver names cDriverNames[i] = new char[32]; } @@ -558,6 +559,13 @@ CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), } asioDrivers->removeCurrentDriver(); + // copy driver names to base class but internally we still have to use + // the char* variable because of the ASIO API :-( + for ( i = 0; i < lNumDevs; i++ ) + { + strDriverNames[i] = cDriverNames[i]; + } + // init device index with illegal value to show that driver is not initialized lCurDev = -1; diff --git a/windows/sound.h b/windows/sound.h index 5300a56f..354b0518 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -58,10 +58,7 @@ public: virtual void OpenDriverSetup() { ASIOControlPanel(); } // device selection - virtual int GetNumDev() { return lNumDevs; } - virtual QString GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; } virtual QString SetDev ( const int iNewDev ); - virtual int GetDev() { return lCurDev; } // channel selection virtual int GetNumInputChannels() { return static_cast ( lNumInChan ); } @@ -126,9 +123,7 @@ protected: static void sampleRateChanged ( ASIOSampleRate ) {} static long asioMessages ( long selector, long value, void* message, double* opt ); - long lNumDevs; - long lCurDev; - char* cDriverNames[MAX_NUMBER_SOUND_CARDS]; + char* cDriverNames[MAX_NUMBER_SOUND_CARDS]; }; #endif // !defined ( _SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ )