mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
221bf540a1
commit
3167a77aa3
|
@ -35,6 +35,8 @@ enum aocontrol {
|
|||
AOCONTROL_SET_MUTE,
|
||||
// Has char* as argument, which contains the desired stream title.
|
||||
AOCONTROL_UPDATE_STREAM_TITLE,
|
||||
// Has enum aocontrol_media_role* argument, which contains the current media role
|
||||
AOCONTROL_UPDATE_MEDIA_ROLE,
|
||||
};
|
||||
|
||||
// If set, then the queued audio data is the last. Note that after a while, new
|
||||
|
@ -64,6 +66,11 @@ typedef struct ao_control_vol {
|
|||
float right;
|
||||
} ao_control_vol_t;
|
||||
|
||||
enum aocontrol_media_role {
|
||||
AOCONTROL_MEDIA_ROLE_MUSIC,
|
||||
AOCONTROL_MEDIA_ROLE_MOVIE,
|
||||
};
|
||||
|
||||
struct ao_device_desc {
|
||||
const char *name; // symbolic name; will be set on ao->device
|
||||
const char *desc; // verbose human readable name
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6539,6 +6539,9 @@ static void command_event(struct MPContext *mpctx, int event, void *arg)
|
|||
}
|
||||
if (event == MP_EVENT_WIN_STATE2)
|
||||
ctx->cached_window_scale = 0;
|
||||
|
||||
if (event == MPV_EVENT_FILE_LOADED)
|
||||
audio_update_media_role(mpctx);
|
||||
}
|
||||
|
||||
void handle_command_updates(struct MPContext *mpctx)
|
||||
|
|
|
@ -487,6 +487,7 @@ int init_audio_decoder(struct MPContext *mpctx, struct track *track);
|
|||
void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track);
|
||||
void audio_update_volume(struct MPContext *mpctx);
|
||||
void audio_update_balance(struct MPContext *mpctx);
|
||||
void audio_update_media_role(struct MPContext *mpctx);
|
||||
void reload_audio_output(struct MPContext *mpctx);
|
||||
void audio_start_ao(struct MPContext *mpctx);
|
||||
|
||||
|
|
Loading…
Reference in New Issue