summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_lavc.c23
-rw-r--r--audio/decode/ad_spdif.c60
-rw-r--r--audio/decode/dec_audio.c20
-rw-r--r--audio/decode/dec_audio.h3
-rw-r--r--audio/filter/af_lavcac3enc.c16
-rw-r--r--audio/filter/af_lavrresample.c5
-rw-r--r--audio/out/ao.c23
-rw-r--r--audio/out/ao_alsa.c20
-rw-r--r--audio/out/ao_audiounit.m3
-rw-r--r--audio/out/ao_coreaudio.c9
-rw-r--r--audio/out/ao_jack.c8
-rw-r--r--audio/out/ao_lavc.c23
-rw-r--r--audio/out/ao_null.c2
-rw-r--r--audio/out/ao_openal.c2
-rw-r--r--audio/out/ao_opensles.c2
-rw-r--r--audio/out/ao_oss.c2
-rw-r--r--audio/out/ao_pcm.c2
-rw-r--r--audio/out/ao_pulse.c2
-rw-r--r--audio/out/ao_rsound.c2
-rw-r--r--audio/out/ao_sdl.c2
-rw-r--r--audio/out/ao_sndio.c2
-rw-r--r--audio/out/ao_wasapi.c7
-rw-r--r--audio/out/ao_wasapi.h6
-rw-r--r--audio/out/ao_wasapi_utils.c24
-rw-r--r--audio/out/internal.h2
-rw-r--r--audio/out/pull.c6
-rw-r--r--audio/out/push.c46
27 files changed, 129 insertions, 193 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index e28558414d..c4d3a2ae7b 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -100,7 +100,6 @@ static int init(struct dec_audio *da, const char *decoder)
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = av_frame_alloc();
- lavc_context->refcounted_frames = 1;
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
@@ -207,7 +206,6 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (priv->needs_reset)
control(da, ADCTRL_RESET, NULL);
-#if HAVE_AVCODEC_NEW_CODEC_API
int ret = avcodec_send_packet(avctx, &pkt);
if (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
if (ret >= 0 && mpkt)
@@ -220,24 +218,6 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
}
-#else
- int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
- if (mpkt) {
- // At least "shorten" decodes sub-frames, instead of the whole packet.
- // At least "mpc8" can return 0 and wants the packet again next time.
- if (ret >= 0) {
- ret = FFMIN(ret, mpkt->len); // sanity check against decoder overreads
- mpkt->buffer += ret;
- mpkt->len -= ret;
- mpkt->pts = MP_NOPTS_VALUE; // don't reset PTS next time
- }
- // LATM may need many packets to find mux info
- if (ret == AVERROR(EAGAIN)) {
- mpkt->len = 0;
- return 0;
- }
- }
-#endif
if (ret < 0) {
MP_ERR(da, "Error decoding audio.\n");
return -1;
@@ -245,8 +225,7 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (!got_frame)
return 0;
- double out_pts = mp_pts_from_av(MP_AVFRAME_DEC_PTS(priv->avframe),
- &priv->codec_timebase);
+ double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase);
struct mp_audio *mpframe = mp_audio_from_avframe(priv->avframe);
if (!mpframe)
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index 56e4a8102d..30c7883bf4 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -71,6 +71,7 @@ static void uninit(struct dec_audio *da)
av_freep(&lavf_ctx->pb->buffer);
av_freep(&lavf_ctx->pb);
avformat_free_context(lavf_ctx);
+ spdif_ctx->lavf_ctx = NULL;
}
}
@@ -82,12 +83,10 @@ static int init(struct dec_audio *da, const char *decoder)
spdif_ctx->use_dts_hd = da->opts->dtshd;
spdif_ctx->pool = mp_audio_pool_create(spdif_ctx);
- if (strcmp(decoder, "dts-hd") == 0) {
- decoder = "dts";
+ if (strcmp(decoder, "spdif_dts_hd") == 0)
spdif_ctx->use_dts_hd = true;
- }
- spdif_ctx->codec_id = mp_codec_to_av_codec_id(decoder);
+ spdif_ctx->codec_id = mp_codec_to_av_codec_id(da->codec->codec);
return spdif_ctx->codec_id != AV_CODEC_ID_NONE;
}
@@ -116,16 +115,10 @@ static int determine_codec_profile(struct dec_audio *da, AVPacket *pkt)
goto done;
}
-#if HAVE_AVCODEC_NEW_CODEC_API
if (avcodec_send_packet(ctx, pkt) < 0)
goto done;
if (avcodec_receive_frame(ctx, frame) < 0)
goto done;
-#else
- int got_frame = 0;
- if (avcodec_decode_audio4(ctx, frame, &got_frame, pkt) < 1 || !got_frame)
- goto done;
-#endif
profile = ctx->profile;
@@ -178,11 +171,7 @@ static int init_filter(struct dec_audio *da, AVPacket *pkt)
if (!stream)
goto fail;
-#if HAVE_AVCODEC_HAS_CODECPAR
stream->codecpar->codec_id = spdif_ctx->codec_id;
-#else
- stream->codec->codec_id = spdif_ctx->codec_id;
-#endif
AVDictionary *format_opts = NULL;
@@ -305,22 +294,53 @@ static const int codecs[] = {
AV_CODEC_ID_NONE
};
-static void add_decoders(struct mp_decoder_list *list)
+static bool find_codec(const char *name)
{
for (int n = 0; codecs[n] != AV_CODEC_ID_NONE; n++) {
const char *format = mp_codec_from_av_codec_id(codecs[n]);
- if (format) {
- mp_add_decoder(list, "spdif", format, format,
- "libavformat/spdifenc audio pass-through decoder");
+ if (format && name && strcmp(format, name) == 0)
+ return true;
+ }
+ return false;
+}
+
+// codec is the libavcodec name of the source audio codec.
+// pref is a ","-separated list of names, some of them which do not match with
+// libavcodec names (like dts-hd).
+struct mp_decoder_list *select_spdif_codec(const char *codec, const char *pref)
+{
+ struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
+
+ if (!find_codec(codec))
+ return list;
+
+ bool spdif_allowed = false, dts_hd_allowed = false;
+ bstr sel = bstr0(pref);
+ while (sel.len) {
+ bstr decoder;
+ bstr_split_tok(sel, ",", &decoder, &sel);
+ if (decoder.len) {
+ if (bstr_equals0(decoder, codec))
+ spdif_allowed = true;
+ if (bstr_equals0(decoder, "dts-hd") && strcmp(codec, "dts") == 0)
+ spdif_allowed = dts_hd_allowed = true;
}
}
- mp_add_decoder(list, "spdif", "dts", "dts-hd",
+
+ if (!spdif_allowed)
+ return list;
+
+ const char *suffix_name = dts_hd_allowed ? "dts_hd" : codec;
+ char name[80];
+ snprintf(name, sizeof(name), "spdif_%s", suffix_name);
+ mp_add_decoder(list, "spdif", codec, name,
"libavformat/spdifenc audio pass-through decoder");
+ return list;
}
const struct ad_functions ad_spdif = {
.name = "spdif",
- .add_decoders = add_decoders,
+ .add_decoders = NULL,
.init = init,
.uninit = uninit,
.control = control,
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 39e867cf42..9f28302bd5 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -43,11 +43,12 @@
#include "audio/filter/af.h"
extern const struct ad_functions ad_lavc;
+
+// Not a real codec - specially treated.
extern const struct ad_functions ad_spdif;
static const struct ad_functions * const ad_drivers[] = {
&ad_lavc,
- &ad_spdif,
NULL
};
@@ -90,10 +91,10 @@ static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
struct mp_decoder_list *list = audio_decoder_list();
struct mp_decoder_list *new =
- mp_select_decoders(list, codec, opts->audio_decoders);
- if (d_audio->try_spdif) {
+ mp_select_decoders(d_audio->log, list, codec, opts->audio_decoders);
+ if (d_audio->try_spdif && codec) {
struct mp_decoder_list *spdif =
- mp_select_decoder_list(list, codec, "spdif", opts->audio_spdif);
+ select_spdif_codec(codec, opts->audio_spdif);
mp_append_decoders(spdif, new);
talloc_free(new);
new = spdif;
@@ -108,6 +109,8 @@ static const struct ad_functions *find_driver(const char *name)
if (strcmp(ad_drivers[i]->name, name) == 0)
return ad_drivers[i];
}
+ if (strcmp(name, "spdif") == 0)
+ return &ad_spdif;
return NULL;
}
@@ -126,21 +129,18 @@ int audio_init_best_codec(struct dec_audio *d_audio)
const struct ad_functions *driver = find_driver(sel->family);
if (!driver)
continue;
- MP_VERBOSE(d_audio, "Opening audio decoder %s:%s\n",
- sel->family, sel->decoder);
+ MP_VERBOSE(d_audio, "Opening audio decoder %s\n", sel->decoder);
d_audio->ad_driver = driver;
if (init_audio_codec(d_audio, sel->decoder)) {
decoder = sel;
break;
}
- MP_WARN(d_audio, "Audio decoder init failed for "
- "%s:%s\n", sel->family, sel->decoder);
+ MP_WARN(d_audio, "Audio decoder init failed for %s\n", sel->decoder);
}
if (d_audio->ad_driver) {
d_audio->decoder_desc =
- talloc_asprintf(d_audio, "%s [%s:%s]", decoder->desc, decoder->family,
- decoder->decoder);
+ talloc_asprintf(d_audio, "%s (%s)", decoder->decoder, decoder->desc);
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
} else {
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index 7bc8b00b0f..ebe7c8ae5b 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -59,4 +59,7 @@ int audio_get_frame(struct dec_audio *d_audio, struct mp_audio **out_frame);
void audio_reset_decoding(struct dec_audio *d_audio);
+// ad_spdif.c
+struct mp_decoder_list *select_spdif_codec(const char *codec, const char *pref);
+
#endif /* MPLAYER_DEC_AUDIO_H */
diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c
index 0a7c5d4440..9df5adb96f 100644
--- a/audio/filter/af_lavcac3enc.c
+++ b/audio/filter/af_lavcac3enc.c
@@ -280,7 +280,6 @@ static int filter_out(struct af_instance *af)
AVPacket pkt = {0};
av_init_packet(&pkt);
-#if HAVE_AVCODEC_NEW_CODEC_API
// Send input as long as it wants.
while (1) {
err = read_input_frame(af, frame);
@@ -310,21 +309,6 @@ static int filter_out(struct af_instance *af)
MP_FATAL(af, "Encode failed.\n");
goto done;
}
-#else
- err = read_input_frame(af, frame);
- if (err < 0)
- goto done;
- if (err == 0)
- goto done;
- err = -1;
- int ok;
- int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &pkt, frame, &ok);
- s->input->samples = 0;
- if (lavc_ret < 0 || !ok) {
- MP_FATAL(af, "Encode failed.\n");
- goto done;
- }
-#endif
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
pkt.size, s->pending->samples + s->input->samples);
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index dc5d1a0d23..828be66247 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -111,12 +111,7 @@ static double get_delay(struct af_resample *s)
}
static int get_out_samples(struct af_resample *s, int in_samples)
{
-#if LIBSWRESAMPLE_VERSION_MAJOR > 1 || LIBSWRESAMPLE_VERSION_MINOR >= 2
return swr_get_out_samples(s->avrctx, in_samples);
-#else
- return av_rescale_rnd(in_samples, s->out_rate, s->in_rate, AV_ROUND_UP)
- + swr_get_delay(s->avrctx, s->out_rate);
-#endif
}
#endif
diff --git a/audio/out/ao.c b/audio/out/ao.c
index b624f4196c..6cf8de2d88 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -112,8 +112,8 @@ static bool get_desc(struct m_obj_desc *dst, int index)
.priv_size = ao->priv_size,
.priv_defaults = ao->priv_defaults,
.options = ao->options,
+ .options_prefix = ao->options_prefix,
.global_opts = ao->global_opts,
- .legacy_prefix = ao->legacy_prefix,
.hidden = ao->encode,
.p = ao,
};
@@ -127,11 +127,12 @@ const struct m_obj_list ao_obj_list = {
.allow_unknown_entries = true,
.allow_trailer = true,
.disallow_positional_parameters = true,
+ .use_global_options = true,
};
static struct ao *ao_alloc(bool probing, struct mpv_global *global,
void (*wakeup_cb)(void *ctx), void *wakeup_ctx,
- char *name, char **args)
+ char *name)
{
assert(wakeup_cb);
@@ -155,12 +156,9 @@ 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),
};
- struct m_config *config =
- m_config_from_obj_desc_and_args(ao, ao->log, global, &desc,
- name, opts->ao_defs, args);
- if (!config)
+ ao->priv = m_config_group_from_desc(ao, ao->log, global, &desc, name);
+ if (!ao->priv)
goto error;
- ao->priv = config->optstruct;
return ao;
error:
talloc_free(ao);
@@ -171,9 +169,9 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
void (*wakeup_cb)(void *ctx), void *wakeup_ctx,
struct encode_lavc_context *encode_lavc_ctx, int flags,
int samplerate, int format, struct mp_chmap channels,
- char *dev, char *name, char **args)
+ char *dev, char *name)
{
- struct ao *ao = ao_alloc(probing, global, wakeup_cb, wakeup_ctx, name, args);
+ struct ao *ao = ao_alloc(probing, global, wakeup_cb, wakeup_ctx, name);
if (!ao)
return NULL;
ao->samplerate = samplerate;
@@ -206,7 +204,7 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
talloc_free(ao);
return ao_init(probing, global, wakeup_cb, wakeup_ctx,
encode_lavc_ctx, flags, samplerate, format, channels,
- rdevice, redirect, NULL);
+ rdevice, redirect);
}
goto fail;
}
@@ -313,8 +311,7 @@ struct ao *ao_init_best(struct mpv_global *global,
mp_verbose(log, "Using preferred device '%s'\n", dev);
}
ao = ao_init(probing, global, wakeup_cb, wakeup_ctx, encode_lavc_ctx,
- init_flags, samplerate, format, channels, dev,
- entry->name, entry->attribs);
+ init_flags, samplerate, format, channels, dev, entry->name);
if (ao)
break;
if (!probing)
@@ -571,7 +568,7 @@ struct ao_device_list *ao_hotplug_get_device_list(struct ao_hotplug *hp)
break; // don't add unsafe/special entries
struct ao *ao = ao_alloc(true, hp->global, hp->wakeup_cb, hp->wakeup_ctx,
- (char *)d->name, NULL);
+ (char *)d->name);
if (!ao)
continue;
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 201557697d..ac29905f5a 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -603,8 +603,8 @@ static int try_open_device(struct ao *ao, const char *device, int mode)
const char *const fallbacks[] = {"hdmi", "iec958", NULL};
for (int n = 0; fallbacks[n]; n++) {
char *ndev = append_params(tmp, fallbacks[n], params);
- MP_VERBOSE(ao, "got error %d; opening iec fallback "
- "device '%s'\n", err, ndev);
+ MP_VERBOSE(ao, "got error '%s'; opening iec fallback "
+ "device '%s'\n", snd_strerror(err), ndev);
err = snd_pcm_open
(&p->alsa, ndev, SND_PCM_STREAM_PLAYBACK, mode);
if (err >= 0)
@@ -845,12 +845,6 @@ static int init_device(struct ao *ao, int mode)
ao->device_buffer = p->buffersize;
- // ao_alsa implements this by relying on underrun behavior (no data means
- // underrun, during which silence is played). Trigger by playing some
- // initial silence.
- if (ao->stream_silence)
- ao_play_silence(ao, p->outburst);
-
return 0;
alsa_error:
@@ -1202,15 +1196,5 @@ const struct ao_driver audio_out_alsa = {
.wakeup = ao_wakeup_poll,
.list_devs = list_devs,
.priv_size = sizeof(struct priv),
- .options = (const struct m_option[]) {
- OPT_SUBOPT_LEGACY("device", "alsa-device"),
- OPT_SUBOPT_LEGACY("resample", "alsa-resample"),
- OPT_SUBOPT_LEGACY("mixer-device", "alsa-mixer-device"),
- OPT_SUBOPT_LEGACY("mixer-name", "alsa-mixer-name"),
- OPT_SUBOPT_LEGACY("mixer-index", "alsa-mixer-index"),
- OPT_SUBOPT_LEGACY("non-interleaved", "alsa-non-interleaved"),
- OPT_SUBOPT_LEGACY("ignore-chmap", "alsa-ignore-chmap"),
- {0}
- },
.global_opts = &ao_alsa_conf,
};
diff --git a/audio/out/ao_audiounit.m b/audio/out/ao_audiounit.m
index 7411a1a1dd..31703525a9 100644
--- a/audio/out/ao_audiounit.m
+++ b/audio/out/ao_audiounit.m
@@ -195,7 +195,4 @@ const struct ao_driver audio_out_audiounit = {
.pause = stop,
.resume = start,
.priv_size = sizeof(struct priv),
- .options = (const struct m_option[]){
- {0}
- },
};
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 3a7aa2eac1..ba0dd9b0ba 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -39,7 +39,6 @@ struct priv {
AudioStreamID original_asbd_stream;
int change_physical_format;
- int exclusive;
};
static int64_t ca_get_hardware_latency(struct ao *ao) {
@@ -143,9 +142,7 @@ static int init(struct ao *ao)
{
struct priv *p = ao->priv;
- p->exclusive |= ao->init_flags & AO_INIT_EXCLUSIVE;
-
- if (!af_fmt_is_pcm(ao->format) || p->exclusive) {
+ if (!af_fmt_is_pcm(ao->format) || (ao->init_flags & AO_INIT_EXCLUSIVE)) {
MP_VERBOSE(ao, "redirecting to coreaudio_exclusive\n");
ao->redirect = "coreaudio_exclusive";
return CONTROL_ERROR;
@@ -429,9 +426,7 @@ const struct ao_driver audio_out_coreaudio = {
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]){
OPT_FLAG("change-physical-format", change_physical_format, 0),
- OPT_FLAG("exclusive", exclusive, 0,
- .deprecation_message = "use --audio-exclusive"),
{0}
},
- .legacy_prefix = "coreaudio",
+ .options_prefix = "coreaudio",
};
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index 56c7e28544..2ad3cad586 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -246,13 +246,5 @@ const struct ao_driver audio_out_jack = {
.uninit = uninit,
.resume = resume,
.priv_size = sizeof(struct priv),
- .options = (const struct m_option[]) {
- OPT_SUBOPT_LEGACY("port", "jack-port"),
- OPT_SUBOPT_LEGACY("name", "jack-name"),
- OPT_SUBOPT_LEGACY("autostart", "jack-autostart"),
- OPT_SUBOPT_LEGACY("connect", "jack-connect"),
- OPT_SUBOPT_LEGACY("std-channel-layout", "jack-std-channel-layout"),
- {0}
- },
.global_opts = &ao_jack_conf,
};
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 8ae1317407..4dbc55a369 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -258,7 +258,6 @@ static void encode_audio_and_write(struct ao *ao, AVFrame *frame)
struct priv *ac = ao->priv;
AVPacket packet = {0};
-#if HAVE_AVCODEC_NEW_CODEC_API
int status = avcodec_send_frame(ac->codec, frame);
if (status < 0) {
MP_ERR(ao, "error encoding at %d %d/%d\n",
@@ -297,28 +296,6 @@ static void encode_audio_and_write(struct ao *ao, AVFrame *frame)
write_packet(ao, &packet);
av_packet_unref(&packet);
}
-#else
- av_init_packet(&packet);
- int got_packet = 0;
- int status = avcodec_encode_audio2(ac->codec, &packet, frame, &got_packet);
- if (status < 0) {
- MP_ERR(ao, "error encoding at %d %d/%d\n",
- frame ? (int) frame->pts : -1,
- ac->codec->time_base.num,
- ac->codec->time_base.den);
- return;
- }
- if (!got_packet) {
- return;
- }
- if (frame) {
- if (ac->savepts == AV_NOPTS_VALUE)
- ac->savepts = frame->pts;
- }
- encode_lavc_write_stats(ao->encode_lavc_ctx, ac->codec);
- write_packet(ao, &packet);
- av_packet_unref(&packet);
-#endif
}
// must get exactly ac->aframesize amount of data
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 7c0c745b12..7b288a8245 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -241,5 +241,5 @@ const struct ao_driver audio_out_null = {
OPT_CHANNELS("channel-layouts", channel_layouts, 0),
{0}
},
- .legacy_prefix = "ao-null",
+ .options_prefix = "ao-null",
};
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index aba049445d..a1fd95ab18 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -374,5 +374,5 @@ const struct ao_driver audio_out_openal = {
DEVICE_OPT_DEPRECATION),
{0}
},
- .legacy_prefix = "ao-openal",
+ .options_prefix = "ao-openal",
};
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index dd20dbf1d0..5357ab4920 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -246,5 +246,5 @@ const struct ao_driver audio_out_opensles = {
OPT_INTRANGE("sample-rate", cfg_sample_rate, 0, 1000, 100000),
{0}
},
- .legacy_prefix = "opensles",
+ .options_prefix = "opensles",
};
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index 5bf5fec29b..c0446eb2aa 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -653,5 +653,5 @@ const struct ao_driver audio_out_oss = {
OPT_STRING("mixer-channel", cfg_oss_mixer_channel, 0),
{0}
},
- .legacy_prefix = "oss",
+ .options_prefix = "oss",
};
diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c
index 169a1b94a1..4e5ec0a319 100644
--- a/audio/out/ao_pcm.c
+++ b/audio/out/ao_pcm.c
@@ -224,5 +224,5 @@ const struct ao_driver audio_out_pcm = {
OPT_FLAG("append", append, 0),
{0}
},
- .legacy_prefix = "ao-pcm",
+ .options_prefix = "ao-pcm",
};
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 5a68553e88..6c6a517f2a 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -841,5 +841,5 @@ const struct ao_driver audio_out_pulse = {
OPT_FLAG("latency-hacks", cfg_latency_hacks, 0),
{0}
},
- .legacy_prefix = "pulse",
+ .options_prefix = "pulse",
};
diff --git a/audio/out/ao_rsound.c b/audio/out/ao_rsound.c
index 5ecb39b9d3..9689a9e0b8 100644
--- a/audio/out/ao_rsound.c
+++ b/audio/out/ao_rsound.c
@@ -162,6 +162,6 @@ const struct ao_driver audio_out_rsound = {
.deprecation_message = "request --audio-device support on issue tracker"),
{0}
},
- .legacy_prefix = "rsound",
+ .options_prefix = "rsound",
};
diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c
index d9d00628b6..1564e26120 100644
--- a/audio/out/ao_sdl.c
+++ b/audio/out/ao_sdl.c
@@ -212,5 +212,5 @@ const struct ao_driver audio_out_sdl = {
OPT_FLOAT("buflen", buflen, 0),
{0}
},
- .legacy_prefix = "sdl",
+ .options_prefix = "sdl",
};
diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c
index f60fa303e5..e0fd9f0296 100644
--- a/audio/out/ao_sndio.c
+++ b/audio/out/ao_sndio.c
@@ -324,5 +324,5 @@ const struct ao_driver audio_out_sndio = {
DEVICE_OPT_DEPRECATION),
{0}
},
- .legacy_prefix = "ao-sndio",
+ .options_prefix = "ao-sndio",
};
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c
index 17f3e98653..b2e035d3dc 100644
--- a/audio/out/ao_wasapi.c
+++ b/audio/out/ao_wasapi.c
@@ -496,11 +496,4 @@ const struct ao_driver audio_out_wasapi = {
.hotplug_init = hotplug_init,
.hotplug_uninit = hotplug_uninit,
.priv_size = sizeof(wasapi_state),
- .options = (const struct m_option[]) {
- OPT_FLAG("exclusive", opt_exclusive, 0,
- .deprecation_message = "use --audio-exclusive"),
- OPT_STRING("device", opt_device, 0, DEVICE_OPT_DEPRECATION),
- {NULL},
- },
- .legacy_prefix = "ao-wasapi",
};
diff --git a/audio/out/ao_wasapi.h b/audio/out/ao_wasapi.h
index 6dd130b50f..65f16d11c1 100644
--- a/audio/out/ao_wasapi.h
+++ b/audio/out/ao_wasapi.h
@@ -50,6 +50,10 @@ void wasapi_change_uninit(struct ao* ao);
#define SAFE_RELEASE(unk, release) \
do { if ((unk) != NULL) { release; (unk) = NULL; } } while(0)
+#define mp_format_res_str(hres) \
+ (SUCCEEDED(hres) ? "ok" : ((hres) == AUDCLNT_E_UNSUPPORTED_FORMAT) \
+ ? "unsupported" : mp_HRESULT_to_str(hres))
+
enum wasapi_thread_state {
WASAPI_THREAD_FEED = 0,
WASAPI_THREAD_RESUME,
@@ -92,8 +96,6 @@ typedef struct wasapi_state {
// ao options
int opt_exclusive;
- int opt_list;
- char *opt_device;
// format info
WAVEFORMATEXTENSIBLE format;
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index 320bb6767b..4667b57ae8 100644
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -289,18 +289,12 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf,
static bool try_format_exclusive(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
{
struct wasapi_state *state = ao->priv;
- MP_VERBOSE(ao, "Trying %s (exclusive)\n",
- waveformat_to_str(&wformat->Format));
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
AUDCLNT_SHAREMODE_EXCLUSIVE,
&wformat->Format, NULL);
- if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
- EXIT_ON_ERROR(hr);
-
+ MP_VERBOSE(ao, "Trying %s (exclusive) -> %s\n",
+ waveformat_to_str(&wformat->Format), mp_format_res_str(hr));
return SUCCEEDED(hr);
-exit_label:
- MP_ERR(state, "Error testing exclusive format: %s\n", mp_HRESULT_to_str(hr));
- return false;
}
// This works like try_format_exclusive(), but will try to fallback to the AC3
@@ -393,11 +387,8 @@ static bool search_channels(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
for (int j = 0; channel_layouts[j]; j++) {
mp_chmap_from_str(&entry, bstr0(channel_layouts[j]));
if (!wformat->Format.nSamplesPerSec) {
- if (search_samplerates(ao, wformat, &entry)) {
+ if (search_samplerates(ao, wformat, &entry))
mp_chmap_sel_add_map(&chmap_sel, &entry);
- MP_VERBOSE(ao, "%s is supported\n",
- waveformat_to_str(&wformat->Format));
- }
} else {