2009-02-23 00:13:59 +01:00
|
|
|
/******************************************************************************\
|
2011-02-22 19:56:52 +01:00
|
|
|
* Copyright (c) 2004-2011
|
2009-02-23 00:13:59 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
{
|
2009-03-12 12:56:15 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-02-23 00:13:59 +01:00
|
|
|
public:
|
2009-03-01 12:17:35 +01:00
|
|
|
CSoundBase ( const bool bNewIsCallbackAudioInterface,
|
2009-07-24 16:31:25 +02:00
|
|
|
void (*fpNewProcessCallback) ( CVector<int16_t>& psData, void* pParg ),
|
2009-03-10 18:33:12 +01:00
|
|
|
void* pParg ) : fpProcessCallback ( fpNewProcessCallback ),
|
|
|
|
pProcessCallbackArg ( pParg ), bRun ( false ),
|
2009-03-01 12:17:35 +01:00
|
|
|
bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ) {}
|
2009-02-23 00:13:59 +01:00
|
|
|
|
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();
|
2010-03-20 13:11:11 +01:00
|
|
|
|
2010-03-20 13:57:16 +01:00
|
|
|
// dummy implementations in base class
|
2010-03-20 13:11:11 +01:00
|
|
|
virtual int GetNumDev() { return 1; }
|
|
|
|
virtual QString GetDeviceName ( const int ) { return "Default"; }
|
|
|
|
virtual QString SetDev ( const int ) { return ""; }
|
|
|
|
virtual int GetDev() { return 0; }
|
|
|
|
|
2010-03-20 13:57:16 +01:00
|
|
|
virtual int GetNumInputChannels() { return 2; }
|
|
|
|
virtual QString GetInputChannelName ( const int ) { return "Default"; }
|
|
|
|
virtual void SetLeftInputChannel ( const int ) {}
|
|
|
|
virtual void SetRightInputChannel ( const int ) {}
|
|
|
|
virtual int GetLeftInputChannel() { return 0; }
|
|
|
|
virtual int GetRightInputChannel() { return 1; }
|
2009-02-23 00:13:59 +01:00
|
|
|
|
2010-03-20 13:57:16 +01:00
|
|
|
virtual int GetNumOutputChannels() { return 2; }
|
|
|
|
virtual QString GetOutputChannelName ( const int ) { return "Default"; }
|
|
|
|
virtual void SetLeftOutputChannel ( const int ) {}
|
|
|
|
virtual void SetRightOutputChannel ( const int ) {}
|
|
|
|
virtual int GetLeftOutputChannel() { return 0; }
|
|
|
|
virtual int GetRightOutputChannel() { return 1; }
|
|
|
|
|
|
|
|
virtual void OpenDriverSetup() {}
|
|
|
|
|
|
|
|
bool IsRunning() const { return bRun; }
|
2009-03-05 10:30:58 +01:00
|
|
|
|
2009-03-12 12:56:15 +01:00
|
|
|
// TODO this should be protected but since it is used
|
|
|
|
// in a callback function it has to be public -> better solution
|
|
|
|
void EmitReinitRequestSignal() { emit ReinitRequest(); }
|
|
|
|
|
2009-02-23 00:13:59 +01:00
|
|
|
protected:
|
|
|
|
// function pointer to callback function
|
2009-07-24 16:31:25 +02:00
|
|
|
void (*fpProcessCallback) ( CVector<int16_t>& psData, void* arg );
|
2009-03-10 18:33:12 +01:00
|
|
|
void* pProcessCallbackArg;
|
2009-02-23 00:13:59 +01:00
|
|
|
|
2009-03-01 12:17:35 +01:00
|
|
|
// callback function call for derived classes
|
2009-07-24 16:31:25 +02:00
|
|
|
void ProcessCallback ( CVector<int16_t>& psData )
|
2009-03-01 12:17:35 +01:00
|
|
|
{
|
2009-03-10 18:33:12 +01:00
|
|
|
(*fpProcessCallback) ( psData, pProcessCallbackArg );
|
2009-03-01 12:17:35 +01:00
|
|
|
}
|
|
|
|
|
2009-02-23 00:13:59 +01:00
|
|
|
// these functions should be overwritten by derived class for
|
|
|
|
// non callback based audio interfaces
|
2010-02-18 22:06:22 +01:00
|
|
|
virtual bool Read ( CVector<int16_t>& ) { printf ( "no sound!" ); return false; }
|
|
|
|
virtual bool Write ( CVector<int16_t>& ) { printf ( "no sound!" ); return false; }
|
2009-02-23 00:13:59 +01:00
|
|
|
|
|
|
|
void run();
|
|
|
|
bool bRun;
|
2009-03-01 12:17:35 +01:00
|
|
|
bool bIsCallbackAudioInterface;
|
2009-02-23 00:13:59 +01:00
|
|
|
|
2009-07-24 16:31:25 +02:00
|
|
|
CVector<int16_t> vecsAudioSndCrdStereo;
|
2009-03-12 12:56:15 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void ReinitRequest();
|
2009-02-23 00:13:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined ( SOUNDBASE_HOIHGEH8_3_4344456456345634565KJIUHF1912__INCLUDED_ ) */
|