jamulus/mac/sound.h

124 lines
5.1 KiB
C
Raw Normal View History

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_
#include <CoreAudio/CoreAudio.h>
#include <CoreMIDI/CoreMIDI.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,
const int iCtrlMIDIChannel );
2014-01-05 17:52:38 +01:00
virtual int Init ( const int iNewPrefMonoBufferSize );
virtual void Start();
virtual void Stop();
// 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;
AudioDeviceID CurrentAudioInputDeviceID;
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 );
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 );
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
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
static void callbackMIDI ( const MIDIPacketList* pktlist,
void* refCon,
void* );
AudioDeviceID audioInputDevice[MAX_NUMBER_SOUND_CARDS];
AudioDeviceID audioOutputDevice[MAX_NUMBER_SOUND_CARDS];
AudioDeviceIOProcID audioInputProcID;
AudioDeviceIOProcID audioOutputProcID;
2014-01-05 17:52:38 +01:00
MIDIPortRef midiInPortRef;
QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS];
QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS];
QMutex Mutex;
2014-01-05 17:52:38 +01:00
};
#endif // !defined(_SOUND_H__9518A621345F78_363456876UZGSDF82CF549__INCLUDED_)