[FFmpeg-devel] [PATCH] ffplay: add support for interactive volume control
Timothy Gu
timothygu99 at gmail.com
Sat Sep 26 17:16:54 CEST 2015
On Sat, Sep 26, 2015 at 7:47 AM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> diff --git a/ffplay.c b/ffplay.c
> index d302793..4f3322b 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -1348,6 +1353,25 @@ static void toggle_pause(VideoState *is)
> is->step = 0;
> }
>
> +static void toggle_mute(VideoState *is)
> +{
> + is->muted = !is->muted;
> +}
> +
> +static void update_volume(VideoState *is, int sign, int step)
> +{
> + if (sign > 0) {
> + is->audio_volume += step;
> + if (is->audio_volume > SDL_MIX_MAXVOLUME)
> + is->audio_volume = SDL_MIX_MAXVOLUME;
> + }
> + else {
> + is->audio_volume -= step;
> + if (is->audio_volume < 0)
> + is->audio_volume = 0;
> + }
> +}
AV_CLIP?
> +
> static void step_to_next_frame(VideoState *is)
> {
> /* if the stream is paused unpause it, then step */
> @@ -2447,7 +2471,10 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
> len1 = is->audio_buf_size - is->audio_buf_index;
> if (len1 > len)
> len1 = len;
> - memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
> + if (is->muted)
> + SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, 0);
memset?
> + else
> + SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
> len -= len1;
> stream += len1;
> is->audio_buf_index += len1;
> @@ -3740,6 +3780,8 @@ int main(int argc, char **argv)
> SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
> SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
>
> + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
> +
> if (av_lockmgr_register(lockmgr)) {
> av_log(NULL, AV_LOG_FATAL, "Could not initialize lock manager!\n");
> do_exit(NULL);
Separate patch please.
Timothy
More information about the ffmpeg-devel
mailing list