Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AESinks] Fix things found by Cppcheck #2380

Merged
merged 2 commits into from Mar 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion xbmc/cores/AudioEngine/AEAudioFormat.h
Expand Up @@ -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)
*/
Expand Down Expand Up @@ -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;

4 changes: 3 additions & 1 deletion xbmc/cores/AudioEngine/Engines/PulseAE/PulseAEStream.cpp
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Interfaces/AESink.h
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkALSA.h
Expand Up @@ -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 ();
Expand Down
11 changes: 10 additions & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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) &&
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
Expand Up @@ -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 ();
Expand Down
16 changes: 9 additions & 7 deletions xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
Expand Up @@ -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();
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down Expand Up @@ -637,6 +640,7 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
{
deviceInfoList.erase(itt);
deviceInfoList.insert(deviceInfoList.begin(), devInfo);
break;
}
}
}
Expand Down Expand Up @@ -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++)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.h
Expand Up @@ -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 ();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkNULL.cpp
Expand Up @@ -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) &&
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkNULL.h
Expand Up @@ -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 ();
Expand Down
6 changes: 3 additions & 3 deletions xbmc/cores/AudioEngine/Sinks/AESinkOSS.cpp
Expand Up @@ -64,14 +64,15 @@ static int OSSSampleRateList[] =

CAESinkOSS::CAESinkOSS()
{
m_fd = 0;
}

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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/AudioEngine/Sinks/AESinkOSS.h
Expand Up @@ -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 ();
Expand All @@ -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);
};

2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkProfiler.h
Expand Up @@ -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; }
Expand Down
30 changes: 15 additions & 15 deletions xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.h
Expand Up @@ -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 ();
Expand Down