summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/input.rst21
-rw-r--r--player/command.c32
2 files changed, 53 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 301d779850..269783c45b 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1334,6 +1334,27 @@ Property list
Note that you need to escape the ``\`` character, because the string is
processed for C escape sequences before passing it to the OSD code.
+``audio-device-list``
+ Return the list of discovered audio devices. This is mostly for use with
+ the client API, and reflects what ``--audio-device=help`` with the command
+ line player returns.
+
+ When querying the property with the client API using ``MPV_FORMAT_NODE``,
+ or with Lua ``mp.get_property_native``, this will return a mpv_node with
+ the following contents:
+
+ ::
+
+ MPV_FORMAT_NODE_ARRAY
+ MPV_FORMAT_NODE_MAP (for each device entry)
+ "name" MPV_FORMAT_STRING
+ "description" MPV_FORMAT_STRING
+
+ The ``name`` is what is to be passed to the ``--audio-device`` option (and
+ often a rather cryptic audio API-specific ID), while ``description`` is
+ human readable free form text. The description is an empty string if none
+ was received.
+
``options/<name>`` (RW)
Read-only access to value of option ``--<name>``. Most options can be
changed at runtime by writing to this property. Note that many options
diff --git a/player/command.c b/player/command.c
index 3a280e1353..ba223bb870 100644
--- a/player/command.c
+++ b/player/command.c
@@ -84,6 +84,8 @@ struct command_ctx {
// bitmap list can be manipulated without additional synchronization.
struct sub_bitmaps overlay_osd[2];
struct sub_bitmaps *overlay_osd_current;
+
+ struct ao_device_list *cached_ao_devices;
};
struct overlay {
@@ -1308,6 +1310,35 @@ static int mp_property_volrestore(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
+static int get_device_entry(int item, int action, void *arg, void *ctx)
+{
+ struct ao_device_list *list = ctx;
+ struct ao_device_desc *entry = &list->devices[item];
+
+ struct m_sub_property props[] = {
+ {"name", SUB_PROP_STR(entry->name)},
+ {"description", SUB_PROP_STR(entry->desc)},
+ {0}
+ };
+
+ return m_property_read_sub(props, action, arg);
+}
+
+static int mp_property_audio_devices(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ struct MPContext *mpctx = ctx;
+ struct command_ctx *cmd = mpctx->command_ctx;
+ if (!cmd->cached_ao_devices)
+ cmd->cached_ao_devices = ao_get_device_list(mpctx->global);
+ if (!cmd->cached_ao_devices)
+ return M_PROPERTY_ERROR;
+ talloc_steal(cmd, cmd->cached_ao_devices);
+
+ return m_property_read_list(action, arg, cmd->cached_ao_devices->num_devices,
+ get_device_entry, cmd->cached_ao_devices);
+}
+
/// Audio delay (RW)
static int mp_property_audio_delay(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -2794,6 +2825,7 @@ static const struct m_property mp_properties[] = {
{"aid", mp_property_audio},
{"balance", mp_property_balance},
{"volume-restore-data", mp_property_volrestore},
+ {"audio-device-list", mp_property_audio_devices},
// Video
{"fullscreen", mp_property_fullscreen},