summaryrefslogtreecommitdiffstats
path: root/player/audio.c
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2022-09-04 11:49:23 +0200
committerPhilip Langdale <github.philipl@overt.org>2022-09-10 12:32:52 -0700
commit3167a77aa38b3700c9a4459fa5fe2f65eef080a8 (patch)
tree06e2fae53fe11485939795f13ad71539f779bf22 /player/audio.c
parent221bf540a1a1dc13a6743f6fdd3b3e47c9f96db2 (diff)
downloadmpv-3167a77aa38b3700c9a4459fa5fe2f65eef080a8.tar.bz2
mpv-3167a77aa38b3700c9a4459fa5fe2f65eef080a8.tar.xz
audio: add AOCONTROL_UPDATE_MEDIA_ROLE
This is used to notify an AO about the type of media that is being played. Either a movie or music.
Diffstat (limited to 'player/audio.c')
-rw-r--r--player/audio.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/player/audio.c b/player/audio.c
index 06ea1262a6..9e1bb708d5 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -183,6 +183,30 @@ void update_playback_speed(struct MPContext *mpctx)
update_speed_filters(mpctx);
}
+static bool has_video_track(struct MPContext *mpctx)
+{
+ if (mpctx->vo_chain && mpctx->vo_chain->is_coverart)
+ return false;
+
+ for (int n = 0; n < mpctx->num_tracks; n++) {
+ struct track *track = mpctx->tracks[n];
+ if (track->type == STREAM_VIDEO && !track->attached_picture && !track->image)
+ return true;
+ }
+
+ return false;
+}
+
+void audio_update_media_role(struct MPContext *mpctx)
+{
+ if (!mpctx->ao)
+ return;
+
+ enum aocontrol_media_role role = has_video_track(mpctx) ?
+ AOCONTROL_MEDIA_ROLE_MOVIE : AOCONTROL_MEDIA_ROLE_MUSIC;
+ ao_control(mpctx->ao, AOCONTROL_UPDATE_MEDIA_ROLE, &role);
+}
+
static void ao_chain_reset_state(struct ao_chain *ao_c)
{
ao_c->last_out_pts = MP_NOPTS_VALUE;
@@ -471,6 +495,8 @@ static int reinit_audio_filters_and_output(struct MPContext *mpctx)
audio_update_volume(mpctx);
+ audio_update_media_role(mpctx);
+
// Almost nonsensical hack to deal with certain format change scenarios.
if (mpctx->audio_status == STATUS_PLAYING)
ao_start(mpctx->ao);