Skip to content
This repository

[AE] Cleanup things found by Cppcheck #2393

Merged
5 commits merged into from about 1 year ago

3 participants

Andreas Zelend davilla Memphiz
Andreas Zelend
Collaborator

This time I checked the whole AudioEngine folder.

Andreas Zelend
Collaborator

Issues I haven't touched:

[Encoders\AEEncoderFFmpeg.cpp:245]: (portability) Casting from float* to integer* is not portable due to different binary data representations on different platforms.
[Engines\CoreAudio\CoreAudioAEHALIOS.cpp:1167]: (performance) Inefficient usage of string::find() in condition; string::compare() would be faster.
[Utils\AEBitstreamPacker.cpp:110] -> [Utils\AEBitstreamPacker.cpp:111]: (performance) Buffer 'm_trueHD' is being written before its old content has been used.

Don't know if these are problematic.

Memphiz
Owner

fine by me - but i guess @davilla will say something about that one :D

Collaborator

yes, iterators should always be pre-incremented.

Deleted user
ghost commented March 16, 2013

The content you are editing has changed. Reload the page and try again.

i guess somebody is afraid of evil casting games.

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user ghost merged commit 8f3fecd into from March 16, 2013
Deleted user ghost closed this March 16, 2013
Andreas Zelend
Collaborator

i guess somebody is afraid of evil casting games.

If I knew you were merging this, I would have removed the [REVIEW] tag from the commit message ;)
Thanks anyway!

Andreas Zelend ace20022 deleted the branch April 02, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6  xbmc/cores/AudioEngine/AEFactory.cpp
@@ -48,9 +48,8 @@ bool CAEFactory::LoadEngine()
48 48
 
49 49
   bool loaded = false;
50 50
 
51  
-  std::string engine;
52  
-
53 51
 #if defined(TARGET_LINUX)
  52
+  std::string engine;
54 53
   if (getenv("AE_ENGINE"))
55 54
   {
56 55
     engine = (std::string)getenv("AE_ENGINE");
@@ -203,9 +202,8 @@ void CAEFactory::VerifyOutputDevice(std::string &device, bool passthrough)
203 202
   EnumerateOutputDevices(devices, passthrough);
204 203
   std::string firstDevice;
205 204
 
206  
-  for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); deviceIt++)
  205
