From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A37054452F for ; Sun, 18 Dec 2022 21:30:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 119E768B721; Sun, 18 Dec 2022 23:30:22 +0200 (EET) Received: from mail-40130.protonmail.ch (mail-40130.protonmail.ch [185.70.40.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A11E6883C8 for ; Sun, 18 Dec 2022 23:30:15 +0200 (EET) Date: Sun, 18 Dec 2022 21:30:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1671399013; x=1671658213; bh=V3LNq3oN2RzHfQ2emuyLtKk7uq+vID6TKPV7nuzla7s=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=nUOe4EtGD8j3rFLVdxbfF4fw7aWaqs/3HWa1o83gT3WWKNLe+x4YJimZwm59fn4L6 g8ia9wgyxhRMGqfiQTWwMiTpDve8FF+otrH8nWuqLEyGFnYExzb54KMzy3NxOgyCcy Cr/QS+r8OpBhdxSvsT83zf0615CsCZ3DtcVKxPIaAoqZyidK89eCglgrBWjD+4MHdJ NSE04tmI/T4Vfk6NYXEJvNaP4KmUSzrhTRk6so7VDz2jzmqc2VG2SkQhge72dgwTx6 0V5dbqdBHekSp8+aEYYcmvsB0v6UorNgjeYw6zjvfi/DKqIK22LTWD7QvDkBgRKJY1 MBAzqKQKMHeAg== To: ffmpeg-devel@ffmpeg.org From: Varun Dhar Message-ID: <20221218212952.1267905-1-vdhar1@protonmail.com> Feedback-ID: 63977915:user:proton MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavdevice/pulse_audio_enc: remove inevitable early return in mute state and volume change callback X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This patch removes an inevitable early return in libavdevice/pulse_audio_enc.c that prevents the user from accessing the volume or mute state of a pulseaudio output device. This happens because pulse_update_sink_input_info() passes a new pulseaudio context to pulse_audio_sink_input_cb(), causing the early return condition s->ctx != ctx (pulse_audio_enc.c:98) to always be true as ctx is a new context whereas s->ctx is the old context. As the early return is inevitable, the user is unable to access the volume or mute state. With this patch, the user will be able to access the volume or mute state of a pulseaudio output device. The following code is an example showing the issue. It creates a pulse output device, sets the volume, then gets the volume: #include #include #include #include #include //volume callback int get_volume(AVFormatContext *ctx, int type, void *data, size_t size){ if(type == AV_DEV_TO_APP_VOLUME_LEVEL_CHANGED){ *(double*)ctx->opaque = *(double*)data; return 0; } return AVERROR(ENOSYS); } int main(){ avdevice_register_all(); //set up pulse output stream AVFormatContext* ctx = NULL; avformat_alloc_output_context2(&ctx,NULL,"pulse",NULL); AVStream* stream = avformat_new_stream(ctx,NULL); AVCodecParameters* stream_params = stream->codecpar; stream_params->codec_type = AVMEDIA_TYPE_AUDIO; stream_params->codec_id = AV_CODEC_ID_PCM_S16LE; stream_params->sample_rate = 48000; stream_params->ch_layout.nb_channels = 2; stream_params->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; avformat_write_header(ctx,NULL); //set volume to 50% double vol = 0.5; avdevice_app_to_dev_control_message(ctx,AV_APP_TO_DEV_SET_VOLUME,&vol,sizeof(vol)); vol = 0; //get volume (should be 50% (0.5)) ctx->opaque = &vol; ctx->control_message_cb = &get_volume; avdevice_app_to_dev_control_message(ctx,AV_APP_TO_DEV_GET_VOLUME,NULL,0); assert(vol == 0.5); av_write_trailer(ctx); avformat_free_context(ctx); } _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".