1 /// Translated from C to D
2 module soundio.coreaudio;
3 
4 extern(C): @nogc: nothrow: __gshared:
5 
6 import soundio.soundio_internal;
7 import soundio.os;
8 import soundio.list;
9 import soundio.atomics;
10 
11 import coreaudio;
12 import audiounit;
13 
14 package struct SoundIoDeviceCoreAudio {
15     AudioDeviceID device_id;
16     UInt32 latency_frames;
17 }
18 
19 alias SoundIoListAudioDeviceID = SOUNDIO_LIST!AudioDeviceID; // static
20 
21 package struct SoundIoCoreAudio {
22     SoundIoOsMutex* mutex;
23     SoundIoOsCond* cond;
24     SoundIoOsThread* thread;
25     SoundIoAtomicFlag abort_flag;
26 
27     // this one is ready to be read with flush_events. protected by mutex
28     SoundIoDevicesInfo* ready_devices_info;
29     SoundIoAtomicBool have_devices_flag;
30     SoundIoOsCond* have_devices_cond;
31     SoundIoOsCond* scan_devices_cond;
32     SoundIoListAudioDeviceID registered_listeners;
33 
34     SoundIoAtomicBool device_scan_queued;
35     SoundIoAtomicBool service_restarted;
36     int shutdown_err;
37     bool emitted_shutdown_cb;
38 }
39 
40 package struct SoundIoOutStreamCoreAudio {
41     AudioComponentInstance instance;
42     AudioBufferList* io_data;
43     int buffer_index;
44     int frames_left;
45     int write_frame_count;
46     double hardware_latency;
47     float volume;
48     SoundIoChannelArea[SOUNDIO_MAX_CHANNELS] areas;
49 }
50 
51 package struct SoundIoInStreamCoreAudio {
52     AudioComponentInstance instance;
53     AudioBufferList* buffer_list;
54     int frames_left;
55     double hardware_latency;
56     SoundIoChannelArea[SOUNDIO_MAX_CHANNELS] areas;
57 }