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:
Volker Fischer 2009-02-24 09:56:11 +00:00
parent 949e2f1387
commit 1bc8c5f84c
4 changed files with 9 additions and 10 deletions

View File

@ -78,9 +78,8 @@ public:
virtual void Init() { InitRecording(); InitPlayback(); }
virtual bool Read ( CVector<short>& psData );
virtual bool Write ( CVector<short>& psData );
virtual void Close();
void Close();
protected:
void InitRecording();
void InitPlayback();
@ -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
};

View File

@ -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()

View File

@ -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

View File

@ -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 );