From 21df1d5ec5681c744ba8679c8484c3e451d36f13 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 26 Nov 2010 20:52:35 +0000 Subject: [PATCH] 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 --- command.c | 14 +++++++------- mp_core.h | 1 - mplayer.c | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/command.c b/command.c index 4ffe29a351..798842b9cd 100644 --- a/command.c +++ b/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) { diff --git a/mp_core.h b/mp_core.h index 206cbdacd3..c25063368b 100644 --- a/mp_core.h +++ b/mp_core.h @@ -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); diff --git a/mplayer.c b/mplayer.c index 4a36afd2f2..8386bb1afd 100644 --- a/mplayer.c +++ b/mplayer.c @@ -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;