mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
command: add audio-device property
Meant for changing the --audio-device at runtime.
This commit is contained in:
@@ -1395,6 +1395,19 @@ Property list
|
||||
human readable free form text. The description is an empty string if none
|
||||
was received.
|
||||
|
||||
``audio-device`` (RW)
|
||||
Set the audio device. This directly reads/writes the ``--audio-device``
|
||||
option, but on write accesses, the audio output will be scheduled for
|
||||
reloading.
|
||||
|
||||
Writing this property while no audio output is active will not automatically
|
||||
enable audio. (This is also true in the case when audio was disabled due to
|
||||
reinitialization failure after a previous write access to ``audio-device``.)
|
||||
|
||||
This property also doesn't tell you which audio device is actually in use.
|
||||
|
||||
How these details are handled may change in the future.
|
||||
|
||||
``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
|
||||
|
||||
@@ -1466,6 +1466,16 @@ static void reload_audio_output(struct MPContext *mpctx)
|
||||
reinit_audio_chain(mpctx);
|
||||
}
|
||||
|
||||
static int mp_property_audio_device(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
struct MPContext *mpctx = ctx;
|
||||
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
||||
if (action == M_PROPERTY_SET)
|
||||
reload_audio_output(mpctx);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int mp_property_audio_devices(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
@@ -3049,6 +3059,7 @@ static const struct m_property mp_properties[] = {
|
||||
{"aid", mp_property_audio},
|
||||
{"balance", mp_property_balance},
|
||||
{"volume-restore-data", mp_property_volrestore},
|
||||
{"audio-device", mp_property_audio_device},
|
||||
{"audio-device-list", mp_property_audio_devices},
|
||||
|
||||
// Video
|
||||
|
||||
Reference in New Issue
Block a user