Skip to content

Commit

Permalink
ao/avfoundation: optimise preprocessors for included coreaudio code
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors authored and Akemi committed Apr 19, 2024
1 parent 578b9da commit e7b0d6b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion audio/out/ao_coreaudio_chmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ AudioChannelLabel mp_speaker_id_to_ca_label(int speaker_id)
return -1; // kAudioChannelLabel_Unknown
}

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
void ca_log_layout(struct ao *ao, int l, AudioChannelLayout *layout)
{
if (!mp_msg_test(ao->log, l))
Expand Down
7 changes: 1 addition & 6 deletions audio/out/ao_coreaudio_chmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
#include "config.h"
#include <AudioToolbox/AudioToolbox.h>

#if HAVE_AVFOUNDATION
#undef HAVE_COREAUDIO
#define HAVE_COREAUDIO 1
#endif

struct mp_chmap;

int ca_label_to_mp_speaker_id(AudioChannelLabel label);
AudioChannelLabel mp_speaker_id_to_ca_label(int speaker_id);

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
AudioChannelLayout *ca_find_standard_layout(void *talloc_ctx, AudioChannelLayout *l);
void ca_log_layout(struct ao *ao, int l, AudioChannelLayout *layout);
bool ca_init_chmap(struct ao *ao, AudioDeviceID device);
Expand Down
5 changes: 0 additions & 5 deletions audio/out/ao_coreaudio_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@

#include "internal.h"

#if HAVE_AVFOUNDATION
#undef HAVE_COREAUDIO
#define HAVE_COREAUDIO 1
#endif

// CoreAudio names are way too verbose
#define ca_sel AudioObjectPropertySelector
#define ca_scope AudioObjectPropertyScope
Expand Down
8 changes: 4 additions & 4 deletions audio/out/ao_coreaudio_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
#include "osdep/semaphore.h"
#include "audio/format.h"

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
#include "audio/out/ao_coreaudio_properties.h"
#include <CoreAudio/HostTime.h>
#else
#include <mach/mach_time.h>
#endif

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
static bool ca_is_output_device(struct ao *ao, AudioDeviceID dev)
{
size_t n_buffers;
Expand Down Expand Up @@ -300,7 +300,7 @@ int64_t ca_frames_to_ns(struct ao *ao, uint32_t frames)

int64_t ca_get_latency(const AudioTimeStamp *ts)
{
#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
uint64_t out = AudioConvertHostTimeToNanos(ts->mHostTime);
uint64_t now = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime());

Expand All @@ -323,7 +323,7 @@ int64_t ca_get_latency(const AudioTimeStamp *ts)
#endif
}

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
bool ca_stream_supports_compressed(struct ao *ao, AudioStreamID stream)
{
AudioStreamRangedDescription *formats = NULL;
Expand Down
9 changes: 2 additions & 7 deletions audio/out/ao_coreaudio_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#include "internal.h"
#include "osdep/utils-mac.h"

#if HAVE_AVFOUNDATION
#undef HAVE_COREAUDIO
#define HAVE_COREAUDIO 1
#endif

bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);

#define CHECK_CA_ERROR_L(label, message) \
Expand All @@ -52,7 +47,7 @@ bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
} while (0)

void ca_get_device_list(struct ao *ao, struct ao_device_list *list);
#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
OSStatus ca_select_device(struct ao *ao, char* name, AudioDeviceID *device);
#endif

Expand All @@ -70,7 +65,7 @@ bool ca_asbd_is_better(AudioStreamBasicDescription *req,
int64_t ca_frames_to_ns(struct ao *ao, uint32_t frames);
int64_t ca_get_latency(const AudioTimeStamp *ts);

#if HAVE_COREAUDIO
#if HAVE_COREAUDIO || HAVE_AVFOUNDATION
bool ca_stream_supports_compressed(struct ao *ao, AudioStreamID stream);
OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid);
OSStatus ca_unlock_device(AudioDeviceID device, pid_t *pid);
Expand Down

0 comments on commit e7b0d6b

Please sign in to comment.