summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-16 21:00:20 +0200
committerwm4 <wm4@nowhere>2017-08-16 21:10:54 +0200
commit1f593beeb4c649c4718db6f9a4ee37a897af6ead (patch)
tree08d78c2cc473c234fc85ed55a48473f89c76f308 /player
parent16e0a3948288e37034c572617cf47b0a4dc0e10e (diff)
downloadmpv-1f593beeb4c649c4718db6f9a4ee37a897af6ead.tar.bz2
mpv-1f593beeb4c649c4718db6f9a4ee37a897af6ead.tar.xz
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the new code is not affected by the copyright of the old code. This is needed, because the original mp_audio struct was written by someone who has disagreed with LGPL relicensing (it was called af_data at the time, and was defined in af.h). The "GPL'ed" struct contents that surive are pretty trivial: just the data pointer, and some metadata like the format, samplerate, etc. - but at least in this case, any new code would be extremely similar anyway, and I'm not really sure whether it's OK to claim different copyright. So what we do is we just use AVFrame (which of course is LGPL with 100% certainty), and add some accessors around it to adapt it to mpv conventions. Also, this gets rid of some annoying conventions of mp_audio, like the struct fields that require using an accessor to write to them anyway. For the most part, this change is only dumb replacements of mp_audio related functions and fields. One minor actual change is that you can't allocate the new type on the stack anymore. Some code still uses mp_audio. All audio filter code will be deleted, so it makes no sense to convert this code. (Audio filters which are LGPL and which we keep will have to be ported to a new filter infrastructure anyway.) player/audio.c uses it because it interacts with the old filter code. push.c has some complex use of mp_audio and mp_audio_buffer, but this and pull.c will most likely be rewritten to do something else.
Diffstat (limited to 'player')
-rw-r--r--player/audio.c57
-rw-r--r--player/command.c43
-rw-r--r--player/core.h10
-rw-r--r--player/lavfi.c59
-rw-r--r--player/lavfi.h6
-rw-r--r--player/loadfile.c2
-rw-r--r--player/playloop.c2
-rw-r--r--player/video.c8
8 files changed, 114 insertions, 73 deletions
diff --git a/player/audio.c b/player/audio.c
index fcc442b974..25d7baa6af 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -352,6 +352,7 @@ static void ao_chain_uninit(struct ao_chain *ao_c)
af_destroy(ao_c->af);
talloc_free(ao_c->input_frame);
+ talloc_free(ao_c->input_format);
talloc_free(ao_c->ao_buffer);
talloc_free(ao_c);
}
@@ -368,6 +369,18 @@ void uninit_audio_chain(struct MPContext *mpctx)
}
}
+static void get_ao_format(struct ao *ao, struct mp_audio *aformat)
+{
+ int samplerate;
+ int format;
+ struct mp_chmap channels;
+ ao_get_format(ao, &samplerate, &format, &channels);
+ *aformat = (struct mp_audio){0};
+ mp_audio_set_format(aformat, format);
+ mp_audio_set_channels(aformat, &channels);
+ aformat->rate = samplerate;
+}
+
static void reinit_audio_filters_and_output(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
@@ -377,11 +390,9 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
struct af_stream *afs = ao_c->af;
if (ao_c->input_frame)
- mp_audio_copy_config(&ao_c->input_format, ao_c->input_frame);
+ mp_aframe_config_copy(ao_c->input_format, ao_c->input_frame);
- struct mp_audio in_format = ao_c->input_format;
-
- if (!mp_audio_config_valid(&in_format)) {
+ if (!mp_aframe_config_is_valid(ao_c->input_format)) {
// We don't know the audio format yet - so configure it later as we're
// resyncing. fill_audio_buffers() will call this function again.
mp_wakeup_core(mpctx);
@@ -390,18 +401,20 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
// Weak gapless audio: drain AO on decoder format changes
if (mpctx->ao_decoder_fmt && mpctx->ao && opts->gapless_audio < 0 &&
- !mp_audio_config_equals(mpctx->ao_decoder_fmt, &in_format))
+ !mp_aframe_config_equals(mpctx->ao_decoder_fmt, ao_c->input_format))
{
uninit_audio_out(mpctx);
}
+ struct mp_audio in_format;
+ mp_audio_config_from_aframe(&in_format, ao_c->input_format);
if (mpctx->ao && mp_audio_config_equals(&in_format, &afs->input))
return;
afs->output = (struct mp_audio){0};
if (mpctx->ao) {
- ao_get_format(mpctx->ao, &afs->output);
- } else if (af_fmt_is_pcm(in_format.format)) {
+ get_ao_format(mpctx->ao, &afs->output);
+ } else if (af_fmt_is_pcm(mp_aframe_get_format(ao_c->input_format))) {
afs->output.rate = opts->force_srate;
mp_audio_set_format(&afs->output, opts->audio_output_format);
if (opts->audio_output_channels.num_chmaps == 1) {
@@ -455,7 +468,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
struct mp_audio fmt = {0};
if (mpctx->ao)
- ao_get_format(mpctx->ao, &fmt);
+ get_ao_format(mpctx->ao, &fmt);
// Verify passthrough format was not changed.
if (mpctx->ao && af_fmt_is_spdif(afs->output.format)) {
@@ -477,7 +490,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
if (!audio_init_best_codec(ao_c->audio_src))
goto init_error;
reset_audio_state(mpctx);
- ao_c->input_format = (struct mp_audio){0};
+ mp_aframe_reset(ao_c->input_format);
mp_wakeup_core(mpctx); // reinit with new format next time
return;
}
@@ -492,8 +505,8 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
if (!mp_audio_config_equals(&afs->output, &afs->filter_output))
afs->initialized = 0;
- mpctx->ao_decoder_fmt = talloc(NULL, struct mp_audio);
- *mpctx->ao_decoder_fmt = in_format;
+ mpctx->ao_decoder_fmt = mp_aframe_create();
+ mp_aframe_config_copy(mpctx->ao_decoder_fmt, ao_c->input_format);
MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(mpctx->ao),
mp_audio_config_to_str(&fmt));
@@ -580,6 +593,7 @@ void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track)
ao_c->pts = MP_NOPTS_VALUE;
ao_c->ao_buffer = mp_audio_buffer_create(NULL);
ao_c->ao = mpctx->ao;
+ ao_c->input_format = mp_aframe_create();
if (track) {
ao_c->track = track;
@@ -593,7 +607,7 @@ void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track)
if (mpctx->ao) {
struct mp_audio fmt;
- ao_get_format(mpctx->ao, &fmt);
+ get_ao_format(mpctx->ao, &fmt);
mp_audio_buffer_reinit(ao_c->ao_buffer, &fmt);
}
@@ -614,9 +628,7 @@ double written_audio_pts(struct MPContext *mpctx)
if (!ao_c)
return MP_NOPTS_VALUE;
- struct mp_audio in_format = ao_c->input_format;
-
- if (!mp_audio_config_valid(&in_format) || ao_c->af->initialized < 1)
+ if (ao_c->af->initialized < 1)
return MP_NOPTS_VALUE;
// first calculate the end pts of audio that has been output by decoder
@@ -653,7 +665,7 @@ static int write_to_ao(struct MPContext *mpctx, struct mp_audio *data, int flags
return 0;
struct ao *ao = mpctx->ao;
struct mp_audio out_format;
- ao_get_format(ao, &out_format);
+ get_ao_format(ao, &out_format);
#if HAVE_ENCODING
encode_lavc_set_audio_pts(mpctx->encode_lavc_ctx, playing_audio_pts(mpctx));
#endif
@@ -706,7 +718,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
return true;
struct mp_audio out_format = {0};
- ao_get_format(mpctx->ao, &out_format);
+ get_ao_format(mpctx->ao, &out_format);
double play_samplerate = out_format.rate / mpctx->audio_speed;
if (!opts->initial_audio_sync) {
@@ -879,14 +891,19 @@ static int filter_audio(struct MPContext *mpctx, struct mp_audio_buffer *outbuf,
}
// On format change, make sure to drain the filter chain.
- if (!mp_audio_config_equals(&afs->input, ao_c->input_frame)) {
+ struct mp_audio in_format;
+ mp_audio_config_from_aframe(&in_format, ao_c->input_format);
+ if (!mp_audio_config_equals(&afs->input, &in_format)) {
copy_output(mpctx, outbuf, minsamples, endpts, true, &eof);
res = AD_NEW_FMT;
break;
}
- struct mp_audio *mpa = ao_c->input_frame;
+ struct mp_audio *mpa = mp_audio_from_aframe(ao_c->input_frame);
+ talloc_free(ao_c->input_frame);
ao_c->input_frame = NULL;
+ if (!mpa)
+ abort();
if (mpa->pts == MP_NOPTS_VALUE) {
ao_c->pts = MP_NOPTS_VALUE;
} else {
@@ -990,7 +1007,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
}
struct mp_audio out_format = {0};
- ao_get_format(mpctx->ao, &out_format);
+ get_ao_format(mpctx->ao, &out_format);
double play_samplerate = out_format.rate / mpctx->audio_speed;
int align = af_format_sample_alignment(out_format.format);
diff --git a/player/command.c b/player/command.c
index b023e350c9..51b025cad4 100644
--- a/player/command.c
+++ b/player/command.c
@@ -56,7 +56,7 @@
#include "video/decode/vd.h"
#include "video/out/vo.h"
#include "video/csputils.h"
-#include "audio/audio_buffer.h"
+#include "audio/aframe.h"
#include "audio/out/ao.h"
#include "audio/filter/af.h"
#include "video/decode/dec_video.h"
@@ -2019,17 +2019,20 @@ static int mp_property_audio_codec(void *ctx, struct m_property *prop,
return m_property_strdup_ro(action, arg, c);
}
-static int property_audiofmt(struct mp_audio a, int action, void *arg)
+static int property_audiofmt(struct mp_aframe *fmt, int action, void *arg)
{
- if (!mp_audio_config_valid(&a))
+ if (!fmt || !mp_aframe_config_is_valid(fmt))
return M_PROPERTY_UNAVAILABLE;
+ struct mp_chmap chmap = {0};
+ mp_aframe_get_chmap(fmt, &chmap);
+
struct m_sub_property props[] = {
- {"samplerate", SUB_PROP_INT(a.rate)},
- {"channel-count", SUB_PROP_INT(a.channels.num)},
- {"channels", SUB_PROP_STR(mp_chmap_to_str(&a.channels))},
- {"hr-channels", SUB_PROP_STR(mp_chmap_to_str_hr(&a.channels))},
- {"format", SUB_PROP_STR(af_fmt_to_str(a.format))},
+ {"samplerate", SUB_PROP_INT(mp_aframe_get_rate(fmt))},
+ {"channel-count", SUB_PROP_INT(chmap.num)},
+ {"channels", SUB_PROP_STR(mp_chmap_to_str(&chmap))},
+ {"hr-channels", SUB_PROP_STR(mp_chmap_to_str_hr(&chmap))},
+ {"format", SUB_PROP_STR(af_fmt_to_str(mp_aframe_get_format(fmt)))},
{0}
};
@@ -2040,20 +2043,28 @@ static int mp_property_audio_params(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct mp_audio fmt = {0};
- if (mpctx->ao_chain)
- fmt = mpctx->ao_chain->input_format;
- return property_audiofmt(fmt, action, arg);
+ return property_audiofmt(mpctx->ao_chain ? mpctx->ao_chain->input_format : NULL,
+ action, arg);
}
static int mp_property_audio_out_params(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct mp_audio fmt = {0};
- if (mpctx->ao)
- ao_get_format(mpctx->ao, &fmt);
- return property_audiofmt(fmt, action, arg);
+ struct mp_aframe *frame = NULL;
+ if (mpctx->ao) {
+ frame = mp_aframe_create();
+ int samplerate;
+ int format;
+ struct mp_chmap channels;
+ ao_get_format(mpctx->ao, &samplerate, &format, &channels);
+ mp_aframe_set_rate(frame, samplerate);
+ mp_aframe_set_format(frame, format);
+ mp_aframe_set_chmap(frame, &channels);
+ }
+ int r = property_audiofmt(frame, action, arg);
+ talloc_free(frame);
+ return r;
}
/// Balance (RW)
diff --git a/player/core.h b/player/core.h
index bdb8b4c3a5..ea7e0c1ec1 100644
--- a/player/core.h
+++ b/player/core.h
@@ -28,7 +28,7 @@
#include "common/common.h"
#include "options/options.h"
#include "sub/osd.h"
-#include "audio/audio.h"
+#include "audio/aframe.h"
#include "video/mp_image.h"
#include "video/out/vo.h"
@@ -205,10 +205,10 @@ struct ao_chain {
double ao_resume_time;
// 1-element input frame queue.
- struct mp_audio *input_frame;
+ struct mp_aframe *input_frame;
- // Last known input_mpi format (so vf can be reinitialized any time).
- struct mp_audio input_format;
+ // Last known input_mpi format (so af can be reinitialized any time).
+ struct mp_aframe *input_format;
struct track *track;
struct lavfi_pad *filter_src;
@@ -313,7 +313,7 @@ typedef struct MPContext {
struct lavfi *lavfi;
struct ao *ao;
- struct mp_audio *ao_decoder_fmt; // for weak gapless audio check
+ struct mp_aframe *ao_decoder_fmt; // for weak gapless audio check
struct ao_chain *ao_chain;
struct vo_chain *vo_chain;
diff --git a/player/lavfi.c b/player/lavfi.c
index ee0ca281e4..e5bfe7fdf5 100644
--- a/player/lavfi.c
+++ b/player/lavfi.c
@@ -37,7 +37,8 @@
#include "common/av_common.h"
#include "common/msg.h"
-#include "audio/audio.h"
+#include "audio/format.h"
+#include "audio/aframe.h"
#include "video/mp_image.h"
#include "audio/fmt-conversion.h"
#include "video/fmt-conversion.h"
@@ -96,7 +97,7 @@ struct lavfi_pad {
// 1-frame queue (used for both input and output)
struct mp_image *pending_v;
- struct mp_audio *pending_a;
+ struct mp_aframe *pending_a;
// -- dir==LAVFI_IN
@@ -107,7 +108,7 @@ struct lavfi_pad {
// used to check for format changes manually
struct mp_image *in_fmt_v;
- struct mp_audio in_fmt_a;
+ struct mp_aframe *in_fmt_a;
// -- dir==LAVFI_OUT
@@ -199,7 +200,7 @@ static void free_graph(struct lavfi *c)
pad->filter_pad = -1;
pad->buffer = NULL;
TA_FREEP(&pad->in_fmt_v);
- pad->in_fmt_a = (struct mp_audio){0};
+ TA_FREEP(&pad->in_fmt_a);
pad->buffer_is_eof = false;
pad->input_needed = false;
pad->input_waiting = false;
@@ -312,9 +313,14 @@ static void send_global_eof(struct lavfi *c)
// libavfilter allows changing some parameters on the fly, but not
// others.
-static bool is_aformat_ok(struct mp_audio *a, struct mp_audio *b)
+static bool is_aformat_ok(struct mp_aframe *a, struct mp_aframe *b)
{
- return mp_audio_config_equals(a, b);
+ struct mp_chmap ca = {0}, cb = {0};
+ mp_aframe_get_chmap(a, &ca);
+ mp_aframe_get_chmap(b, &cb);
+ return mp_chmap_equals(&ca, &cb) &&
+ mp_aframe_get_rate(a) == mp_aframe_get_rate(b) &&
+ mp_aframe_get_format(a) == mp_aframe_get_format(b);
}
static bool is_vformat_ok(struct mp_image *a, struct mp_image *b)
{
@@ -331,9 +337,9 @@ static void check_format_changes(struct lavfi *c)
if (!pad->buffer || pad->dir != LAVFI_IN)
continue;
- if (pad->type == STREAM_AUDIO && pad->pending_a && pad->in_fmt_a.format) {
+ if (pad->type == STREAM_AUDIO && pad->pending_a && pad->in_fmt_a) {
c->draining_new_format |= !is_aformat_ok(pad->pending_a,
- &pad->in_fmt_a);
+ pad->in_fmt_a);
}
if (pad->type == STREAM_VIDEO && pad->pending_v && pad->in_fmt_v) {
c->draining_new_format |= !is_vformat_ok(pad->pending_v,
@@ -389,7 +395,10 @@ static bool init_pads(struct lavfi *c)
if (pad->pending_a) {
assert(pad->type == STREAM_AUDIO);
- mp_audio_copy_config(&pad->in_fmt_a, pad->pending_a);
+ pad->in_fmt_a = mp_aframe_new_ref(pad->pending_a);
+ if (!pad->in_fmt_a)
+ goto error;
+ mp_aframe_unref_data(pad->in_fmt_a);
} else if (pad->pending_v) {
assert(pad->type == STREAM_VIDEO);
pad->in_fmt_v = mp_image_new_ref(pad->pending_v);
@@ -400,9 +409,11 @@ static bool init_pads(struct lavfi *c)
// libavfilter makes this painful. Init it with a dummy config,
// just so we can tell it the stream is EOF.
if (pad->type == STREAM_AUDIO) {
- mp_audio_set_format(&pad->in_fmt_a, AF_FORMAT_FLOAT);
- mp_audio_set_num_channels(&pad->in_fmt_a, 2);
- pad->in_fmt_a.rate = 48000;
+ pad->in_fmt_a = mp_aframe_create();
+ mp_aframe_set_format(pad->in_fmt_a, AF_FORMAT_FLOAT);
+ mp_aframe_set_chmap(pad->in_fmt_a,
+ &(struct mp_chmap)MP_CHMAP_INIT_STEREO);
+ mp_aframe_set_rate(pad->in_fmt_a, 48000);
} else if (pad->type == STREAM_VIDEO) {
pad->in_fmt_v = talloc_zero(NULL, struct mp_image);
mp_image_setfmt(pad->in_fmt_v, IMGFMT_420P);
@@ -421,11 +432,13 @@ static bool init_pads(struct lavfi *c)
char *filter_name = NULL;
if (pad->type == STREAM_AUDIO) {
params->time_base = pad->timebase =
- (AVRational){1, pad->in_fmt_a.rate};
- params->format = af_to_avformat(pad->in_fmt_a.format);
- params->sample_rate = pad->in_fmt_a.rate;
- params->channel_layout =
- mp_chmap_to_lavc(&pad->in_fmt_a.channels);
+ (AVRational){1, mp_aframe_get_rate(pad->in_fmt_a)};
+ params->format =
+ af_to_avformat(mp_aframe_get_format(pad->in_fmt_a));
+ params->sample_rate = mp_aframe_get_rate(pad->in_fmt_a);
+ struct mp_chmap chmap = {0};
+ mp_aframe_get_chmap(pad->in_fmt_a, &chmap);
+ params->channel_layout = mp_chmap_to_lavc(&chmap);
filter_name = "abuffer";
} else if (pad->type == STREAM_VIDEO) {
params->time_base = pad->timebase = AV_TIME_BASE_Q;
@@ -565,8 +578,8 @@ static void feed_input_pads(struct lavfi *c)
frame = mp_image_to_av_frame_and_unref(pad->pending_v);
pad->pending_v = NULL;
} else if (pad->pending_a) {
- pts = pad->pending_a->pts;
- frame = mp_audio_to_avframe_and_unref(pad->pending_a);
+ pts = mp_aframe_get_pts(pad->pending_a);
+ frame = mp_aframe_to_avframe_and_unref(pad->pending_a);
pad->pending_a = NULL;
} else {
if (!pad->input_eof) {
@@ -621,9 +634,9 @@ static void read_output_pads(struct lavfi *c)
pad->output_needed = false;
double pts = mp_pts_from_av(c->tmp_frame->pts, &pad->timebase);
if (pad->type == STREAM_AUDIO) {
- pad->pending_a = mp_audio_from_avframe(c->tmp_frame);
+ pad->pending_a = mp_aframe_from_avframe(c->tmp_frame);
if (pad->pending_a)
- pad->pending_a->pts = pts;
+ mp_aframe_set_pts(pad->pending_a, pts);
} else if (pad->type == STREAM_VIDEO) {
pad->pending_v = mp_image_from_av_frame(c->tmp_frame);
if (pad->pending_v)
@@ -733,7 +746,7 @@ static int lavfi_request_frame(struct lavfi_pad *pad)
// DATA_STARVE: needs more input data
// DATA_WAIT: needs more input data, and all inputs in LAVFI_WAIT state
// DATA_EOF: no more data
-int lavfi_request_frame_a(struct lavfi_pad *pad, struct mp_audio **out_aframe)
+int lavfi_request_frame_a(struct lavfi_pad *pad, struct mp_aframe **out_aframe)
{
int r = lavfi_request_frame(pad);
*out_aframe = pad->pending_a;
@@ -787,7 +800,7 @@ static void lavfi_sent_frame(struct lavfi_pad *pad)
}
// See lavfi_send_status() for remarks.
-void lavfi_send_frame_a(struct lavfi_pad *pad, struct mp_audio *aframe)
+void lavfi_send_frame_a(struct lavfi_pad *pad, struct mp_aframe *aframe)
{
assert(pad->type == STREAM_AUDIO);
assert(!pad->pending_a);
diff --git a/player/lavfi.h b/player/lavfi.h
index ef19a14179..92c32954d7 100644
--- a/player/lavfi.h
+++ b/player/lavfi.h
@@ -5,7 +5,7 @@ struct mp_log;
struct lavfi;
struct lavfi_pad;
struct mp_image;
-struct mp_audio;
+struct mp_aframe;
enum lavfi_direction {
LAVFI_IN = 1,
@@ -25,11 +25,11 @@ bool lavfi_has_failed(struct lavfi *c);
void lavfi_seek_reset(struct lavfi *c);
void lavfi_pad_set_hwdec_devs(struct lavfi_pad *pad,
struct mp_hwdec_devices *hwdevs);
-int lavfi_request_frame_a(struct lavfi_pad *pad, struct mp_audio **out_aframe);
+int lavfi_request_frame_a(struct lavfi_pad *pad, struct mp_aframe **out_aframe);
int lavfi_request_frame_v(struct lavfi_pad *pad, struct mp_image **out_vframe);
bool lavfi_needs_input(struct lavfi_pad *pad);
void lavfi_send_status(struct lavfi_pad *pad, int status);
-void lavfi_send_frame_a(struct lavfi_pad *pad, struct mp_audio *aframe);
+void lavfi_send_frame_a(struct lavfi_pad *pad, struct mp_aframe *aframe);
void lavfi_send_frame_v(struct lavfi_pad *pad, struct mp_image *vframe);
#endif
diff --git a/player/loadfile.c b/player/loadfile.c
index 4a5c0e1d2c..543fd02458 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -43,8 +43,6 @@
#include "common/recorder.h"
#include "input/input.h"
-#include "audio/audio.h"
-#include "audio/audio_buffer.h"
#include "audio/decode/dec_audio.h"
#include "audio/out/ao.h"
#include "demux/demux.h"
diff --git a/player/playloop.c b/player/playloop.c
index ea73981a4f..c9bc91010b 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -1053,7 +1053,7 @@ static void handle_complex_filter_decoders(struct MPContext *mpctx)
continue;
if (track->d_audio) {
audio_work(track->d_audio);
- struct mp_audio *fr;
+ struct mp_aframe *fr;
int res = audio_get_frame(track->d_audio, &fr);
if (res == DATA_OK) {
lavfi_send_frame_a(track->sink, fr);
diff --git a/player/video.c b/player/video.c
index 0dca3a597f..3a9941d8e0 100644
--- a/player/video.c
+++ b/player/video.c
@@ -1053,9 +1053,11 @@ static double find_best_speed(struct MPContext *mpctx, double vsync)
static bool using_spdif_passthrough(struct MPContext *mpctx)
{
if (mpctx->ao_chain && mpctx->ao_chain->ao) {
- struct mp_audio out_format = {0};
- ao_get_format(mpctx->ao_chain->ao, &out_format);
- return !af_fmt_is_pcm(out_format.format);
+ int samplerate;
+ int format;
+ struct mp_chmap channels;
+ ao_get_format(mpctx->ao_chain->ao, &samplerate, &format, &channels);
+ return !af_fmt_is_pcm(format);
}
return false;
}