put some functions from Windows sound in sound base class
This commit is contained in:
parent
215374c2e2
commit
a8795c1bf3
4 changed files with 35 additions and 12 deletions
|
@ -26,6 +26,21 @@
|
|||
|
||||
|
||||
/* Implementation *************************************************************/
|
||||
CSoundBase::CSoundBase ( const bool bNewIsCallbackAudioInterface,
|
||||
void (*fpNewProcessCallback) ( CVector<int16_t>& 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
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_
|
||||
|
||||
#include <qthread.h>
|
||||
#include <qstring.h>
|
||||
#include "global.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -38,19 +39,19 @@ class CSoundBase : public QThread
|
|||
public:
|
||||
CSoundBase ( const bool bNewIsCallbackAudioInterface,
|
||||
void (*fpNewProcessCallback) ( CVector<int16_t>& 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<int16_t> vecsAudioSndCrdStereo;
|
||||
|
||||
long lNumDevs;
|
||||
long lCurDev;
|
||||
QString strDriverNames[MAX_NUMBER_SOUND_CARDS];
|
||||
|
||||
signals:
|
||||
void ReinitRequest();
|
||||
};
|
||||
|
|
|
@ -539,6 +539,7 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& 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<int16_t>& 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;
|
||||
|
||||
|
|
|
@ -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<int> ( 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_ )
|
||||
|
|
Loading…
Reference in a new issue