Skip to content

Commit

Permalink
Limit volume measurement to the first 8 channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Jul 29, 2022
1 parent 862b2b7 commit 82c1e06
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion decoder/LAVAudio/LAVAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ HRESULT CLAVAudio::GetChannelVolumeAverage(WORD nChannel, float *pfDb)
{
return E_UNEXPECTED;
}
if (nChannel >= m_OutputQueue.wChannels || nChannel >= 8)
if (nChannel >= m_OutputQueue.wChannels || nChannel >= MAX_VOLUME_STAT_CHANNEL)
{
return E_INVALIDARG;
}
Expand Down
4 changes: 3 additions & 1 deletion decoder/LAVAudio/LAVAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
// Maximum desync that we attribute to jitter before re-syncing (10ms)
#define MAX_JITTER_DESYNC 100000i64

#define MAX_VOLUME_STAT_CHANNEL 8

//////////////////// End Configuration //////////////////////

#define AV_CODEC_ID_PCM_SxxBE (AVCodecID)0x19001
Expand Down Expand Up @@ -318,7 +320,7 @@ class __declspec(uuid("E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491")) CLAVAudio
BOOL m_bRuntimeConfig = FALSE;

BOOL m_bVolumeStats = FALSE; // Volume Stats gathering enabled
FloatingAverage<float> m_faVolume[8]; // Floating Average for volume (8 channels)
FloatingAverage<float> m_faVolume[MAX_VOLUME_STAT_CHANNEL]; // Floating Average for volume (8 channels)

BOOL m_bQueueResync = FALSE;
BOOL m_bResyncTimestamp = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion decoder/LAVAudio/Media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void CLAVAudio::UpdateVolumeStats(const BufferDetails &buffer)
}
}

for (int ch = 0; ch < buffer.wChannels; ++ch)
for (int ch = 0; ch < min(buffer.wChannels, MAX_VOLUME_STAT_CHANNEL); ++ch)
{
if (fChAvg[ch] > FLT_EPSILON)
{
Expand Down

0 comments on commit 82c1e06

Please sign in to comment.