1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-02 17:51:06 +01:00
libtgvoip/os/darwin/AudioUnitIO.h

57 lines
1.8 KiB
C
Raw Normal View History

2017-02-02 17:24:40 +01:00
//
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#ifndef LIBTGVOIP_AUDIOUNITIO_H
#define LIBTGVOIP_AUDIOUNITIO_H
#include <AudioUnit/AudioUnit.h>
2017-03-30 16:06:59 +02:00
#include "../../threading.h"
2017-02-02 17:24:40 +01:00
class CAudioInputAudioUnit;
class CAudioOutputAudioUnit;
class CAudioUnitIO{
public:
CAudioUnitIO();
~CAudioUnitIO();
void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
void AttachInput(CAudioInputAudioUnit* i);
void AttachOutput(CAudioOutputAudioUnit* o);
void DetachInput();
void DetachOutput();
void EnableInput(bool enabled);
void EnableOutput(bool enabled);
static CAudioUnitIO* Get();
static void Release();
2017-03-30 16:06:59 +02:00
static void* StartFakeIOThread(void* arg);
static void AudioSessionAcquired();
2017-02-02 17:24:40 +01:00
private:
static OSStatus BufferCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData);
void BufferCallback(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 bus, UInt32 numFrames, AudioBufferList* ioData);
2017-03-30 16:06:59 +02:00
void RunFakeIOThread();
void Init();
void ActuallyConfigure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
void ProcessAudioSessionAcquired();
2017-02-02 17:24:40 +01:00
AudioComponentInstance unit;
CAudioInputAudioUnit* input;
CAudioOutputAudioUnit* output;
AudioBufferList inBufferList;
bool configured;
bool inputEnabled;
bool outputEnabled;
2017-03-30 16:06:59 +02:00
bool runFakeIO;
uint32_t cfgSampleRate;
uint32_t cfgBitsPerSample;
uint32_t cfgChannels;
tgvoip_thread_t fakeIOThread;
2017-02-02 17:24:40 +01:00
static int refCount;
static CAudioUnitIO* sharedInstance;
2017-03-30 16:06:59 +02:00
static bool haveAudioSession;
2017-02-02 17:24:40 +01:00
};
#endif /* LIBTGVOIP_AUDIOUNITIO_H */