libsoundio/src/coreaudio.h

67 lines
1.7 KiB
C
Raw Normal View History

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
*/
#ifndef SOUNDIO_COREAUDIO_H
#define SOUNDIO_COREAUDIO_H
2015-08-01 01:52:51 +00:00
#include "soundio_internal.h"
#include "os.h"
#include "list.h"
#include "atomics.h"
2015-08-04 05:27:09 +00:00
#include <CoreAudio/CoreAudio.h>
#include <AudioUnit/AudioUnit.h>
2015-08-01 01:52:51 +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;
UInt32 latency_frames;
2015-08-04 05:27:09 +00:00
};
2015-08-01 01:52:51 +00:00
SOUNDIO_MAKE_LIST_STRUCT(AudioDeviceID, SoundIoListAudioDeviceID, SOUNDIO_LIST_STATIC)
2015-08-01 01:52:51 +00:00
struct SoundIoCoreAudio {
struct SoundIoOsMutex *mutex;
struct SoundIoOsCond *cond;
struct SoundIoOsThread *thread;
struct SoundIoAtomicFlag abort_flag;
// this one is ready to be read with flush_events. protected by mutex
struct SoundIoDevicesInfo *ready_devices_info;
struct SoundIoAtomicBool have_devices_flag;
struct SoundIoOsCond *have_devices_cond;
struct SoundIoOsCond *scan_devices_cond;
struct SoundIoListAudioDeviceID registered_listeners;
struct SoundIoAtomicBool device_scan_queued;
struct SoundIoAtomicBool service_restarted;
int shutdown_err;
bool emitted_shutdown_cb;
2015-08-01 01:52:51 +00:00
};
struct SoundIoOutStreamCoreAudio {
AudioComponentInstance instance;
2015-08-04 05:27:09 +00:00
AudioBufferList *io_data;
int buffer_index;
int frames_left;
int write_frame_count;
double hardware_latency;
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
2015-08-01 01:52:51 +00:00
};
struct SoundIoInStreamCoreAudio {
AudioComponentInstance instance;
2015-08-08 18:45:21 +00:00
AudioBufferList *buffer_list;
int frames_left;
double hardware_latency;
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
2015-08-01 01:52:51 +00:00
};
#endif