From 8e16e829181c2b44abd45007bf72cdafbca6d0ec Mon Sep 17 00:00:00 2001 From: ace20022 Date: Fri, 8 Mar 2013 13:02:49 +0100 Subject: [PATCH 1/5] [AE] Initialize member vars. --- xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp | 8 +++++++- .../AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp | 3 ++- .../AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp | 3 ++- xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp | 1 + xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp | 6 ++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp index c611f15e8f5ac..59a37a5a65c3e 100644 --- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp +++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp @@ -29,7 +29,13 @@ #include CAEEncoderFFmpeg::CAEEncoderFFmpeg(): - m_CodecCtx(NULL) + m_CodecCtx (NULL ), + m_BitRate (0 ), + m_BufferSize (0 ), + m_OutputSize (0 ), + m_OutputRatio (0.0 ), + m_SampleRateMul (0.0 ), + m_NeededFrames (0 ) { } diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp index 10a764db434fa..41fd8831a745f 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp @@ -1098,7 +1098,8 @@ m_allowMixing (false ), m_encoded (false ), m_initVolume (1.0f ), m_NumLatencyFrames (0 ), -m_OutputBufferIndex (0 ) +m_OutputBufferIndex (0 ), +m_ae (NULL ) { } diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp index 52bf7702c3889..b43732f43e51e 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp @@ -45,7 +45,8 @@ CCoreAudioAEHALOSX::CCoreAudioAEHALOSX() : m_encoded (false ), m_initVolume (1.0f ), m_NumLatencyFrames (0 ), - m_OutputBufferIndex (0 ) + m_OutputBufferIndex (0 ), + m_ae (NULL ) { m_AudioDevice = new CCoreAudioDevice(); m_OutputStream = new CCoreAudioStream(); diff --git a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp index 1670e6e9e9961..b1efb4cdefeca 100644 --- a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp @@ -81,6 +81,7 @@ CPulseAE::CPulseAE() m_Context = NULL; m_MainLoop = NULL; m_muted = false; + m_Volume = 0.0f; } CPulseAE::~CPulseAE() diff --git a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp index 116d8c49c3722..3c98ea45ceac4 100644 --- a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp +++ b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp @@ -34,9 +34,11 @@ CPulseAESound::CPulseAESound(const std::string &filename, pa_context *context, p m_context (context ), m_mainLoop (mainLoop), m_stream (NULL ), - m_op (NULL ) + m_op (NULL ), + m_maxVolume (0.0f ), + m_volume (0.0f ), + m_pulseName (StringUtils::CreateUUID()) { - m_pulseName = StringUtils::CreateUUID(); m_wavLoader.Load(filename); } From d06259cdf841f09cf834dde1cc16ac5be631ea51 Mon Sep 17 00:00:00 2001 From: ace20022 Date: Fri, 8 Mar 2013 13:25:55 +0100 Subject: [PATCH 2/5] [AE] Clean up variables related stuff, e.g., scope, unused, check. --- xbmc/cores/AudioEngine/AEFactory.cpp | 4 +--- xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp | 4 ++-- .../cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h | 2 +- xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/xbmc/cores/AudioEngine/AEFactory.cpp b/xbmc/cores/AudioEngine/AEFactory.cpp index f0b4177901acf..e39b1eb32b2d4 100644 --- a/xbmc/cores/AudioEngine/AEFactory.cpp +++ b/xbmc/cores/AudioEngine/AEFactory.cpp @@ -48,9 +48,8 @@ bool CAEFactory::LoadEngine() bool loaded = false; - std::string engine; - #if defined(TARGET_LINUX) + std::string engine; if (getenv("AE_ENGINE")) { engine = (std::string)getenv("AE_ENGINE"); @@ -205,7 +204,6 @@ void CAEFactory::VerifyOutputDevice(std::string &device, bool passthrough) for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); deviceIt++) { - std::string currentDevice = deviceIt->second; /* remember the first device so we can default to it if required */ if (firstDevice.empty()) firstDevice = deviceIt->second; diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp index 02f7b485b56c3..93667e0d0bba4 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp @@ -58,12 +58,12 @@ void CCoreAudioMixMap::Rebuild(AudioChannelLayout& inLayout, AudioChannelLayout& // Try to find a 'well-known' matrix const AudioChannelLayout* layouts[] = {&inLayout, &outLayout}; UInt32 propSize = 0; - OSStatus ret = AudioFormatGetPropertyInfo(kAudioFormatProperty_MatrixMixMap, + AudioFormatGetPropertyInfo(kAudioFormatProperty_MatrixMixMap, sizeof(layouts), layouts, &propSize); m_pMap = (Float32*)calloc(1,propSize); // Try and get a predefined mixmap - ret = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap, + OSStatus ret = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap, sizeof(layouts), layouts, &propSize, m_pMap); if (!ret) { diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h index a390c11535554..9efad25615389 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h @@ -156,7 +156,7 @@ class CoreAudioRingBuffer { unsigned int space = GetReadSize(); //want to read more than we have written? - if( space <= 0 ) + if( space == 0 ) { #ifdef RING_BUFFER_DEBUG CLog::Log(LOGDEBUG, "CoereAudioRingBuffer: Can't read from empty buffer."); diff --git a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp index 876f5b6c159f7..cc536e0fbeacf 100644 --- a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp @@ -102,7 +102,6 @@ int CAEStreamInfo::AddData(uint8_t *data, unsigned int size, uint8_t **buffer/* return 0; } - unsigned int consumed = 0; if (m_skipBytes) { unsigned int canSkip = std::min(size, m_skipBytes); @@ -125,6 +124,7 @@ int CAEStreamInfo::AddData(uint8_t *data, unsigned int size, uint8_t **buffer/* } else { + unsigned int consumed = 0; unsigned int offset = 0; unsigned int room = sizeof(m_buffer) - m_bufferSize; while(1) From 3c14f5883cd8e39927f6b59b6cef8769d450eade Mon Sep 17 00:00:00 2001 From: ace20022 Date: Fri, 8 Mar 2013 14:15:46 +0100 Subject: [PATCH 3/5] [AE] Performance improvements. --- xbmc/cores/AudioEngine/AEFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/cores/AudioEngine/AEFactory.cpp b/xbmc/cores/AudioEngine/AEFactory.cpp index e39b1eb32b2d4..8c0cbb6e09f20 100644 --- a/xbmc/cores/AudioEngine/AEFactory.cpp +++ b/xbmc/cores/AudioEngine/AEFactory.cpp @@ -202,7 +202,7 @@ void CAEFactory::VerifyOutputDevice(std::string &device, bool passthrough) EnumerateOutputDevices(devices, passthrough); std::string firstDevice; - for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); deviceIt++) + for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt) { /* remember the first device so we can default to it if required */ if (firstDevice.empty()) From a371cd5a813c7e7bcaded648b8116307c87b2407 Mon Sep 17 00:00:00 2001 From: ace20022 Date: Mon, 11 Mar 2013 09:09:40 +0100 Subject: [PATCH 4/5] [SoftAESound] Remove unused struct. --- xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp index f9cace57f953a..84a7f464850d3 100644 --- a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp +++ b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp @@ -34,12 +34,6 @@ /* typecast AE to CSoftAE */ #define AE (*((CSoftAE*)CAEFactory::GetEngine())) -typedef struct -{ - char chunk_id[4]; - uint32_t chunksize; -} WAVE_CHUNK; - CSoftAESound::CSoftAESound(const std::string &filename) : IAESound (filename), m_filename (filename), From add8fab77bd3a646569164a79d96f1ee2b57ac0f Mon Sep 17 00:00:00 2001 From: ace20022 Date: Thu, 14 Mar 2013 17:50:01 +0100 Subject: [PATCH 5/5] [AEChannelInfo][*REVIEW*] What's the purpose of this assert? --- xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp index 265a33917192c..beaaa79adf1ba 100644 --- a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp @@ -239,6 +239,7 @@ CAEChannelInfo::operator std::string() const char* CAEChannelInfo::GetChName(const enum AEChannel ch) { + // Logical disjunction always evaluates to true: ch >= 0 || ch < 29. ASSERT(ch >= 0 || ch < AE_CH_MAX); static const char* channels[AE_CH_MAX] =