diff options
-rw-r--r-- | audio/out/ao.c | 25 | ||||
-rw-r--r-- | audio/out/ao.h | 7 | ||||
-rw-r--r-- | options/options.c | 13 | ||||
-rw-r--r-- | options/options.h | 5 | ||||
-rw-r--r-- | player/command.c | 9 | ||||
-rw-r--r-- | player/main.c | 4 |
6 files changed, 44 insertions, 19 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c index b8337d5c16..e7af02276f 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -120,7 +120,7 @@ static bool get_desc(struct m_obj_desc *dst, int index) } // For the ao option -const struct m_obj_list ao_obj_list = { +static const struct m_obj_list ao_obj_list = { .get_desc = get_desc, .description = "audio outputs", .allow_unknown_entries = true, @@ -129,13 +129,30 @@ const struct m_obj_list ao_obj_list = { .use_global_options = true, }; +#define OPT_BASE_STRUCT struct ao_opts +const struct m_sub_options ao_conf = { + .opts = (const struct m_option[]) { + OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list, ), + OPT_STRING("audio-device", audio_device, UPDATE_AUDIO), + OPT_STRING("audio-client-name", audio_client_name, UPDATE_AUDIO), + OPT_DOUBLE("audio-buffer", audio_buffer, M_OPT_MIN | M_OPT_MAX, + .min = 0, .max = 10), + {0} + }, + .size = sizeof(OPT_BASE_STRUCT), + .defaults = &(const OPT_BASE_STRUCT){ + .audio_buffer = 0.2, + .audio_device = "auto", + .audio_client_name = "mpv", + }, +}; + static struct ao *ao_alloc(bool probing, struct mpv_global *global, void (*wakeup_cb)(void *ctx), void *wakeup_ctx, char *name) { assert(wakeup_cb); - struct MPOpts *opts = global->opts; struct mp_log *log = mp_log_new(NULL, global->log, "ao"); struct m_obj_desc desc; if (!m_obj_list_find(&desc, &ao_obj_list, bstr0(name))) { @@ -143,6 +160,7 @@ static struct ao *ao_alloc(bool probing, struct mpv_global *global, talloc_free(log); return NULL; }; + struct ao_opts *opts = mp_get_config_group(NULL, global, &ao_conf); struct ao *ao = talloc_ptrtype(NULL, ao); talloc_steal(ao, log); *ao = (struct ao) { @@ -155,6 +173,7 @@ static struct ao *ao_alloc(bool probing, struct mpv_global *global, .def_buffer = opts->audio_buffer, .client_name = talloc_strdup(ao, opts->audio_client_name), }; + talloc_free(opts); ao->priv = m_config_group_from_desc(ao, ao->log, global, &desc, name); if (!ao->priv) goto error; @@ -267,8 +286,8 @@ struct ao *ao_init_best(struct mpv_global *global, struct encode_lavc_context *encode_lavc_ctx, int samplerate, int format, struct mp_chmap channels) { - struct MPOpts *opts = global->opts; void *tmp = talloc_new(NULL); + struct ao_opts *opts = mp_get_config_group(tmp, global, &ao_conf); struct mp_log *log = mp_log_new(tmp, global->log, "ao"); struct ao *ao = NULL; struct m_obj_settings *ao_list = NULL; diff --git a/audio/out/ao.h b/audio/out/ao.h index 99a3d0fae0..d66391ef1d 100644 --- a/audio/out/ao.h +++ b/audio/out/ao.h @@ -83,6 +83,13 @@ struct mpv_global; struct input_ctx; struct encode_lavc_context; +struct ao_opts { + struct m_obj_settings *audio_driver_list; + char *audio_device; + char *audio_client_name; + double audio_buffer; +}; + struct ao *ao_init_best(struct mpv_global *global, int init_flags, void (*wakeup_cb)(void *ctx), void *wakeup_ctx, diff --git a/options/options.c b/options/options.c index bfaf374365..c9ed2f0008 100644 --- a/options/options.c +++ b/options/options.c @@ -78,7 +78,8 @@ extern const struct m_sub_options demux_conf; extern const struct m_obj_list vf_obj_list; extern const struct m_obj_list af_obj_list; extern const struct m_obj_list vo_obj_list; -extern const struct m_obj_list ao_obj_list; + +extern const struct m_sub_options ao_conf; extern const struct m_sub_options opengl_conf; extern const struct m_sub_options vulkan_conf; @@ -549,10 +550,8 @@ const m_option_t mp_opts[] = { OPT_FLAG("osd-bar", osd_bar_visible, UPDATE_OSD), //---------------------- libao/libvo options ------------------------ - OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list, ), - OPT_STRING("audio-device", audio_device, UPDATE_AUDIO), + OPT_SUBSTRUCT("", ao_opts, ao_conf, 0), OPT_FLAG("audio-exclusive", audio_exclusive, UPDATE_AUDIO), - OPT_STRING("audio-client-name", audio_client_name, UPDATE_AUDIO), OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0), OPT_FLAG("audio-stream-silence", audio_stream_silence, 0), OPT_FLOATRANGE("audio-wait-open", audio_wait_open, 0, 0, 60), @@ -577,8 +576,6 @@ const m_option_t mp_opts[] = { ({"no", 0}, {"yes", 1}, {"weak", -1})), - OPT_DOUBLE("audio-buffer", audio_buffer, M_OPT_MIN | M_OPT_MAX, - .min = 0, .max = 10), OPT_STRING("title", wintitle, 0), OPT_STRING("force-media-title", media_title, 0), @@ -879,16 +876,12 @@ const m_option_t mp_opts[] = { const struct MPOpts mp_default_opts = { .use_terminal = 1, .msg_color = 1, - .audio_driver_list = NULL, .audio_decoders = NULL, .video_decoders = NULL, .softvol_max = 130, .softvol_volume = 100, .softvol_mute = 0, .gapless_audio = -1, - .audio_buffer = 0.2, - .audio_device = "auto", - .audio_client_name = "mpv", .wintitle = "${?media-title:${media-title}}${!media-title:No file} - mpv", .stop_screensaver = 1, .cursor_autohide_delay = 1000, diff --git a/options/options.h b/options/options.h index b4c0f9e719..d376ad1cd6 100644 --- a/options/options.h +++ b/options/options.h @@ -144,10 +144,7 @@ typedef struct MPOpts { int auto_load_scripts; - struct m_obj_settings *audio_driver_list; - char *audio_device; int audio_exclusive; - char *audio_client_name; int ao_null_fallback; int audio_stream_silence; float audio_wait_open; @@ -160,9 +157,9 @@ typedef struct MPOpts { int softvol_mute; float softvol_max; int gapless_audio; - double audio_buffer; mp_vo_opts *vo; + struct ao_opts *ao_opts; char *wintitle; char *media_title; diff --git a/player/command.c b/player/command.c index e836b3ef21..7d52f2425c 100644 --- a/player/command.c +++ b/player/command.c @@ -2008,14 +2008,21 @@ static int mp_property_audio_device(void *ctx, struct m_property *prop, if (action == M_PROPERTY_PRINT) { create_hotplug(mpctx); + char *name = NULL; + if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &name) < 1) + name = NULL; + struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug); for (int n = 0; n < list->num_devices; n++) { struct ao_device_desc *dev = &list->devices[n]; - if (dev->name && strcmp(dev->name, mpctx->opts->audio_device) == 0) { + if (dev->name && name && strcmp(dev->name, name) == 0) { *(char **)arg = talloc_strdup(NULL, dev->desc ? dev->desc : "?"); + talloc_free(name); return M_PROPERTY_OK; } } + + talloc_free(name); } return mp_property_generic_option(mpctx, prop, action, arg); } diff --git a/player/main.c b/player/main.c index ec5cdd69b1..5870574844 100644 --- a/player/main.c +++ b/player/main.c @@ -222,7 +222,9 @@ static bool handle_help_options(struct MPContext *mpctx) MP_INFO(mpctx, "\n"); return true; } - if (opts->audio_device && strcmp(opts->audio_device, "help") == 0) { + if (opts->ao_opts->audio_device && + strcmp(opts->ao_opts->audio_device, "help") == 0) + { ao_print_devices(mpctx->global, log); return true; } |