From a3be14683a33211e3e07094246bb3342fc789763 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Feb 2015 23:01:11 +0100 Subject: command: add property returning detected audio device This can be useful to adjust some other audio related properties at runtime depending on the audio device being used. --- audio/out/ao.c | 5 +++++ audio/out/ao.h | 1 + audio/out/ao_coreaudio.c | 2 ++ audio/out/internal.h | 3 +++ 4 files changed, 11 insertions(+) (limited to 'audio/out') diff --git a/audio/out/ao.c b/audio/out/ao.c index f77ae4c24a..dbdcf272cb 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -440,6 +440,11 @@ bool ao_untimed(struct ao *ao) return ao->untimed; } +const char *ao_get_detected_device(struct ao *ao) +{ + return ao->detected_device; +} + struct ao_device_list *ao_get_device_list(struct mpv_global *global) { struct ao_device_list *list = talloc_zero(NULL, struct ao_device_list); diff --git a/audio/out/ao.h b/audio/out/ao.h index f1c922ae69..dbbed24873 100644 --- a/audio/out/ao.h +++ b/audio/out/ao.h @@ -79,6 +79,7 @@ void ao_uninit(struct ao *ao); void ao_get_format(struct ao *ao, struct mp_audio *format); const char *ao_get_name(struct ao *ao); const char *ao_get_description(struct ao *ao); +const char *ao_get_detected_device(struct ao *ao); bool ao_untimed(struct ao *ao); int ao_play(struct ao *ao, void **data, int samples, int flags); int ao_control(struct ao *ao, enum aocontrol cmd, void *arg); diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index 0c7f769e72..590549bd1a 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -156,6 +156,8 @@ static int init(struct ao *ao) OSStatus err = ca_select_device(ao, ao->device, &p->device); CHECK_CA_ERROR("failed to select device"); + ao->detected_device = talloc_asprintf(ao, "%d", p->device); + if (!init_chmap(ao)) goto coreaudio_error; diff --git a/audio/out/internal.h b/audio/out/internal.h index 4d18adef78..9414208923 100644 --- a/audio/out/internal.h +++ b/audio/out/internal.h @@ -50,6 +50,9 @@ struct ao { // default device should be used, this is set to NULL. char *device; + // Device actually chosen by the AO + char *detected_device; + // Application name to report to the audio API. char *client_name; -- cgit v1.2.3