2015-08-01 01:52:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Andrew Kelley
|
|
|
|
*
|
|
|
|
* This file is part of libsoundio, which is MIT licensed.
|
|
|
|
* See http://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
#ifndef SOUNDIO_COREAUDIO_H
|
|
|
|
#define SOUNDIO_COREAUDIO_H
|
2015-08-01 01:52:51 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
#include "soundio_internal.h"
|
2015-08-20 21:48:19 +00:00
|
|
|
#include "os.h"
|
2015-11-01 22:18:37 +00:00
|
|
|
#include "list.h"
|
|
|
|
#include "atomics.h"
|
2015-08-01 20:00:46 +00:00
|
|
|
|
2015-08-04 05:27:09 +00:00
|
|
|
#include <CoreAudio/CoreAudio.h>
|
|
|
|
#include <AudioUnit/AudioUnit.h>
|
2015-08-01 01:52:51 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoPrivate;
|
2015-08-01 01:52:51 +00:00
|
|
|
int soundio_coreaudio_init(struct SoundIoPrivate *si);
|
|
|
|
|
2015-08-04 05:27:09 +00:00
|
|
|
struct SoundIoDeviceCoreAudio {
|
|
|
|
AudioDeviceID device_id;
|
2015-09-03 17:47:38 +00:00
|
|
|
UInt32 latency_frames;
|
2015-08-04 05:27:09 +00:00
|
|
|
};
|
2015-08-01 01:52:51 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
SOUNDIO_MAKE_LIST_STRUCT(AudioDeviceID, SoundIoListAudioDeviceID, SOUNDIO_LIST_STATIC)
|
|
|
|
|
2015-08-01 01:52:51 +00:00
|
|
|
struct SoundIoCoreAudio {
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoOsMutex *mutex;
|
|
|
|
struct SoundIoOsCond *cond;
|
2015-08-01 20:00:46 +00:00
|
|
|
struct SoundIoOsThread *thread;
|
2015-12-05 13:25:44 +00:00
|
|
|
struct SoundIoAtomicFlag abort_flag;
|
2015-08-01 20:00:46 +00:00
|
|
|
|
|
|
|
// this one is ready to be read with flush_events. protected by mutex
|
|
|
|
struct SoundIoDevicesInfo *ready_devices_info;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoAtomicBool have_devices_flag;
|
|
|
|
struct SoundIoOsCond *have_devices_cond;
|
|
|
|
struct SoundIoOsCond *scan_devices_cond;
|
|
|
|
struct SoundIoListAudioDeviceID registered_listeners;
|
2015-08-01 20:00:46 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoAtomicBool device_scan_queued;
|
|
|
|
struct SoundIoAtomicBool service_restarted;
|
2015-08-01 20:00:46 +00:00
|
|
|
int shutdown_err;
|
|
|
|
bool emitted_shutdown_cb;
|
2015-08-01 01:52:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundIoOutStreamCoreAudio {
|
2015-08-07 22:28:22 +00:00
|
|
|
AudioComponentInstance instance;
|
2015-08-04 05:27:09 +00:00
|
|
|
AudioBufferList *io_data;
|
|
|
|
int buffer_index;
|
2015-08-05 04:57:46 +00:00
|
|
|
int frames_left;
|
|
|
|
int write_frame_count;
|
2015-09-03 17:47:38 +00:00
|
|
|
double hardware_latency;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
2015-08-01 01:52:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundIoInStreamCoreAudio {
|
2015-08-07 22:28:22 +00:00
|
|
|
AudioComponentInstance instance;
|
2015-08-08 18:45:21 +00:00
|
|
|
AudioBufferList *buffer_list;
|
2015-08-07 22:28:22 +00:00
|
|
|
int frames_left;
|
2015-09-03 17:47:38 +00:00
|
|
|
double hardware_latency;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
2015-08-01 01:52:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|