2014-01-05 17:52:38 +01:00
|
|
|
/******************************************************************************\
|
2018-03-09 22:13:02 +01:00
|
|
|
* Copyright (c) 2004-2018
|
2014-01-05 17:52:38 +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(_SOUND_H__9518A621345F78_363456876UZGSDF82CF549__INCLUDED_)
|
|
|
|
#define _SOUND_H__9518A621345F78_363456876UZGSDF82CF549__INCLUDED_
|
|
|
|
|
2015-11-17 18:42:28 +01:00
|
|
|
#include <CoreAudio/CoreAudio.h>
|
2014-01-05 17:52:38 +01:00
|
|
|
#include <QMutex>
|
|
|
|
#include "soundbase.h"
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CSound : public CSoundBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ), void* arg );
|
|
|
|
|
|
|
|
virtual int Init ( const int iNewPrefMonoBufferSize );
|
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
|
|
|
|
2015-11-19 20:36:47 +01:00
|
|
|
// channel selection
|
|
|
|
virtual int GetNumInputChannels() { return iNumInChan; }
|
|
|
|
virtual QString GetInputChannelName ( const int iDiD ) { return sChannelNamesInput[iDiD]; }
|
|
|
|
virtual void SetLeftInputChannel ( const int iNewChan );
|
|
|
|
virtual void SetRightInputChannel ( const int iNewChan );
|
|
|
|
virtual int GetLeftInputChannel() { return iSelInputLeftChannel; }
|
|
|
|
virtual int GetRightInputChannel() { return iSelInputRightChannel; }
|
|
|
|
|
|
|
|
virtual int GetNumOutputChannels() { return iNumOutChan; }
|
|
|
|
virtual QString GetOutputChannelName ( const int iDiD ) { return sChannelNamesOutput[iDiD]; }
|
|
|
|
virtual void SetLeftOutputChannel ( const int iNewChan );
|
|
|
|
virtual void SetRightOutputChannel ( const int iNewChan );
|
|
|
|
virtual int GetLeftOutputChannel() { return iSelOutputLeftChannel; }
|
|
|
|
virtual int GetRightOutputChannel() { return iSelOutputRightChannel; }
|
|
|
|
|
2014-01-05 17:52:38 +01:00
|
|
|
// these variables should be protected but cannot since we want
|
|
|
|
// to access them from the callback function
|
|
|
|
CVector<short> vecsTmpAudioSndCrdStereo;
|
|
|
|
int iCoreAudioBufferSizeMono;
|
|
|
|
int iCoreAudioBufferSizeStereo;
|
2015-11-15 20:21:24 +01:00
|
|
|
AudioDeviceID CurrentAudioInputDeviceID;
|
2015-11-19 20:36:47 +01:00
|
|
|
AudioDeviceID CurrentAudioOutputDeviceID;
|
|
|
|
int iNumInChan;
|
|
|
|
int iNumOutChan;
|
|
|
|
int iSelInputLeftChannel;
|
|
|
|
int iSelInputRightChannel;
|
|
|
|
int iSelOutputLeftChannel;
|
|
|
|
int iSelOutputRightChannel;
|
2014-01-05 17:52:38 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual QString LoadAndInitializeDriver ( int iIdx );
|
|
|
|
|
2015-11-15 20:21:24 +01:00
|
|
|
QString CheckDeviceCapabilities ( const int iDriverIdx );
|
2014-01-05 17:52:38 +01:00
|
|
|
|
|
|
|
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID,
|
|
|
|
const bool bIsInput,
|
|
|
|
UInt32 iPrefBufferSize );
|
|
|
|
|
|
|
|
void GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
|
|
|
|
QString& strDeviceName,
|
|
|
|
bool& bIsInput,
|
|
|
|
bool& bIsOutput );
|
|
|
|
|
2015-11-19 20:36:47 +01:00
|
|
|
bool ConvertCFStringToQString ( const CFStringRef stringRef, QString& sOut );
|
|
|
|
|
2014-01-05 17:52:38 +01:00
|
|
|
// callbacks
|
|
|
|
static OSStatus deviceNotification ( AudioDeviceID,
|
|
|
|
UInt32,
|
2015-11-13 23:27:25 +01:00
|
|
|
const AudioObjectPropertyAddress* inAddresses,
|
|
|
|
void* inRefCon );
|
2014-01-05 17:52:38 +01:00
|
|
|
|
2015-11-15 20:21:24 +01:00
|
|
|
static OSStatus callbackIO ( AudioDeviceID inDevice,
|
|
|
|
const AudioTimeStamp*,
|
|
|
|
const AudioBufferList* inInputData,
|
|
|
|
const AudioTimeStamp*,
|
|
|
|
AudioBufferList* outOutputData,
|
|
|
|
const AudioTimeStamp*,
|
|
|
|
void* inRefCon );
|
2014-01-05 17:52:38 +01:00
|
|
|
|
2015-11-17 18:42:28 +01:00
|
|
|
AudioDeviceID audioInputDevice[MAX_NUMBER_SOUND_CARDS];
|
|
|
|
AudioDeviceID audioOutputDevice[MAX_NUMBER_SOUND_CARDS];
|
|
|
|
AudioDeviceIOProcID audioInputProcID;
|
|
|
|
AudioDeviceIOProcID audioOutputProcID;
|
2014-01-05 17:52:38 +01:00
|
|
|
|
2015-11-19 20:36:47 +01:00
|
|
|
QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS];
|
|
|
|
QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS];
|
|
|
|
|
2015-11-17 18:42:28 +01:00
|
|
|
QMutex Mutex;
|
2014-01-05 17:52:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // !defined(_SOUND_H__9518A621345F78_363456876UZGSDF82CF549__INCLUDED_)
|