From 2baa7a37fbc82d2eaf72f11d04deaa16fa66e0af Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 20 Sep 2026 12:29:00 -0400 Subject: [PATCH] refactor: stop passing VideoStore an audio decoder it never used VideoStore took an AVCodecContext for the input audio and ignored it: the member was initialised to nullptr and open() builds its own from audio_in_stream's codecpar, with its own codec lookup, time_base and avcodec_open2, and frees it in the destructor. So the parameter described a relationship that did not exist, and following it backwards -- through Monitor::GetAudioCodecContext() to the camera -- suggested the camera's audio decoder was feeding recording. It was not. Drop the parameter and say beside the member where the context actually comes from. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_015Y6FieTwEXuLhhR4e2yiax --- src/zm_event.cpp | 1 - src/zm_videostore.cpp | 3 ++- src/zm_videostore.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 5ddd255d2..a7e615f96 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -862,7 +862,6 @@ void Event::Run() { monitor->GetVideoStream(), monitor->GetVideoCodecContext(), ( monitor->RecordAudio() ? monitor->GetAudioStream() : nullptr ), - ( monitor->RecordAudio() ? monitor->GetAudioCodecContext() : nullptr ), monitor ); if (!videoStore->open()) { diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index d94582964..8e88cfcc9 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -43,7 +43,6 @@ VideoStore::VideoStore( AVStream *p_video_in_stream, AVCodecContext *p_video_in_ctx, AVStream *p_audio_in_stream, - AVCodecContext *p_audio_in_ctx, Monitor *p_monitor ) : chosen_codec_data(nullptr), @@ -57,6 +56,8 @@ VideoStore::VideoStore( video_in_stream(p_video_in_stream), audio_in_stream(p_audio_in_stream), audio_in_codec(nullptr), + // Opened in open() from audio_in_stream's codecpar, not handed in. The + // caller used to pass a context as well and this ignored it. audio_in_ctx(nullptr), audio_out_codec(nullptr), audio_out_ctx(nullptr), diff --git a/src/zm_videostore.h b/src/zm_videostore.h index bca94d39e..bf5a7181a 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -138,7 +138,6 @@ class VideoStore { AVStream *video_in_stream, AVCodecContext *video_in_ctx, AVStream *audio_in_stream, - AVCodecContext *audio_in_ctx, Monitor * p_monitor); ~VideoStore(); bool open();