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 void Init() { InitRecording(); InitPlayback(); }
|
||||||
virtual bool Read ( CVector<short>& psData );
|
virtual bool Read ( CVector<short>& psData );
|
||||||
virtual bool Write ( CVector<short>& psData );
|
virtual bool Write ( CVector<short>& psData );
|
||||||
|
virtual void Close();
|
||||||
void Close();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InitRecording();
|
void InitRecording();
|
||||||
|
@ -106,7 +105,7 @@ protected:
|
||||||
virtual void Init() { printf ( "no sound!" ); }
|
virtual void Init() { printf ( "no sound!" ); }
|
||||||
virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
|
virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
|
||||||
virtual bool Write ( 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
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,16 @@ void CSoundBase::Start()
|
||||||
|
|
||||||
void CSoundBase::Stop()
|
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
|
// set flag so that thread can leave the main loop
|
||||||
bRun = false;
|
bRun = false;
|
||||||
|
|
||||||
// give thread some time to terminate
|
// give thread some time to terminate
|
||||||
wait ( 5000 );
|
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()
|
void CSoundBase::run()
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual void Start();
|
virtual void Start();
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
bool IsRunning() const { return bRun; }
|
bool IsRunning() const { return bRun; }
|
||||||
|
virtual void Close() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// function pointer to callback function
|
// function pointer to callback function
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual bool Read ( CVector<short>& psData );
|
virtual bool Read ( CVector<short>& psData );
|
||||||
virtual bool Write ( CVector<short>& psData );
|
virtual bool Write ( CVector<short>& psData );
|
||||||
|
virtual void Close();
|
||||||
|
|
||||||
int GetNumDev() { return lNumDevs; }
|
int GetNumDev() { return lNumDevs; }
|
||||||
std::string GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
|
std::string GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
|
||||||
|
@ -74,8 +75,6 @@ public:
|
||||||
void SetInNumBuf ( const int iNewNum );
|
void SetInNumBuf ( const int iNewNum );
|
||||||
int GetInNumBuf();
|
int GetInNumBuf();
|
||||||
|
|
||||||
void Close();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool LoadAndInitializeFirstValidDriver();
|
bool LoadAndInitializeFirstValidDriver();
|
||||||
std::string LoadAndInitializeDriver ( int iIdx );
|
std::string LoadAndInitializeDriver ( int iIdx );
|
||||||
|
|
Loading…
Reference in a new issue