jamulus/src/soundbase.h

75 lines
2.7 KiB
C
Raw Normal View History

2009-02-23 00:13:59 +01:00
/******************************************************************************\
* Copyright (c) 2004-2009
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined ( SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_ )
#define SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_
#include <qthread.h>
#include "global.h"
#include "util.h"
/* Classes ********************************************************************/
class CSoundBase : public QThread
{
public:
CSoundBase ( const bool bNewIsCallbackAudioInterface,
void (*fpNewCallback) ( CVector<short>& psData, void* arg ),
void* arg ) : fpCallback ( fpNewCallback ), pCallbackArg ( arg ),
bRun ( false ),
bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ) {}
2009-02-23 00:13:59 +01:00
virtual ~CSoundBase() {}
2009-03-01 23:08:06 +01:00
virtual int Init ( const int iNewPrefMonoBufferSize );
2009-02-23 00:13:59 +01:00
virtual void Start();
virtual void Stop();
bool IsRunning() const { return bRun; }
virtual void OpenDriverSetup() {}
2009-02-23 00:13:59 +01:00
protected:
// function pointer to callback function
void (*fpCallback) ( CVector<short>& psData, void* arg );
void* pCallbackArg;
// callback function call for derived classes
void Callback ( CVector<short>& psData )
{
(*fpCallback) ( psData, pCallbackArg );
}
2009-02-23 00:13:59 +01:00
// these functions should be overwritten by derived class for
// non callback based audio interfaces
virtual bool Read ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
virtual bool Write ( CVector<short>& psData ) { printf ( "no sound!" ); return false; }
void run();
bool bRun;
bool bIsCallbackAudioInterface;
2009-02-23 00:13:59 +01:00
CVector<short> vecsAudioSndCrdStereo;
2009-02-23 00:13:59 +01:00
};
#endif /* !defined ( SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_ ) */