+  for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt)
207 206
   {
208  
-    std::string currentDevice = deviceIt->second;
209 207
     /* remember the first device so we can default to it if required */
210 208
     if (firstDevice.empty())
211 209
       firstDevice = deviceIt->second;
8  xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp
@@ -29,7 +29,13 @@
29 29
 #include <string.h>
30 30
 
31 31
 CAEEncoderFFmpeg::CAEEncoderFFmpeg():
32  
-  m_CodecCtx(NULL)
  32
+  m_CodecCtx      (NULL ),
  33
+  m_BitRate       (0    ),
  34
+  m_BufferSize    (0    ),
  35
+  m_OutputSize    (0    ),
  36
+  m_OutputRatio   (0.0  ),
  37
+  m_SampleRateMul (0.0  ),
  38
+  m_NeededFrames  (0    )
33 39
 {
34 40
 }
35 41
 
3  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALIOS.cpp
@@ -1098,7 +1098,8 @@ m_allowMixing       (false  ),
1098 1098
 m_encoded           (false  ),
1099 1099
 m_initVolume        (1.0f   ),
1100 1100
 m_NumLatencyFrames  (0      ),
1101  
-m_OutputBufferIndex (0      )
  1101
+m_OutputBufferIndex (0      ),
  1102
+m_ae                (NULL   )
1102 1103
 {
1103 1104
 }
1104 1105
 
3  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp
@@ -45,7 +45,8 @@ CCoreAudioAEHALOSX::CCoreAudioAEHALOSX() :
45 45
   m_encoded           (false  ),
46 46
   m_initVolume        (1.0f   ),
47 47
   m_NumLatencyFrames  (0      ),
48  
-  m_OutputBufferIndex (0      )
  48
+  m_OutputBufferIndex (0      ),
  49
+  m_ae                (NULL   )
49 50
 {
50 51
   m_AudioDevice   = new CCoreAudioDevice();
51 52
   m_OutputStream  = new CCoreAudioStream();
4  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp
@@ -58,12 +58,12 @@ void CCoreAudioMixMap::Rebuild(AudioChannelLayout& inLayout, AudioChannelLayout&
58 58
   // Try to find a 'well-known' matrix
59 59
   const AudioChannelLayout* layouts[] = {&inLayout, &outLayout};
60 60
   UInt32 propSize = 0;
61  
-  OSStatus ret = AudioFormatGetPropertyInfo(kAudioFormatProperty_MatrixMixMap,
  61
+  AudioFormatGetPropertyInfo(kAudioFormatProperty_MatrixMixMap,
62 62
     sizeof(layouts), layouts, &propSize);
63 63
   m_pMap = (Float32*)calloc(1,propSize);
64 64
 
65 65
   // Try and get a predefined mixmap
66  
-  ret = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap,
  66
+  OSStatus ret = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap,
67 67
     sizeof(layouts), layouts, &propSize, m_pMap);
68 68
   if (!ret)
69 69
   {
2  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioRingBuffer.h
@@ -156,7 +156,7 @@ class CoreAudioRingBuffer {
156 156
     unsigned int space = GetReadSize();
157 157
 
158 158
     //want to read more than we have written?
159  
-    if( space <= 0 )
  159
+    if( space == 0 )
160 160
     {
161 161
 #ifdef RING_BUFFER_DEBUG
162 162
       CLog::Log(LOGDEBUG, "CoereAudioRingBuffer: Can't read from empty buffer.");
1  xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp
@@ -81,6 +81,7 @@ CPulseAE::CPulseAE()
81 81
   m_Context = NULL;
82 82
   m_MainLoop = NULL;
83 83
   m_muted = false;
  84
+  m_Volume = 0.0f;
84 85
 }
85 86
 
86 87
 CPulseAE::~CPulseAE()
6  xbmc/cores/AudioEngine/Engines/PulseAE/PulseAESound.cpp
@@ -34,9 +34,11 @@ CPulseAESound::CPulseAESound(const std::string &filename, pa_context *context, p
34 34
   m_context        (context ),
35 35
   m_mainLoop       (mainLoop),
36 36
   m_stream         (NULL    ),
37  
-  m_op             (NULL    )
  37
+  m_op             (NULL    ),
  38
+  m_maxVolume      (0.0f    ),
  39
+  m_volume         (0.0f    ),
  40
+  m_pulseName      (StringUtils::CreateUUID())
38 41
 {
39  
-  m_pulseName = StringUtils::CreateUUID();
40 42
   m_wavLoader.Load(filename);
41 43
 }
42 44
 
6  xbmc/cores/AudioEngine/Engines/SoftAE/SoftAESound.cpp
@@ -34,12 +34,6 @@
34 34
 /* typecast AE to CSoftAE */
35 35
 #define AE (*((CSoftAE*)CAEFactory::GetEngine()))
36 36
 
37  
-typedef struct
38  
-{
39  
-  char     chunk_id[4];
40  
-  uint32_t chunksize;
41  
-} WAVE_CHUNK;
42  
-
43 37
 CSoftAESound::CSoftAESound(const std::string &filename) :
44 38
   IAESound         (filename),
45 39
   m_filename       (filename),
1  xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp
@@ -239,6 +239,7 @@ CAEChannelInfo::operator std::string()
239 239
 
240 240
 const char* CAEChannelInfo::GetChName(const enum AEChannel ch)
241 241
 {
  242
+  // Logical disjunction always evaluates to true: ch >= 0 || ch < 29.
242 243
   ASSERT(ch >= 0 || ch < AE_CH_MAX);
243 244
 
244 245
   static const char* channels[AE_CH_MAX] =
2  xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp
@@ -102,7 +102,6 @@ int CAEStreamInfo::AddData(uint8_t *data, unsigned int size, uint8_t **buffer/*
102 102
     return 0;
103 103
   }
104 104
 
105  
-  unsigned int consumed = 0;
106 105
   if (m_skipBytes)
107 106
   {
108 107
     unsigned int canSkip = std::min(size, m_skipBytes);
@@ -125,6 +124,7 @@ int CAEStreamInfo::AddData(uint8_t *data, unsigned int size, uint8_t **buffer/*
125 124
   }
126 125
   else
127 126
   {
  127
+    unsigned int consumed = 0;
128 128
     unsigned int offset = 0;
129 129
     unsigned int room = sizeof(m_buffer) - m_bufferSize;
130 130
     while(1)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.