mirror of
https://github.com/mpv-player/mpv
synced 2024-11-18 21:16:10 +01:00
core: avoid using build_afilter_chain() directly
build_afilter_chain is not safe to use directly, thus make it static and instead use reinit_audio_chain which should have better error handling. Fixes a crash with -af hrtf and changing speed, audio will still stop playing though. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32648 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a9b5a9348d
commit
21df1d5ec5
14
command.c
14
command.c
@ -263,14 +263,14 @@ static int mp_property_playback_speed(m_option_t *prop, int action,
|
||||
return M_PROPERTY_ERROR;
|
||||
M_PROPERTY_CLAMP(prop, *(float *) arg);
|
||||
opts->playback_speed = *(float *) arg;
|
||||
build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_STEP_UP:
|
||||
case M_PROPERTY_STEP_DOWN:
|
||||
opts->playback_speed += (arg ? *(float *) arg : 0.1) *
|
||||
(action == M_PROPERTY_STEP_DOWN ? -1 : 1);
|
||||
M_PROPERTY_CLAMP(prop, opts->playback_speed);
|
||||
build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
return m_property_float_range(prop, action, arg, &opts->playback_speed);
|
||||
@ -2821,7 +2821,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
case MP_CMD_SPEED_INCR:{
|
||||
float v = cmd->args[0].v.f;
|
||||
opts->playback_speed += v;
|
||||
build_afilter_chain(mpctx, sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f",
|
||||
opts->playback_speed);
|
||||
} break;
|
||||
@ -2829,7 +2829,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
case MP_CMD_SPEED_MULT:{
|
||||
float v = cmd->args[0].v.f;
|
||||
opts->playback_speed *= v;
|
||||
build_afilter_chain(mpctx, sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f",
|
||||
opts->playback_speed);
|
||||
} break;
|
||||
@ -2837,7 +2837,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
case MP_CMD_SPEED_SET:{
|
||||
float v = cmd->args[0].v.f;
|
||||
opts->playback_speed = v;
|
||||
build_afilter_chain(mpctx, sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f",
|
||||
opts->playback_speed);
|
||||
} break;
|
||||
@ -3513,7 +3513,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
else
|
||||
af_add(mpctx->mixer.afilter, af_command);
|
||||
}
|
||||
build_afilter_chain(mpctx, sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
free(af_args);
|
||||
}
|
||||
break;
|
||||
@ -3522,7 +3522,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
break;
|
||||
af_uninit(mpctx->mixer.afilter);
|
||||
af_init(mpctx->mixer.afilter);
|
||||
build_afilter_chain(mpctx, sh_audio, &ao_data);
|
||||
reinit_audio_chain(mpctx);
|
||||
break;
|
||||
case MP_CMD_AF_CMDLINE:
|
||||
if (sh_audio) {
|
||||
|
@ -208,7 +208,6 @@ extern int file_filter;
|
||||
extern int forced_subs_only;
|
||||
|
||||
struct ao_data;
|
||||
int build_afilter_chain(struct MPContext *mpctx, struct sh_audio *sh_audio, struct ao_data *ao_data);
|
||||
void uninit_player(struct MPContext *mpctx, unsigned int mask);
|
||||
void reinit_audio_chain(struct MPContext *mpctx);
|
||||
void init_vo_spudec(struct MPContext *mpctx);
|
||||
|
@ -1373,7 +1373,8 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame)
|
||||
* \param sh_audio describes the requested input format of the chain.
|
||||
* \param ao_data describes the requested output format of the chain.
|
||||
*/
|
||||
int build_afilter_chain(struct MPContext *mpctx, sh_audio_t *sh_audio, ao_data_t *ao_data)
|
||||
static int build_afilter_chain(struct MPContext *mpctx, sh_audio_t *sh_audio,
|
||||
ao_data_t *ao_data)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
int new_srate;
|
||||
|
Loading…
Reference in New Issue
Block a user