1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 23:00:41 +00:00

audio/out, video/out: hide encoding VO/AO

mpv -ao help and mpv -vo help shouldn't show the encoding outputs (named
"lavc" on both cases). Also make it impossible to select these manually
when not encoding.
This commit is contained in:
wm4 2013-02-06 22:54:03 +01:00
parent 4628ea3c46
commit ae070a6f1e
6 changed files with 31 additions and 12 deletions

View File

@ -91,13 +91,14 @@ static const struct ao_driver * const audio_out_drivers[] = {
void list_audio_out(void) void list_audio_out(void)
{ {
int i=0;
mp_tmsg(MSGT_AO, MSGL_INFO, "Available audio output drivers:\n"); mp_tmsg(MSGT_AO, MSGL_INFO, "Available audio output drivers:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n"); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
while (audio_out_drivers[i]) { for (int i = 0; audio_out_drivers[i]; i++) {
const ao_info_t *info = audio_out_drivers[i++]->info; const ao_info_t *info = audio_out_drivers[i]->info;
mp_msg(MSGT_GLOBAL, MSGL_INFO, "\t%s\t%s\n", info->short_name, if (!audio_out_drivers[i]->encode) {
info->name); mp_msg(MSGT_GLOBAL, MSGL_INFO, "\t%s\t%s\n",
info->short_name, info->name);
}
} }
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n"); mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
} }
@ -110,6 +111,13 @@ struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input)
return r; return r;
} }
static bool ao_try_init(struct ao *ao, char *params)
{
if (ao->driver->encode != !!ao->encode_lavc_ctx)
return false;
return ao->driver->init(ao, params) >= 0;
}
void ao_init(struct ao *ao, char **ao_list) void ao_init(struct ao *ao, char **ao_list)
{ {
/* Caller adding child blocks is not supported as we may call /* Caller adding child blocks is not supported as we may call
@ -148,7 +156,7 @@ void ao_init(struct ao *ao, char **ao_list)
if (audio_out) { if (audio_out) {
// name matches, try it // name matches, try it
ao->driver = audio_out; ao->driver = audio_out;
if (audio_out->init(ao, params) >= 0) { if (ao_try_init(ao, params)) {
ao->driver = audio_out; ao->driver = audio_out;
ao->initialized = true; ao->initialized = true;
return; return;
@ -167,13 +175,14 @@ void ao_init(struct ao *ao, char **ao_list)
try_defaults: try_defaults:
mp_tmsg(MSGT_AO, MSGL_V, "Trying every known audio driver...\n"); mp_tmsg(MSGT_AO, MSGL_V, "Trying every known audio driver...\n");
ao->probing = false;
// now try the rest... // now try the rest...
for (int i = 0; audio_out_drivers[i]; i++) { for (int i = 0; audio_out_drivers[i]; i++) {
const struct ao_driver *audio_out = audio_out_drivers[i]; const struct ao_driver *audio_out = audio_out_drivers[i];
ao->driver = audio_out; ao->driver = audio_out;
ao->probing = true; ao->probing = true;
if (audio_out->init(ao, NULL) >= 0) { if (ao_try_init(ao, NULL)) {
ao->probing = false;
ao->initialized = true; ao->initialized = true;
ao->driver = audio_out; ao->driver = audio_out;
return; return;

View File

@ -75,6 +75,7 @@ struct ao;
struct ao_driver { struct ao_driver {
bool is_new; bool is_new;
bool encode;
const struct ao_info *info; const struct ao_info *info;
const struct ao_old_functions *old_functions; const struct ao_old_functions *old_functions;
int (*control)(struct ao *ao, enum aocontrol cmd, void *arg); int (*control)(struct ao *ao, enum aocontrol cmd, void *arg);

View File

@ -660,6 +660,7 @@ static int play(struct ao *ao, void *data, int len, int flags)
const struct ao_driver audio_out_lavc = { const struct ao_driver audio_out_lavc = {
.is_new = true, .is_new = true,
.encode = true,
.info = &(const struct ao_info) { .info = &(const struct ao_info) {
"audio encoding using libavcodec", "audio encoding using libavcodec",
"lavc", "lavc",

View File

@ -131,6 +131,8 @@ const struct vo_driver *video_out_drivers[] =
static int vo_preinit(struct vo *vo, char *arg) static int vo_preinit(struct vo *vo, char *arg)
{ {
if (vo->driver->encode != !!vo->encode_lavc_ctx)
return -1;
if (vo->driver->priv_size) { if (vo->driver->priv_size) {
vo->priv = talloc_zero_size(vo, vo->driver->priv_size); vo->priv = talloc_zero_size(vo, vo->driver->priv_size);
if (vo->driver->priv_defaults) if (vo->driver->priv_defaults)
@ -268,12 +270,14 @@ void vo_destroy(struct vo *vo)
void list_video_out(void) void list_video_out(void)
{ {
int i = 0;
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n"); mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n"); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
while (video_out_drivers[i]) { for (int i = 0; video_out_drivers[i]; i++) {
const vo_info_t *info = video_out_drivers[i++]->info; const vo_info_t *info = video_out_drivers[i]->info;
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name); if (!video_out_drivers[i]->encode) {
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n",
info->short_name, info->name);
}
} }
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n"); mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
} }

View File

@ -146,6 +146,9 @@ struct vo_driver {
// of pts values itself // of pts values itself
bool buffer_frames; bool buffer_frames;
// Encoding functionality, which can be invoked via --o only.
bool encode;
const vo_info_t *info; const vo_info_t *info;
/* /*
* Preinitializes driver (real INITIALIZATION) * Preinitializes driver (real INITIALIZATION)

View File

@ -514,6 +514,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
const struct vo_driver video_out_lavc = { const struct vo_driver video_out_lavc = {
.buffer_frames = false, .buffer_frames = false,
.encode = true,
.info = &(const struct vo_info_s){ .info = &(const struct vo_info_s){
"video encoding using libavcodec", "video encoding using libavcodec",
"lavc", "lavc",