diff options
author | wm4 <wm4@nowhere> | 2015-03-10 10:13:23 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-10 10:13:23 +0100 |
commit | fa75a7b6d7af4b6c68329e1acdaced38a71d0dd8 (patch) | |
tree | 1f790a62ca1f732b82c8ef2d8ade2aac2aa4273b /audio | |
parent | ee14da2988a543fe2d520ff63729edf9d3484907 (diff) |
ao_coreaudio: move some helpers to utils
Needed by ao_coreaudio_exclusive.c in the next commit.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_coreaudio.c | 16 | ||||
-rw-r--r-- | audio/out/ao_coreaudio_utils.c | 17 | ||||
-rw-r--r-- | audio/out/ao_coreaudio_utils.h | 3 |
3 files changed, 20 insertions, 16 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index 99f0572723..8c8970bc26 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -38,11 +38,6 @@ struct priv { bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout, struct mp_chmap *chmap); -static int64_t ca_frames_to_us(struct ao *ao, uint32_t frames) -{ - return frames / (float) ao->samplerate * 1e6; -} - static int64_t ca_get_hardware_latency(struct ao *ao) { struct priv *p = ao->priv; @@ -73,17 +68,6 @@ coreaudio_error: return 0; } -static int64_t ca_get_latency(const AudioTimeStamp *ts) -{ - uint64_t out = AudioConvertHostTimeToNanos(ts->mHostTime); - uint64_t now = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); - - if (now > out) - return 0; - - return (out - now) * 1e-3; -} - static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags, const AudioTimeStamp *ts, UInt32 bus, UInt32 frames, AudioBufferList *buffer_list) diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index 90ebdbc752..64d98e5ece 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -22,6 +22,8 @@ * on CoreAudio but not the AUHAL (such as using AudioQueue services). */ +#include <CoreAudio/HostTime.h> + #include "audio/out/ao_coreaudio_utils.h" #include "audio/out/ao_coreaudio_properties.h" #include "osdep/timer.h" @@ -214,3 +216,18 @@ void ca_print_asbd(struct ao *ao, const char *description, talloc_free(format); } +int64_t ca_frames_to_us(struct ao *ao, uint32_t frames) +{ + return frames / (float) ao->samplerate * 1e6; +} + +int64_t ca_get_latency(const AudioTimeStamp *ts) +{ + uint64_t out = AudioConvertHostTimeToNanos(ts->mHostTime); + uint64_t now = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); + + if (now > out) + return 0; + + return (out - now) * 1e-3; +} diff --git a/audio/out/ao_coreaudio_utils.h b/audio/out/ao_coreaudio_utils.h index 17c60b93be..bd233e4b22 100644 --- a/audio/out/ao_coreaudio_utils.h +++ b/audio/out/ao_coreaudio_utils.h @@ -56,4 +56,7 @@ void ca_fill_asbd(struct ao *ao, AudioStreamBasicDescription *asbd); void ca_print_asbd(struct ao *ao, const char *description, const AudioStreamBasicDescription *asbd); +int64_t ca_frames_to_us(struct ao *ao, uint32_t frames); +int64_t ca_get_latency(const AudioTimeStamp *ts); + #endif /* MPV_COREAUDIO_UTILS_H */ |