Ring Daemon 16.0.0
Loading...
Searching...
No Matches
ios/corelayer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef CORE_LAYER_H_
19#define CORE_LAYER_H_
20
21#include "audio/audiolayer.h"
22#include <AudioToolbox/AudioToolbox.h>
23
24#define checkErr(err) \
25 if (err) { \
26 JAMI_ERR("CoreAudio Error: %ld", static_cast<long>(err)); \
27 }
28
34namespace jami {
35
36class RingBuffer;
37
38class CoreLayer : public AudioLayer
39{
40public:
43
48 virtual std::vector<std::string> getCaptureDeviceList() const;
49 virtual std::vector<std::string> getPlaybackDeviceList() const;
50
51 virtual int getAudioDeviceIndex(const std::string& name, AudioDeviceType type) const;
52 virtual std::string getAudioDeviceName(int index, AudioDeviceType type) const;
53
58 virtual int getIndexCapture() const { return indexIn_; }
59
64 virtual int getIndexPlayback() const { return indexOut_; }
65
70 virtual int getIndexRingtone() const { return indexRing_; }
71
79
81
89
91
98
99private:
101
102 void initAudioFormat();
103
104 static OSStatus outputCallback(void* inRefCon,
110
116
117 static OSStatus inputCallback(void* inRefCon,
123
129
130 virtual void updatePreference(AudioPreference& pref, int index, AudioDeviceType type);
131
135 int indexIn_;
136
140 int indexOut_;
141
145 int indexRing_;
146
147 AudioUnit ioUnit_;
148
149 Float64 inSampleRate_;
150 UInt32 inChannelsPerFrame_;
151 Float64 outSampleRate_;
152 UInt32 outChannelsPerFrame_;
153
154 std::condition_variable readyCv_ {};
155 dispatch_queue_t audioConfigurationQueue;
156};
157
158} // namespace jami
159
160#endif // CORE_LAYER_H_
Main sound class.
virtual int getAudioDeviceIndex(const std::string &name, AudioDeviceType type) const
virtual std::vector< std::string > getCaptureDeviceList() const
Scan the sound card available on the system.
void setupInputBus()
void destroyAudioLayer()
virtual std::vector< std::string > getPlaybackDeviceList() const
virtual int getIndexCapture() const
Get the index of the audio card for capture.
virtual std::string getAudioDeviceName(int index, AudioDeviceType type) const
int initAudioStreams(AudioUnit *audioUnit)
virtual void stopStream(AudioDeviceType stream=AudioDeviceType::ALL)
Stop the playback and capture streams.
virtual int getIndexPlayback() const
Get the index of the audio card for playback.
virtual void startStream(AudioDeviceType stream=AudioDeviceType::ALL)
Start the capture stream and prepare the playback stream.
virtual int getIndexRingtone() const
Get the index of the audio card for ringtone (could be differnet from playback)
void setupOutputBus()
CoreLayer(const AudioPreference &pref)
bool initAudioLayerIO(AudioDeviceType stream)
Configure the AudioUnit.
void bindCallbacks()
void emitSignal(Args... args)
Definition ring_signal.h:64
AudioDeviceType
Definition audiolayer.h:58
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30