added close function for audio interface (this is a preliminary solution for switching off the audio interface when not connected, a better solution would be to implement a stop function but this does not work with our current buffer initialization scheme)
This commit is contained in:
parent
949e2f1387
commit
1bc8c5f84c
4 changed files with 9 additions and 10 deletions
|
@ -78,8 +78,7 @@ public:
|
|||
virtual void Init() { InitRecording(); InitPlayback(); }
|
||||
virtual bool Read ( CVector<short>& psData );
|
||||
virtual bool Write ( CVector<short>& psData );
|
||||
|
||||
void Close();
|
||||
virtual void Close();
|
||||
|
||||
protected:
|
||||
void InitRecording();
|
||||
|
@ -106,7 +105,7 @@ protected:
|
|||
virtual void Init() { printf ( "no sound!" ); }
|
||||
virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
|
||||
virtual bool Write ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
|
||||
void Close() {}
|
||||
virtual void Close() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -37,16 +37,16 @@ void CSoundBase::Start()
|
|||
|
||||
void CSoundBase::Stop()
|
||||
{
|
||||
|
||||
// TODO stop audio interface (previously done in Close function which is
|
||||
// now unused!!!!!!!!!!!
|
||||
|
||||
|
||||
// set flag so that thread can leave the main loop
|
||||
bRun = false;
|
||||
|
||||
// give thread some time to terminate
|
||||
wait ( 5000 );
|
||||
|
||||
|
||||
// TODO stop audio interface (previously done in Close function, we
|
||||
// better should implement a stop function in derived sound classes
|
||||
Close();
|
||||
}
|
||||
|
||||
void CSoundBase::run()
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
virtual void Start();
|
||||
virtual void Stop();
|
||||
bool IsRunning() const { return bRun; }
|
||||
virtual void Close() = 0;
|
||||
|
||||
protected:
|
||||
// function pointer to callback function
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
virtual void Init();
|
||||
virtual bool Read ( CVector<short>& psData );
|
||||
virtual bool Write ( CVector<short>& psData );
|
||||
virtual void Close();
|
||||
|
||||
int GetNumDev() { return lNumDevs; }
|
||||
std::string GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
|
||||
|
@ -74,8 +75,6 @@ public:
|
|||
void SetInNumBuf ( const int iNewNum );
|
||||
int GetInNumBuf();
|
||||
|
||||
void Close();
|
||||
|
||||
protected:
|
||||
bool LoadAndInitializeFirstValidDriver();
|
||||
std::string LoadAndInitializeDriver ( int iIdx );
|
||||
|
|
Loading…
Reference in a new issue