From 5e0051598aa330ac58256acae607de79744987a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Wed, 27 Sep 2023 21:31:22 -0400 Subject: [PATCH] audio: use av_samples_set_silence Change-Id: Ia2f2eada788e6dd81e2442a0f384943ea3efa8ad --- src/media/audio/audioloop.cpp | 1 + src/media/audio/opensl/audio_player.cpp | 2 +- src/media/audio/opensl/audio_recorder.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/media/audio/audioloop.cpp b/src/media/audio/audioloop.cpp index 333e21534b..bf767e374c 100644 --- a/src/media/audio/audioloop.cpp +++ b/src/media/audio/audioloop.cpp @@ -65,6 +65,7 @@ AudioLoop::getNext(AVFrame* output, bool mute) if (buf_samples == 0) { JAMI_ERR("Audio loop size is 0"); + av_samples_set_silence(output->data, 0, output->nb_samples, format_.nb_channels, format_.sampleFormat); return; } else if (pos >= buf_samples) { JAMI_ERR("Invalid loop position %zu", pos); diff --git a/src/media/audio/opensl/audio_player.cpp b/src/media/audio/opensl/audio_player.cpp index ab8c26ca52..c3967c2b32 100644 --- a/src/media/audio/opensl/audio_player.cpp +++ b/src/media/audio/opensl/audio_player.cpp @@ -168,7 +168,7 @@ AudioPlayer::AudioPlayer(jami::AudioFormat sampleFormat, silentBuf_ = {(format_pcm.containerSize >> 3) * format_pcm.numChannels * bufSize}; silentBuf_.size_ = silentBuf_.cap_; - memset(silentBuf_.buf_, 0, silentBuf_.cap_); + av_samples_set_silence(&silentBuf_.buf_, 0, (int)bufSize, (int)sampleInfo_.nb_channels, sampleInfo_.sampleFormat); } AudioPlayer::~AudioPlayer() diff --git a/src/media/audio/opensl/audio_recorder.cpp b/src/media/audio/opensl/audio_recorder.cpp index 9686573a4f..9e9b01e895 100644 --- a/src/media/audio/opensl/audio_recorder.cpp +++ b/src/media/audio/opensl/audio_recorder.cpp @@ -202,7 +202,7 @@ AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, size_t bufSize, SLE silentBuf_ = {(format_pcm.containerSize >> 3) * format_pcm.numChannels * bufSize}; silentBuf_.size_ = silentBuf_.cap_; - memset(silentBuf_.buf_, 0, silentBuf_.cap_); + av_samples_set_silence(&silentBuf_.buf_, 0, (int)bufSize, (int)sampleInfo_.nb_channels, sampleInfo_.sampleFormat); } bool -- GitLab