Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2380 from ace20022/warnings

[AESinks] Fix things found by Cppcheck
  • Loading branch information...
commit 6b319a1dd9505c749b6956f713e98d7b940579db 2 parents 4081044 + 2279652
@davilla davilla authored
View
13 xbmc/cores/AudioEngine/AEAudioFormat.h
@@ -70,7 +70,7 @@ enum AEDataFormat
/**
* The audio format structure that fully defines a stream's audio information
*/
-typedef struct {
+typedef struct AEAudioFormat{
/**
* The stream's data format (eg, AE_FMT_S16LE)
*/
@@ -105,5 +105,16 @@ typedef struct {
* The size of one frame in bytes
*/
unsigned int m_frameSize;
+
+ AEAudioFormat()
+ {
+ m_dataFormat = AE_FMT_INVALID;
+ m_sampleRate = 0;
+ m_encodedRate = 0;
+ m_frames = 0;
+ m_frameSamples = 0;
+ m_frameSize = 0;
+ }
+
} AEAudioFormat;
View
4 xbmc/cores/AudioEngine/Engines/PulseAE/PulseAEStream.cpp
@@ -556,8 +556,10 @@ void CPulseAEStream::StreamDrainComplete(pa_stream *s, int success, void *userda
{
CPulseAEStream *stream = (CPulseAEStream *)userdata;
if(stream)
+ {
stream->SetDrained();
- pa_threaded_mainloop_signal(stream->m_MainLoop, 0);
+ pa_threaded_mainloop_signal(stream->m_MainLoop, 0);
+ }
}
void CPulseAEStream::ProcessCallbacks()
View
2  xbmc/cores/AudioEngine/Interfaces/AESink.h
@@ -49,7 +49,7 @@ class IAESink
/*
Return true if the supplied format and device are compatible with the current open sink
*/
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device) = 0;
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device) = 0;
/*
This method returns the time in seconds that it will take
View
8 xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
@@ -66,7 +66,11 @@ static unsigned int ALSASampleRateList[] =
};
CAESinkALSA::CAESinkALSA() :
- m_pcm(NULL)
+ m_pcm(NULL),
+ m_bufferSize(0),
+ m_formatSampleRateMul(0.0),
+ m_passthrough(false),
+ m_timeout(0)
{
/* ensure that ALSA has been initialized */
if (!snd_config)
@@ -210,7 +214,7 @@ bool CAESinkALSA::Initialize(AEAudioFormat &format, std::string &device)
return true;
}
-bool CAESinkALSA::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkALSA::IsCompatible(const AEAudioFormat format, const std::string &device)
{
return (
/* compare against the requested format and the real format */
View
2  xbmc/cores/AudioEngine/Sinks/AESinkALSA.h
@@ -41,7 +41,7 @@ class CAESinkALSA : public IAESink
virtual bool Initialize (AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual void Stop ();
virtual double GetDelay ();
View
11 xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
@@ -74,6 +74,15 @@ CAESinkAUDIOTRACK::CAESinkAUDIOTRACK()
{
m_sinkbuffer = NULL;
m_alignedS16LE = NULL;
+ m_volume_changed = false;
+ m_min_frames = 0;
+ m_sink_frameSize = 0;
+ m_sinkbuffer_sec = 0.0;
+ m_sinkbuffer_sec_per_byte = 0.0;
+ m_draining = false;
+ m_audiotrackbuffer_sec = 0.0;
+ m_audiotrack_empty_sec = 0.0;
+ m_volume = 0.0;
#if defined(HAS_AMLPLAYER)
aml_cpufreq_limit(true);
#endif
@@ -151,7 +160,7 @@ void CAESinkAUDIOTRACK::Deinitialize()
_aligned_free(m_alignedS16LE), m_alignedS16LE = NULL;
}
-bool CAESinkAUDIOTRACK::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkAUDIOTRACK::IsCompatible(const AEAudioFormat format, const std::string &device)
{
return ((m_format.m_sampleRate == format.m_sampleRate) &&
(m_format.m_dataFormat == format.m_dataFormat) &&
View
2  xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
@@ -34,7 +34,7 @@ class CAESinkAUDIOTRACK : public CThread, public IAESink
virtual bool Initialize(AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual double GetDelay ();
virtual double GetCacheTime ();
View
16 xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
@@ -121,7 +121,11 @@ CAESinkDirectSound::CAESinkDirectSound() :
m_CacheLen (0 ),
m_dwChunkSize (0 ),
m_dwBufferLen (0 ),
- m_BufferTimeouts(0 )
+ m_BufferTimeouts(0 ),
+ m_AvgBytesPerSec(0 ),
+ m_dwFrameSize (0 ),
+ m_LastCacheCheck(0 ),
+ m_running (false)
{
m_channelLayout.Reset();
}
@@ -143,7 +147,7 @@ bool CAESinkDirectSound::Initialize(AEAudioFormat &format, std::string &device)
std::string deviceFriendlyName;
DirectSoundEnumerate(DSEnumCallback, &DSDeviceList);
- for (std::list<DSDevice>::iterator itt = DSDeviceList.begin(); itt != DSDeviceList.end(); itt++)
+ for (std::list<DSDevice>::iterator itt = DSDeviceList.begin(); itt != DSDeviceList.end(); ++itt)
{
if ((*itt).lpGuid)
{
@@ -322,7 +326,7 @@ void CAESinkDirectSound::Deinitialize()
m_dwBufferLen = 0;
}
-bool CAESinkDirectSound::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkDirectSound::IsCompatible(const AEAudioFormat format, const std::string &device)
{
if (!m_initialized || m_isDirtyDS)
return false;
@@ -471,7 +475,6 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
IMMDeviceEnumerator* pEnumerator = NULL;
IMMDeviceCollection* pEnumDevices = NULL;
- WAVEFORMATEX* pwfxex = NULL;
HRESULT hr;
/* See if we are on Windows XP */
@@ -484,7 +487,7 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
std::list<DSDevice> DSDeviceList;
DirectSoundEnumerate(DSEnumCallback, &DSDeviceList);
- for(std::list<DSDevice>::iterator itt = DSDeviceList.begin(); itt != DSDeviceList.end(); itt++)
+ for(std::list<DSDevice>::iterator itt = DSDeviceList.begin(); itt != DSDeviceList.end(); ++itt)
{
if (UuidToString((*itt).lpGuid, &cszGUID) != RPC_S_OK)
continue; /* could not convert GUID to string - skip device */
@@ -637,6 +640,7 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
{
deviceInfoList.erase(itt);
deviceInfoList.insert(deviceInfoList.begin(), devInfo);
+ break;
}
}
}
@@ -749,8 +753,6 @@ unsigned int CAESinkDirectSound::GetSpace()
void CAESinkDirectSound::AEChannelsFromSpeakerMask(DWORD speakers)
{
- int j = 0;
-
m_channelLayout.Reset();
for (int i = 0; i < DS_SPEAKER_COUNT; i++)
View
2  xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.h
@@ -36,7 +36,7 @@ class CAESinkDirectSound : public IAESink
virtual bool Initialize (AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual void Stop ();
virtual double GetDelay ();
View
2  xbmc/cores/AudioEngine/Sinks/AESinkNULL.cpp
@@ -75,7 +75,7 @@ void CAESinkNULL::Deinitialize()
StopThread();
}
-bool CAESinkNULL::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkNULL::IsCompatible(const AEAudioFormat format, const std::string &device)
{
return ((m_format.m_sampleRate == format.m_sampleRate) &&
(m_format.m_dataFormat == format.m_dataFormat) &&
View
2  xbmc/cores/AudioEngine/Sinks/AESinkNULL.h
@@ -33,7 +33,7 @@ class CAESinkNULL : public CThread, public IAESink
virtual bool Initialize(AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual double GetDelay ();
virtual double GetCacheTime ();
View
6 xbmc/cores/AudioEngine/Sinks/AESinkOSS.cpp
@@ -64,6 +64,7 @@ static int OSSSampleRateList[] =
CAESinkOSS::CAESinkOSS()
{
+ m_fd = 0;
}
CAESinkOSS::~CAESinkOSS()
@@ -71,7 +72,7 @@ CAESinkOSS::~CAESinkOSS()
Deinitialize();
}
-std::string CAESinkOSS::GetDeviceUse(const AEAudioFormat format, const std::string device)
+std::string CAESinkOSS::GetDeviceUse(const AEAudioFormat format, const std::string &device)
{
#ifdef OSS4
if (AE_IS_RAW(format.m_dataFormat))
@@ -287,7 +288,6 @@ bool CAESinkOSS::Initialize(AEAudioFormat &format, std::string &device)
if (ioctl(m_fd, SNDCTL_DSP_GET_CHNORDER, &order) == -1)
{
CLog::Log(LOGWARNING, "CAESinkOSS::Initialize - Failed to get the channel order, assuming CHNORDER_NORMAL");
- order = CHNORDER_NORMAL;
}
}
#endif
@@ -367,7 +367,7 @@ inline CAEChannelInfo CAESinkOSS::GetChannelLayout(AEAudioFormat format)
return info;
}
-bool CAESinkOSS::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkOSS::IsCompatible(const AEAudioFormat format, const std::string &device)
{
AEAudioFormat tmp = format;
tmp.m_channelLayout = GetChannelLayout(format);
View
4 xbmc/cores/AudioEngine/Sinks/AESinkOSS.h
@@ -35,7 +35,7 @@ class CAESinkOSS : public IAESink
virtual bool Initialize (AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual void Stop ();
virtual double GetDelay ();
@@ -51,6 +51,6 @@ class CAESinkOSS : public IAESink
AEAudioFormat m_format;
CAEChannelInfo GetChannelLayout(AEAudioFormat format);
- std::string GetDeviceUse(const AEAudioFormat format, const std::string device);
+ std::string GetDeviceUse(const AEAudioFormat format, const std::string &device);
};
View
2  xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp
@@ -56,7 +56,7 @@ void CAESinkProfiler::Deinitialize()
{
}
-bool CAESinkProfiler::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkProfiler::IsCompatible(const AEAudioFormat format, const std::string &device)
{
if (AE_IS_RAW(format.m_dataFormat))
return false;
View
2  xbmc/cores/AudioEngine/Sinks/AESinkProfiler.h
@@ -34,7 +34,7 @@ class CAESinkProfiler : public IAESink
virtual bool Initialize (AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual double GetDelay ();
virtual double GetCacheTime () { return 0.0; }
View
30 xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
@@ -187,7 +187,11 @@ CAESinkWASAPI::CAESinkWASAPI() :
m_encodedSampleRate(0),
m_uiBufferLen(0),
m_avgTimeWaiting(50),
- m_isDirty(false)
+ m_isDirty(false),
+ sinkReqFormat(AE_FMT_INVALID),
+ sinkRetFormat(AE_FMT_INVALID),
+ m_isSuspended(false),
+ m_sinkLatency(0.0)
{
m_channelLayout.Reset();
}
@@ -350,7 +354,7 @@ void CAESinkWASAPI::Deinitialize()
m_initialized = false;
}
-bool CAESinkWASAPI::IsCompatible(const AEAudioFormat format, const std::string device)
+bool CAESinkWASAPI::IsCompatible(const AEAudioFormat format, const std::string &device)
{
if (!m_initialized || m_isDirty)
return false;
@@ -472,7 +476,7 @@ unsigned int CAESinkWASAPI::AddPackets(uint8_t *data, unsigned int frames, bool
return INT_MAX;
}
hr = m_pAudioClient->Start(); //start the audio driver running
- if FAILED(hr)
+ if (FAILED(hr))
CLog::Log(LOGERROR, __FUNCTION__": AudioClient Start Failed");
m_running = true; //signal that we're processing frames
return g_advancedSettings.m_streamSilence ? NumFramesRequested : 0U;
@@ -567,7 +571,6 @@ void CAESinkWASAPI::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
CAEChannelInfo deviceChannels;
WAVEFORMATEXTENSIBLE wfxex = {0};
- WAVEFORMATEX* pwfxex = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
@@ -890,17 +893,8 @@ void CAESinkWASAPI::BuildWaveFormatExtensible(AEAudioFormat &format, WAVEFORMATE
wfxex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
if (format.m_dataFormat == AE_FMT_AC3 || format.m_dataFormat == AE_FMT_DTS)
{
- wfxex.dwChannelMask = bool (format.m_channelLayout.Count() == 2) ? KSAUDIO_SPEAKER_STEREO : KSAUDIO_SPEAKER_5POINT1;
-
- if (format.m_dataFormat == AE_FMT_AC3)
- {
- wfxex.SubFormat = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL;
- }
- else
- {
- wfxex.SubFormat = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL;
- }
-
+ wfxex.dwChannelMask = bool (format.m_channelLayout.Count() == 2) ? KSAUDIO_SPEAKER_STEREO : KSAUDIO_SPEAKER_5POINT1;
+ wfxex.SubFormat = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL;
wfxex.Format.wBitsPerSample = 16;
wfxex.Samples.wValidBitsPerSample = 16;
wfxex.Format.nChannels = (WORD)format.m_channelLayout.Count();
@@ -1168,6 +1162,12 @@ bool CAESinkWASAPI::InitializeExclusive(AEAudioFormat &format)
/* second buffer is filled. Multiplying the returned 100ns intervals by 0.0000002 */
/* is handles both the unit conversion and twin buffers. */
hr = m_pAudioClient->GetStreamLatency(&hnsLatency);
+ if (FAILED(hr))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": GetStreamLatency Failed : %s", WASAPIErrToStr(hr));
+ return false;
+ }
+
m_sinkLatency = hnsLatency * 0.0000002;
CLog::Log(LOGINFO, __FUNCTION__": WASAPI Exclusive Mode Sink Initialized using: %s, %d, %d",
View
2  xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.h
@@ -37,7 +37,7 @@ class CAESinkWASAPI : public IAESink
virtual bool Initialize (AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
- virtual bool IsCompatible(const AEAudioFormat format, const std::string device);
+ virtual bool IsCompatible(const AEAudioFormat format, const std::string &device);
virtual double GetDelay ();
virtual double GetCacheTime ();
Please sign in to comment.
Something went wrong with that request. Please try again.