audio: add AO_INIT_MEDIA_ROLE_MUSIC
This allows the AO to set the media role directly during init().
This commit is contained in:
1 parent
1bbc7a2cd0
commit
6e023547ea
2 files changed
+19
No files matched your search
@@ -56,6 +56,8 @@ enum {
|
||||
AO_INIT_STREAM_SILENCE = 1 << 2,
|
||||
// Force exclusive mode, i.e. lock out the system mixer.
|
||||
AO_INIT_EXCLUSIVE = 1 << 3,
|
||||
// Initialize with music role.
|
||||
AO_INIT_MEDIA_ROLE_MUSIC = 1 << 4,
|
||||
};
|
||||
|
||||
struct ao_device_desc {
|
||||
|
||||
@@ -190,6 +190,20 @@ 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;
|
||||
}
|
||||
|
||||
static void ao_chain_reset_state(struct ao_chain *ao_c)
|
||||
{
|
||||
ao_c->last_out_pts = MP_NOPTS_VALUE;
|
||||
@@ -416,6 +430,9 @@ static int reinit_audio_filters_and_output(struct MPContext *mpctx)
|
||||
opts->audio_output_channels.num_chmaps);
|
||||
}
|
||||
|
||||
if (!has_video_track(mpctx))
|
||||
ao_flags |= AO_INIT_MEDIA_ROLE_MUSIC;
|
||||
|
||||
mpctx->ao_filter_fmt = out_fmt;
|
||||
|
||||
mpctx->ao = ao_init_best(mpctx->global, ao_flags, mp_wakeup_core_cb,
|
||||
|
||||
Reference in new issue
Block a user