From patchwork Thu Dec 22 18:20:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gajjanag@yandex.com X-Patchwork-Id: 1890 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp783496vsb; Thu, 22 Dec 2016 10:25:58 -0800 (PST) X-Received: by 10.28.211.72 with SMTP id k69mr12381344wmg.138.1482431158086; Thu, 22 Dec 2016 10:25:58 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rd19si32742561wjb.206.2016.12.22.10.25.57; Thu, 22 Dec 2016 10:25:58 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@yandex.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=yandex.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFE1368A49F; Thu, 22 Dec 2016 20:25:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from forward19j.cmail.yandex.net (forward19j.cmail.yandex.net [5.255.227.238]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1381C68A413 for ; Thu, 22 Dec 2016 20:25:49 +0200 (EET) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward19j.cmail.yandex.net (Yandex) with ESMTP id 9082C21C1D; Thu, 22 Dec 2016 21:25:48 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 9E21F1300D7B; Thu, 22 Dec 2016 21:25:47 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Eyz3ZdcL4V-Pjf0wsc2; Thu, 22 Dec 2016 21:25:46 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1482431146; bh=J/oOg7YepYJjJNeworZKrY1Q7cmUXtqUBsWQXkS4v1w=; h=From:To:Cc:Subject:Date:Message-Id; b=oDtj759C8bnHvA3g7fe2v3fiWaEqAB2w3STrrUCJ+uiUKiyKHmRETEn/H4mcK7khI 0Jr5nFlAo4baUW2UznAs8zFAOVEsXxCoYL6QzhGXs7h9AoHxLY9NwdAme6ErFbnT0W iF1oThCz186pFs1uw+A6Pf1jzhu5qm0GIC2xlgJc= Authentication-Results: smtp1o.mail.yandex.net; dkim=pass header.i=@yandex.com X-Yandex-Suid-Status: 1 0,1 0 From: gajjanag@yandex.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Dec 2016 10:20:45 -0800 Message-Id: <20161222182045.15269-1-gajjanag@yandex.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] ffplay: add startup volume option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Ganesh Ajjanagadde MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Ganesh Ajjanagadde Fixes Ticket 5389. Signed-off-by: Ganesh Ajjanagadde --- doc/ffplay.texi | 4 ++++ ffplay.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 073b457256..378a229d67 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -62,6 +62,10 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) Seek by bytes. @item -nodisp Disable graphical display. +@item -volume +Set the startup volume. 0 means silence, 100 means no volume reduction or +amplification. Negative values are treated as 0, values above 100 are treated +as 100. @item -f @var{fmt} Force format. @item -window_title @var{title} diff --git a/ffplay.c b/ffplay.c index 911fd7f947..de603c0a27 100644 --- a/ffplay.c +++ b/ffplay.c @@ -322,6 +322,7 @@ static int subtitle_disable; static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = {0}; static int seek_by_bytes = -1; static int display_disable; +static int startup_volume = 100; static int show_status = 1; static int av_sync_type = AV_SYNC_AUDIO_MASTER; static int64_t start_time = AV_NOPTS_VALUE; @@ -3105,7 +3106,13 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat) init_clock(&is->audclk, &is->audioq.serial); init_clock(&is->extclk, &is->extclk.serial); is->audio_clock_serial = -1; - is->audio_volume = SDL_MIX_MAXVOLUME; + if (startup_volume < 0) + av_log(NULL, AV_LOG_WARNING, "-volume=%d < 0, setting to 0\n", startup_volume); + if (startup_volume > 100) + av_log(NULL, AV_LOG_WARNING, "-volume=%d > 100, setting to 100\n", startup_volume); + startup_volume = av_clip(startup_volume, 0, 100); + startup_volume = av_clip(SDL_MIX_MAXVOLUME * startup_volume / 100.0, 0, SDL_MIX_MAXVOLUME); + is->audio_volume = startup_volume; is->muted = 0; is->av_sync_type = av_sync_type; is->read_tid = SDL_CreateThread(read_thread, "read_thread", is); @@ -3586,6 +3593,7 @@ static const OptionDef options[] = { { "t", HAS_ARG, { .func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, + { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" }, { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" },