Make waveform and spectrum visualizations optional and stop installing unwanted stuff
-Subproject commit 68a27fc3355e7f6fd87e1fc5644ac37bc055e344
+Subproject commit c716b54af6adc62dc859c8f60fe65f611e230e33
virtual int av_get_channel_layout_channel_index (uint64_t channel_layout, uint64_t channel) = 0;
virtual int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt) = 0;
+ virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index) = 0;
#if defined(AVFRAME_IN_LAVU)
virtual void av_frame_free(AVFrame **frame)=0;
virtual AVFrame *av_frame_alloc(void)=0;
{ return ::av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, nb_samples, sample_fmt, align); }
virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
{ return ::av_samples_copy(dst, src, dst_offset, src_offset, nb_samples, nb_channels, sample_fmt); }
+ virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
+ { return ::av_channel_layout_extract_channel(channel_layout, index); }
#if defined(AVFRAME_IN_LAVU)
virtual void av_frame_free(AVFrame **frame) { return ::av_frame_free(frame); }
virtual AVFrame *av_frame_alloc() { return ::av_frame_alloc(); }
DEFINE_METHOD2(int, av_get_channel_layout_channel_index, (uint64_t p1, uint64_t p2))
DEFINE_METHOD7(int, av_samples_fill_arrays, (uint8_t **p1, int *p2, const uint8_t *p3, int p4, int p5, enum AVSampleFormat p6, int p7))
DEFINE_METHOD7(int, av_samples_copy, (uint8_t **p1, uint8_t *const *p2, int p3, int p4, int p5, int p6, enum AVSampleFormat p7))
+ DEFINE_METHOD2(uint64_t, av_channel_layout_extract_channel, (uint64_t p1, int p2))
#if defined(AVFRAME_IN_LAVU)
DEFINE_METHOD1(void, av_frame_free, (AVFrame **p1))
DEFINE_METHOD0(AVFrame *, av_frame_alloc)
RESOLVE_METHOD(av_get_channel_layout_channel_index)
RESOLVE_METHOD(av_samples_fill_arrays)
RESOLVE_METHOD(av_samples_copy)
+ RESOLVE_METHOD(av_channel_layout_extract_channel)
#if defined(AVFRAME_IN_LAVU)
RESOLVE_METHOD(av_frame_free)
RESOLVE_METHOD(av_frame_alloc)
</group>
</category>
</section>
+ <section id="videos">
+ <category id="videoplayer">
+ <group id="2">
+ <setting id="videoplayer.usestagefright" type="boolean" label="13436" help="36260">
+ <requirement>HAVE_LIBSTAGEFRIGHTDECODER</requirement>
+ <level>2</level>
+ <default>true</default>
+ </setting>
+ </group>
+ </category>
+ </section>
</settings>
<level>2</level>
<default>true</default>
</setting>
- <setting id="videoplayer.usestagefright" type="boolean" label="13436" help="36260">
- <requirement>HAVE_LIBSTAGEFRIGHTDECODER</requirement>
- <level>2</level>
- <default>true</default>
- </setting>
<setting id="videoplayer.usepbo" type="boolean" label="13424" help="36163">
<requirement>HAS_GL</requirement>
<level>4</level>
<group id="2">
<setting id="audiooutput.audiodevice" type="string" label="545" help="36371">
<level>2</level>
- <default>WASAPI:default</default> <!-- will be properly set on startup -->
+ <default>DirectSound:default</default>
<constraints>
<options>audiodevices</options>
</constraints>
</setting>
<setting id="audiooutput.passthroughdevice" type="string" label="546" help="36372">
<level>2</level>
- <default>WASAPI:default</default> <!-- will be properly set on startup -->
+ <default>DirectSound:default</default>
<constraints>
<options>audiodevicespassthrough</options>
</constraints>
CActiveAEStream *stream;
stream = *(CActiveAEStream**)msg->data;
stream->m_paused = true;
+ if (m_streams.size() == 1)
+ FlushEngine();
return;
case CActiveAEControlProtocol::RESUMESTREAM:
stream = *(CActiveAEStream**)msg->data;
void CActiveAE::Configure(AEAudioFormat *desiredFmt)
{
bool initSink = false;
+
AEAudioFormat sinkInputFormat, inputFormat;
m_mode = MODE_PCM;
std::string device = AE_IS_RAW(m_sinkRequestFormat.m_dataFormat) ? m_settings.passthoughdevice : m_settings.device;
std::string driver;
CAESinkFactory::ParseDevice(device, driver);
- if (!m_sink.IsCompatible(m_sinkRequestFormat, device) || m_settings.driver.compare(driver) != 0)
+ if (!IsSinkCompatible(m_sinkRequestFormat, device) || m_settings.driver.compare(driver) != 0)
{
if (!InitSink())
return;
}
// resample buffers for sink
- if (m_sinkBuffers && !m_sink.IsCompatible(m_sinkBuffers->m_format, device))
+ if (m_sinkBuffers &&
+ (!CompareFormat(m_sinkBuffers->m_format,m_sinkFormat) || !CompareFormat(m_sinkBuffers->m_inputFormat, sinkInputFormat)))
{
m_discardBufferPools.push_back(m_sinkBuffers);
m_sinkBuffers = NULL;
// flush the engine if we only have a single stream
if (m_streams.size() == 1)
{
- if (m_sinkBuffers)
- m_sinkBuffers->Flush();
- if (m_vizBuffers)
- m_vizBuffers->Flush();
+ FlushEngine();
+ }
+}
- // send message to sink
- Message *reply;
- if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH,
- &reply, 2000))
- {
- bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
- if (!success)
- {
- CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
- m_extError = true;
- }
- reply->Release();
- }
- else
+void CActiveAE::FlushEngine()
+{
+ if (m_sinkBuffers)
+ m_sinkBuffers->Flush();
+ if (m_vizBuffers)
+ m_vizBuffers->Flush();
+
+ // send message to sink
+ Message *reply;
+ if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH,
+ &reply, 2000))
+ {
+ bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
+ if (!success)
{
- CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
+ CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
m_extError = true;
}
- m_stats.Reset(m_sinkFormat.m_sampleRate);
+ reply->Release();
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
+ m_extError = true;
}
+ m_stats.Reset(m_sinkFormat.m_sampleRate);
}
void CActiveAE::ClearDiscardedBuffers()
if (m_settings.driver.compare(driver) != 0)
return true;
- if (!m_sink.IsCompatible(newFormat, device))
+ if (!IsSinkCompatible(newFormat, device))
return true;
return false;
SinkConfig config;
config.format = m_sinkRequestFormat;
config.stats = &m_stats;
+ config.device = AE_IS_RAW(m_sinkRequestFormat.m_dataFormat) ? &m_settings.passthoughdevice :
+ &m_settings.device;
// send message to sink
Message *reply;
}
}
+bool CActiveAE::IsSinkCompatible(const AEAudioFormat format, const std::string &device)
+{
+ bool compatible = false;
+ SinkConfig config;
+ config.format = format;
+ config.device = &device;
+
+ // send message to sink
+ Message *reply;
+ if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::ISCOMPATIBLE,
+ &reply,
+ 1000,
+ &config, sizeof(config)))
+ {
+ bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
+ if (!success)
+ {
+ reply->Release();
+ CLog::Log(LOGERROR, "ActiveAE::%s - returned error", __FUNCTION__);
+ m_extError = true;
+ return false;
+ }
+ compatible = *(bool*)reply->data;
+ reply->Release();
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "ActiveAE::%s - failed to query compatibility", __FUNCTION__);
+ m_extError = true;
+ return false;
+ }
+ return compatible;
+}
+
void CActiveAE::UnconfigureSink()
{
// send message to sink
uint8_t **buffer;
planes = m_dllAvUtil.av_sample_fmt_is_planar(config.fmt) ? config.channels : 1;
buffer = new uint8_t*[planes];
+
+ // align buffer to 16 in order to be compatible with sse in CAEConvert
m_dllAvUtil.av_samples_alloc(buffer, &linesize, config.channels,
- samples, config.fmt, 0);
+ samples, config.fmt, 16);
bytes_per_sample = m_dllAvUtil.av_get_bytes_per_sample(config.fmt);
return buffer;
}
delete [] data;
}
+bool CActiveAE::CompareFormat(AEAudioFormat &lhs, AEAudioFormat &rhs)
+{
+ if (lhs.m_channelLayout != rhs.m_channelLayout ||
+ lhs.m_dataFormat != rhs.m_dataFormat ||
+ lhs.m_sampleRate != rhs.m_sampleRate ||
+ lhs.m_frames != rhs.m_frames)
+ return false;
+ else
+ return true;
+}
+
//-----------------------------------------------------------------------------
// GUI Sounds
//-----------------------------------------------------------------------------
{
int samples = fileSize / m_dllAvUtil.av_get_bytes_per_sample(dec_ctx->sample_fmt) / config.channels;
config.fmt = dec_ctx->sample_fmt;
+ config.bits_per_sample = dec_ctx->bits_per_coded_sample;
sound->InitSound(true, config, samples);
init = true;
}
dst_config.channels = m_internalFormat.m_channelLayout.Count();
dst_config.sample_rate = m_internalFormat.m_sampleRate;
dst_config.fmt = CActiveAEResample::GetAVSampleFormat(m_internalFormat.m_dataFormat);
+ dst_config.bits_per_sample = CAEUtil::DataFormatToUsedBits(m_internalFormat.m_dataFormat);
CActiveAEResample *resampler = new CActiveAEResample();
resampler->Init(dst_config.channel_layout,
dst_config.channels,
dst_config.sample_rate,
dst_config.fmt,
+ dst_config.bits_per_sample,
orig_config.channel_layout,
orig_config.channels,
orig_config.sample_rate,
orig_config.fmt,
+ orig_config.bits_per_sample,
NULL,
AE_QUALITY_MID);
bool InitSink();
void DrainSink();
void UnconfigureSink();
+ bool IsSinkCompatible(const AEAudioFormat format, const std::string &device);
void Start();
void Dispose();
void LoadSettings();
CActiveAEStream* CreateStream(MsgStreamNew *streamMsg);
void DiscardStream(CActiveAEStream *stream);
void SFlushStream(CActiveAEStream *stream);
+ void FlushEngine();
void ClearDiscardedBuffers();
void SStopSound(CActiveAESound *sound);
void DiscardSound(CActiveAESound *sound);
void MixSounds(CSoundPacket &dstSample);
void Deamplify(CSoundPacket &dstSample);
+ bool CompareFormat(AEAudioFormat &lhs, AEAudioFormat &rhs);
+
CEvent m_inMsgEvent;
CEvent m_outMsgEvent;
CActiveAEControlProtocol m_controlPort;
#include "ActiveAEBuffer.h"
#include "AEFactory.h"
#include "ActiveAE.h"
+#include "Utils/AEUtil.h"
using namespace ActiveAE;
CSampleBuffer *buffer;
SampleConfig config;
config.fmt = CActiveAEResample::GetAVSampleFormat(m_format.m_dataFormat);
+ config.bits_per_sample = CAEUtil::DataFormatToUsedBits(m_format.m_dataFormat);
config.channels = m_format.m_channelLayout.Count();
config.sample_rate = m_format.m_sampleRate;
config.channel_layout = CActiveAEResample::GetAVChannelLayout(m_format.m_channelLayout);
m_format.m_channelLayout.Count(),
m_format.m_sampleRate,
CActiveAEResample::GetAVSampleFormat(m_format.m_dataFormat),
+ CAEUtil::DataFormatToUsedBits(m_format.m_dataFormat),
CActiveAEResample::GetAVChannelLayout(m_inputFormat.m_channelLayout),
m_inputFormat.m_channelLayout.Count(),
m_inputFormat.m_sampleRate,
CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
+ CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
remap ? &m_format.m_channelLayout : NULL,
m_resampleQuality);
}
m_format.m_channelLayout.Count(),
m_outSampleRate,
CActiveAEResample::GetAVSampleFormat(m_format.m_dataFormat),
+ CAEUtil::DataFormatToUsedBits(m_format.m_dataFormat),
CActiveAEResample::GetAVChannelLayout(m_inputFormat.m_channelLayout),
m_inputFormat.m_channelLayout.Count(),
m_inputFormat.m_sampleRate,
CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
+ CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
NULL,
m_resampleQuality);
uint64_t channel_layout;
int channels;
int sample_rate;
+ int bits_per_sample;
};
/**
m_dllSwResample.Unload();
}
-bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, CAEChannelInfo *remapLayout, AEQuality quality)
+bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, CAEChannelInfo *remapLayout, AEQuality quality)
{
if (!m_dllAvUtil.Load() || !m_dllSwResample.Load())
return false;
m_dst_channels = dst_channels;
m_dst_rate = dst_rate;
m_dst_fmt = dst_fmt;
+ m_dst_bits = dst_bits;
m_src_chan_layout = src_chan_layout;
m_src_channels = src_channels;
m_src_rate = src_rate;
m_src_fmt = src_fmt;
+ m_src_bits = src_bits;
if (m_dst_chan_layout == 0)
m_dst_chan_layout = m_dllAvUtil.av_get_default_channel_layout(m_dst_channels);
m_dllAvUtil.av_opt_set_int(m_pContext,"filter_size", 32, 0);
}
+ if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
+ {
+ m_dllAvUtil.av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
+ }
+
if(!m_pContext)
{
CLog::Log(LOGERROR, "CActiveAEResample::Init - create context failed");
return false;
}
}
+ // stereo upmix
+ else if (m_src_channels == 2 && m_dst_channels > 2)
+ {
+ memset(m_rematrix, 0, sizeof(m_rematrix));
+ for (int out=0; out<m_dst_channels; out++)
+ {
+ uint64_t out_chan = m_dllAvUtil.av_channel_layout_extract_channel(m_dst_chan_layout, out);
+ switch(out_chan)
+ {
+ case AV_CH_FRONT_LEFT:
+ case AV_CH_BACK_LEFT:
+ case AV_CH_SIDE_LEFT:
+ m_rematrix[out][0] = 1.0;
+ break;
+ case AV_CH_FRONT_RIGHT:
+ case AV_CH_BACK_RIGHT:
+ case AV_CH_SIDE_RIGHT:
+ m_rematrix[out][1] = 1.0;
+ break;
+ case AV_CH_FRONT_CENTER:
+ m_rematrix[out][0] = 0.5;
+ m_rematrix[out][1] = 0.5;
+ break;
+ case AV_CH_LOW_FREQUENCY:
+ m_rematrix[out][0] = 0.5;
+ m_rematrix[out][1] = 0.5;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (m_dllSwResample.swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
+ {
+ CLog::Log(LOGERROR, "CActiveAEResample::Init - setting channel matrix failed");
+ return false;
+ }
+ }
+
if(m_dllSwResample.swr_init(m_pContext) < 0)
{
CLog::Log(LOGERROR, "CActiveAEResample::Init - init resampler failed");
if (format == AE_FMT_U8) return AV_SAMPLE_FMT_U8;
else if (format == AE_FMT_S16NE) return AV_SAMPLE_FMT_S16;
else if (format == AE_FMT_S32NE) return AV_SAMPLE_FMT_S32;
+ else if (format == AE_FMT_S24NE4) return AV_SAMPLE_FMT_S32;
else if (format == AE_FMT_FLOAT) return AV_SAMPLE_FMT_FLT;
else if (format == AE_FMT_DOUBLE) return AV_SAMPLE_FMT_DBL;
else if (format == AE_FMT_U8P) return AV_SAMPLE_FMT_U8P;
else if (format == AE_FMT_S16NEP) return AV_SAMPLE_FMT_S16P;
else if (format == AE_FMT_S32NEP) return AV_SAMPLE_FMT_S32P;
+ else if (format == AE_FMT_S24NE4P) return AV_SAMPLE_FMT_S32P;
else if (format == AE_FMT_FLOATP) return AV_SAMPLE_FMT_FLTP;
else if (format == AE_FMT_DOUBLEP) return AV_SAMPLE_FMT_DBLP;
return AV_SAMPLE_FMT_FLT;
}
-AEDataFormat CActiveAEResample::GetAESampleFormat(AVSampleFormat format)
+AEDataFormat CActiveAEResample::GetAESampleFormat(AVSampleFormat format, int bits)
{
if (format == AV_SAMPLE_FMT_U8) return AE_FMT_U8;
else if (format == AV_SAMPLE_FMT_S16) return AE_FMT_S16NE;
- else if (format == AV_SAMPLE_FMT_S32) return AE_FMT_S32NE;
+ else if (format == AV_SAMPLE_FMT_S32 && bits == 32) return AE_FMT_S32NE;
+ else if (format == AV_SAMPLE_FMT_S32 && bits == 24) return AE_FMT_S24NE4;
else if (format == AV_SAMPLE_FMT_FLT) return AE_FMT_FLOAT;
else if (format == AV_SAMPLE_FMT_DBL) return AE_FMT_DOUBLE;
else if (format == AV_SAMPLE_FMT_U8P) return AE_FMT_U8P;
else if (format == AV_SAMPLE_FMT_S16P) return AE_FMT_S16NEP;
- else if (format == AV_SAMPLE_FMT_S32P) return AE_FMT_S32NEP;
+ else if (format == AV_SAMPLE_FMT_S32P && bits == 32) return AE_FMT_S32NEP;
+ else if (format == AV_SAMPLE_FMT_S32P && bits == 24) return AE_FMT_S24NE4P;
else if (format == AV_SAMPLE_FMT_FLTP) return AE_FMT_FLOATP;
else if (format == AV_SAMPLE_FMT_DBLP) return AE_FMT_DOUBLEP;
public:
CActiveAEResample();
virtual ~CActiveAEResample();
- bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, CAEChannelInfo *remapLayout, AEQuality quality);
+ bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, CAEChannelInfo *remapLayout, AEQuality quality);
int Resample(uint8_t **dst_buffer, int dst_samples, uint8_t **src_buffer, int src_samples);
int64_t GetDelay(int64_t base);
int GetBufferedSamples();
static uint64_t GetAVChannelLayout(CAEChannelInfo &info);
// static CAEChannelInfo GetAEChannelLayout(uint64_t layout);
static AVSampleFormat GetAVSampleFormat(AEDataFormat format);
- static AEDataFormat GetAESampleFormat(AVSampleFormat format);
+ static AEDataFormat GetAESampleFormat(AVSampleFormat format, int bits);
static uint64_t GetAVChannel(enum AEChannel aechannel);
int GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout);
int m_src_rate, m_dst_rate;
int m_src_channels, m_dst_channels;
AVSampleFormat m_src_fmt, m_dst_fmt;
+ int m_src_bits, m_dst_bits;
SwrContext *m_pContext;
double m_rematrix[AE_CH_MAX][AE_CH_MAX];
};
{
m_requestedFormat = data->format;
m_stats = data->stats;
+ m_device = *(data->device);
}
m_extError = false;
m_extSilence = false;
msg->Reply(CSinkControlProtocol::ACC);
return;
+ case CSinkControlProtocol::ISCOMPATIBLE:
+ data = (SinkConfig*)msg->data;
+ bool compatible;
+ compatible = IsCompatible(data->format, *(data->device));
+ msg->Reply(CSinkControlProtocol::ACC, &compatible, sizeof(bool));
+ return;
+
default:
break;
}
void CActiveAESink::OpenSink()
{
- std::string device, driver;
+ std::string driver;
bool passthrough = AE_IS_RAW(m_requestedFormat.m_dataFormat);
- if (passthrough)
- device = CSettings::Get().GetString("audiooutput.passthroughdevice");
- else
- device = CSettings::Get().GetString("audiooutput.audiodevice");
- CAESinkFactory::ParseDevice(device, driver);
+ CAESinkFactory::ParseDevice(m_device, driver);
if (driver.empty() && m_sink)
driver = m_sink->GetName();
std::transform(sinkName.begin(), sinkName.end(), sinkName.begin(), ::toupper);
}
- if (!m_sink || sinkName != driver || !m_sink->IsCompatible(m_requestedFormat, device))
+ if (!m_sink || sinkName != driver || !m_sink->IsCompatible(m_requestedFormat, m_device))
{
CLog::Log(LOGINFO, "CActiveAE::OpenSink - sink incompatible, re-starting");
}
// get the display name of the device
- GetDeviceFriendlyName(device);
+ GetDeviceFriendlyName(m_device);
// if we already have a driver, prepend it to the device string
if (!driver.empty())
- device = driver + ":" + device;
+ m_device = driver + ":" + m_device;
// WARNING: this changes format and does not use passthrough
m_sinkFormat = m_requestedFormat;
- m_sink = CAESinkFactory::Create(device, m_sinkFormat, passthrough);
+ m_sink = CAESinkFactory::Create(m_device, m_sinkFormat, passthrough);
if (!m_sink)
{
// init sample of silence
SampleConfig config;
config.fmt = CActiveAEResample::GetAVSampleFormat(m_sinkFormat.m_dataFormat);
+ config.bits_per_sample = CAEUtil::DataFormatToUsedBits(m_sinkFormat.m_dataFormat);
config.channel_layout = CActiveAEResample::GetAVChannelLayout(m_sinkFormat.m_channelLayout);
config.channels = m_sinkFormat.m_channelLayout.Count();
config.sample_rate = m_sinkFormat.m_sampleRate;
void CActiveAESink::ConvertInit(CSampleBuffer* samples)
{
- if (CActiveAEResample::GetAESampleFormat(samples->pkt->config.fmt) != m_sinkFormat.m_dataFormat)
+ if (CActiveAEResample::GetAESampleFormat(samples->pkt->config.fmt, samples->pkt->config.bits_per_sample) != m_sinkFormat.m_dataFormat)
{
m_convertFn = CAEConvert::FrFloat(m_sinkFormat.m_dataFormat);
if (m_convertBuffer)
void CActiveAESink::GenerateNoise()
{
int nb_floats = m_sinkFormat.m_frames*m_sinkFormat.m_channelLayout.Count();
- float *noise = new float[nb_floats];
+ float *noise = (float*)_aligned_malloc(nb_floats*sizeof(float), 16);
float R1, R2;
for(int i=0; i<nb_floats;i++)
noise[i] = (float) sqrt( -2.0f * log( R1 )) * cos( 2.0f * PI * R2 ) * 0.00001;
}
- AEDataFormat fmt = CActiveAEResample::GetAESampleFormat(m_sampleOfNoise.pkt->config.fmt);
+ AEDataFormat fmt = CActiveAEResample::GetAESampleFormat(m_sampleOfNoise.pkt->config.fmt, m_sampleOfNoise.pkt->config.bits_per_sample);
CAEConvert::AEConvertFrFn convertFn = CAEConvert::FrFloat(fmt);
convertFn(noise, nb_floats, m_sampleOfNoise.pkt->data[0]);
- delete [] noise;
+ _aligned_free(noise);
}
{
AEAudioFormat format;
CEngineStats *stats;
+ const std::string *device;
};
class CSinkControlProtocol : public Protocol
CONFIGURE,
UNCONFIGURE,
SILENCEMODE,
+ ISCOMPATIBLE,
VOLUME,
FLUSH,
TIMEOUT,
std::string GetDefaultDevice(bool passthrough);
void Start();
void Dispose();
- bool IsCompatible(const AEAudioFormat format, const std::string &device);
bool HasVolume();
CSinkControlProtocol m_controlPort;
CSinkDataProtocol m_dataPort;
void GetDeviceFriendlyName(std::string &device);
void OpenSink();
void ReturnBuffers();
+ bool IsCompatible(const AEAudioFormat format, const std::string &device);
unsigned int OutputSamples(CSampleBuffer* samples);
void ConvertInit(CSampleBuffer* samples);
} m_convertState;
std::string m_deviceFriendlyName;
+ std::string m_device;
AESinkInfoList m_sinkInfoList;
IAESink *m_sink;
AEAudioFormat m_sinkFormat, m_requestedFormat;
/* work around invalid alignment */
while ((((uintptr_t)data & 0xF) || ((uintptr_t)dest & 0xF)) && count > 0)
{
- dst[0] = safeRound(data[0] * ((float)INT24_MAX+.5f));
+ dst[0] = (safeRound(data[0] * ((float)INT24_MAX+.5f)) & 0xFFFFFF) << 8;
++data;
++dst;
--count;
memcpy(dst, &con, sizeof(int32_t) * 4);
}
- if (samples != even)
+ if (count != even)
{
- const uint32_t odd = samples - even;
+ const uint32_t odd = count - even;
if (odd == 1)
- dst[0] = safeRound(data[0] * ((float)INT24_MAX+.5f));
+ dst[0] = (safeRound(data[0] * ((float)INT24_MAX+.5f)) & 0xFFFFFF) << 8;
else
{
__m128 in;
*((uint32_t*)(dest + 9)) = (dst[3] & 0xFFFFFF) << leftShift;
}
- if (samples != even)
+ if (count != even)
{
- const uint32_t odd = samples - even;
+ const uint32_t odd = count - even;
if (odd == 1)
dst[0] = safeRound(data[0] * ((float)INT24_MAX+.5f)) & 0xFFFFFF;
else
dst[3] = Endian_SwapLE32(dst[3]);
}
- if (samples != even)
+ if (count != even)
{
- const uint32_t odd = samples - even;
+ const uint32_t odd = count - even;
if (odd == 1)
{
dst[0] = safeRound(data[0] * AE_MUL32);
dst[3] = Endian_SwapBE32(dst[3]);
}
- if (samples != even)
+ if (count != even)
{
- const uint32_t odd = samples - even;
+ const uint32_t odd = count - even;
if (odd == 1)
{
dst[0] = safeRound(data[0] * AE_MUL32);
return formats[dataFormat];
}
+const unsigned int CAEUtil::DataFormatToUsedBits(const enum AEDataFormat dataFormat)
+{
+ if (dataFormat == AE_FMT_S24BE4 || dataFormat == AE_FMT_S24LE4 || dataFormat == AE_FMT_S24NE4)
+ return 24;
+ else
+ return DataFormatToBits(dataFormat);
+}
+
const char* CAEUtil::DataFormatToStr(const enum AEDataFormat dataFormat)
{
if (dataFormat < 0 || dataFormat >= AE_FMT_MAX)
static CAEChannelInfo GuessChLayout (const unsigned int channels);
static const char* GetStdChLayoutName(const enum AEStdChLayout layout);
static const unsigned int DataFormatToBits (const enum AEDataFormat dataFormat);
+ static const unsigned int DataFormatToUsedBits (const enum AEDataFormat dataFormat);
static const char* DataFormatToStr (const enum AEDataFormat dataFormat);
/*! \brief convert a volume percentage (as a proportion) to a dB gain
m_pFormatName = "am-h264";
// convert h264-avcC to h264-annex-b as h264-avcC
// under streamers can have issues when seeking.
- if (*(uint8_t*)m_hints.extradata == 1)
+ if (m_hints.extradata && *(uint8_t*)m_hints.extradata == 1)
{
m_bitstream = new CBitstreamConverter;
m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true);
for(int i=0; i < mxhouse->synth.pcm.length; i++)
{
// Left channel
- *dest++ = mad_f_todouble(mxhouse->synth.pcm.samples[0][i]);
+ *dest++ = (float)mad_f_todouble(mxhouse->synth.pcm.samples[0][i]);
// Right channel
if(MAD_NCHANNELS(&mxhouse->frame.header) == 2)
- *dest++ = mad_f_todouble(mxhouse->synth.pcm.samples[1][i]);
+ *dest++ = (float)mad_f_todouble(mxhouse->synth.pcm.samples[1][i]);
}
// Tell calling code buffer size
void Release();
protected:
- unsigned char getbyte(FILE *fd);
+ static unsigned char getbyte(FILE *fd);
};
// Accessors
LPDIRECT3DTEXTURE9 Get() const { return m_texture; };
- UINT GetWidth() { return m_width; }
- UINT GetHeight() { return m_height; }
+ UINT GetWidth() const { return m_width; }
+ UINT GetHeight() const { return m_height; }
virtual void OnDestroyDevice();
virtual void OnCreateDevice();
return true;
}
-unsigned int CDDSImage::GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const
+unsigned int CDDSImage::GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format)
{
switch (format)
{
m_data = new unsigned char[m_desc.linearSize];
}
-const char *CDDSImage::GetFourCC(unsigned int format) const
+const char *CDDSImage::GetFourCC(unsigned int format)
{
switch (format)
{
private:
void Allocate(unsigned int width, unsigned int height, unsigned int format);
- const char *GetFourCC(unsigned int format) const;
+ static const char *GetFourCC(unsigned int format);
bool WriteFile(const std::string &file) const;
/*! \brief Compress an ARGB buffer into a DXT1/3/5 image
*/
bool Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
- unsigned int GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const;
+ static unsigned int GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format);
enum {
ddsd_caps = 0x00000001,
ddsd_height = 0x00000002,
// Currently only works for 32bit and 8bit textures, with power of 2 width and height
void Unswizzle(const void *src, unsigned int depth, unsigned int width, unsigned int height, void *dest)
{
- if (height <= 0 || width <= 0)
+ if (height == 0 || width == 0)
return;
for (UINT y = 0; y < height; y++)
}
// Finish rendering to FBO
-void CFrameBufferObject::EndRender()
+void CFrameBufferObject::EndRender() const
{
if (IsValid())
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
bool IsSupported();
// returns true if FBO has been initialized
- bool IsValid() { return m_valid; }
+ bool IsValid() const { return m_valid; }
// returns true if FBO has a texture bound to it
- bool IsBound() { return m_bound; }
+ bool IsBound() const { return m_bound; }
// initialize the FBO
bool Initialize();
GLenum filter=GL_LINEAR, GLenum clampmode=GL_CLAMP_TO_EDGE);
// Return the internally created texture ID
- GLuint Texture() { return m_texid; }
+ GLuint Texture() const { return m_texid; }
// Begin rendering to FBO
bool BeginRender();
// Finish rendering to FBO
- void EndRender();
+ void EndRender() const;
private:
GLuint m_fbo;
if (m_actions.size() == 0) return false;
// take a copy of actions that satisfy our conditions
vector<CStdString> actions;
- for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
{
if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
{
int CGUIAction::GetNavigation() const
{
- for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
{
if (StringUtils::IsInteger(it->action))
{
if (id == 0) return;
CStdString strId;
strId.Format("%i", id);
- for (iActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ for (iActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
{
if (StringUtils::IsInteger(it->action) && it->condition.IsEmpty())
{
bool CGUIAction::HasActionsMeetingCondition() const
{
- for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
{
if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
return true;
{
if (updateAllItems)
{ // free memory of items
- for (iItems it = m_items.begin(); it != m_items.end(); it++)
+ for (iItems it = m_items.begin(); it != m_items.end(); ++it)
(*it)->FreeMemory();
}
// and recalculate the layout
return GetOffset() / m_itemsPerPage + 1;
}
-void CGUIBaseContainer::GetCacheOffsets(int &cacheBefore, int &cacheAfter)
+void CGUIBaseContainer::GetCacheOffsets(int &cacheBefore, int &cacheAfter) const
{
if (m_scroller.IsScrollingDown())
{
// changing around)
void UpdateScrollByLetter();
- void GetCacheOffsets(int &cacheBefore, int &cacheAfter);
+ void GetCacheOffsets(int &cacheBefore, int &cacheAfter) const;
int GetCacheCount() const { return m_cacheItems; };
bool ScrollingDown() const { return m_scroller.IsScrollingDown(); };
bool ScrollingUp() const { return m_scroller.IsScrollingUp(); };
}
CGUIBorderedImage::CGUIBorderedImage(const CGUIBorderedImage &right)
-: CGUIImage(right), m_borderImage(right.m_borderImage)
+: CGUIImage(right), m_borderImage(right.m_borderImage), m_borderSize(right.m_borderSize)
{
- m_borderSize = right.m_borderSize;
ControlType = GUICONTROL_BORDEREDIMAGE;
}
void PythonSetDisabledColor(color_t disabledColor);
virtual void OnClick();
- bool HasClickActions() { return m_clickActions.HasActionsMeetingCondition(); };
+ bool HasClickActions() const { return m_clickActions.HasActionsMeetingCondition(); };
virtual bool UpdateColors();
// Assign an EventHandler (EventHandler's are derived from Event)
GUIEvent<Cookie> &operator=(GUIEvent<Cookie> &aEvent)
{
- if (&aEvent)
+ if (&aEvent != this)
{
m_pInstance = aEvent.m_pInstance;
m_pMethod = aEvent.m_pMethod;
}
- else
- {
- GUIEvent();
- }
-
return *this;
}
// Are the class instance and method pointers initialised?
- bool HasAHandler()
+ bool HasAHandler() const
{
return (m_pInstance && m_pMethod);
}
// Execute the associated class method
- void Fire(Cookie aCookie)
+ void Fire(Cookie aCookie) const
{
if (HasAHandler())
{
// Assign a CallbackHandler (CallbackHandler's are derived from Callback)
Callback<Result, Cookie> &operator=(Callback<Result, Cookie> &aCallback)
{
- if (&aCallback)
+ if (&aCallback != this)
{
m_pInstance = aCallback.m_pInstance;
m_pMethod = aCallback.m_pMethod;
}
- else
- {
- Callback();
- }
-
return *this;
}
// Are the class instance and method pointers initialised?
- bool HasAHandler()
+ bool HasAHandler() const
{
return (m_pInstance && m_pMethod);
}
// Execute the associated class method and return the result
- Result Fire(Cookie aCookie)
+ Result Fire(Cookie aCookie) const
{
if (HasAHandler())
{
, m_imgCheckMark(posX, posY, checkWidth, checkHeight, textureCheckMark)
, m_imgCheckMarkNoFocus(posX, posY, checkWidth, checkHeight, textureCheckMarkNF)
, m_label(posX, posY, width, height, labelInfo)
+ , m_strLabel("")
{
- m_strLabel = "";
m_bSelected = false;
m_label.GetLabelInfo().align |= XBFONT_CENTER_Y;
ControlType = GUICONTROL_CHECKMARK;
using namespace std;
-CGUIControl::CGUIControl()
+CGUIControl::CGUIControl() :
+ m_diffuseColor(0xffffffff)
{
m_hasProcessed = false;
m_bHasFocus = false;
m_visibleCondition = 0;
m_enableCondition = 0;
m_enabled = true;
- m_diffuseColor = 0xffffffff;
m_posX = 0;
m_posY = 0;
m_width = 0;
}
CGUIControl::CGUIControl(int parentID, int controlID, float posX, float posY, float width, float height)
-: m_hitRect(posX, posY, posX + width, posY + height)
+: m_hitRect(posX, posY, posX + width, posY + height),
+ m_diffuseColor(0xffffffff)
{
m_posX = posX;
m_posY = posY;
m_parentID = parentID;
m_visible = VISIBLE;
m_visibleFromSkinCondition = true;
- m_diffuseColor = 0xffffffff;
m_forceHidden = false;
m_visibleCondition = 0;
m_enableCondition = 0;
return false;
}
-bool CGUIControl::Navigate(int direction)
+bool CGUIControl::Navigate(int direction) const
{
if (HasFocus())
{
Navigate(ACTION_PREV_CONTROL);
}
-bool CGUIControl::SendWindowMessage(CGUIMessage &message)
+bool CGUIControl::SendWindowMessage(CGUIMessage &message) const
{
CGUIWindow *pWindow = g_windowManager.GetWindow(GetParentID());
if (pWindow)
void CGUIControl::UnfocusFromPoint(const CPoint &point)
{
- CPoint controlPoint(point);
- m_transform.InverseTransformPosition(controlPoint.x, controlPoint.y);
- if (!HitTest(controlPoint))
- SetFocus(false);
+ if (HasFocus())
+ {
+ CPoint controlPoint(point);
+ m_transform.InverseTransformPosition(controlPoint.x, controlPoint.y);
+ if (!HitTest(controlPoint))
+ SetFocus(false);
+ }
}
bool CGUIControl::HasID(int id) const
bool GetNavigationAction(int direction, CGUIAction& action) const;
/*! \brief Start navigating in given direction.
*/
- bool Navigate(int direction);
+ bool Navigate(int direction) const;
virtual void SetFocus(bool focus);
virtual void SetWidth(float width);
virtual void SetHeight(float height);
virtual bool Animate(unsigned int currentTime);
virtual bool CheckAnimation(ANIMATION_TYPE animType);
void UpdateStates(ANIMATION_TYPE type, ANIMATION_PROCESS currentProcess, ANIMATION_STATE currentState);
- bool SendWindowMessage(CGUIMessage &message);
+ bool SendWindowMessage(CGUIMessage &message) const;
// navigation and actions
CGUIAction m_actionLeft;
static CStdString GetType(const TiXmlElement *pControlNode);
static bool GetConditionalVisibility(const TiXmlNode* control, CStdString &condition, CStdString &allowHiddenFocus);
bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strString);
- bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue);
- bool GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue);
+ static bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue);
+ static bool GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue);
};
#endif
if (first != m_lookup.end())
{
LookupMap::const_iterator last = m_lookup.upper_bound(iControl);
- for (LookupMap::const_iterator i = first; i != last; i++)
+ for (LookupMap::const_iterator i = first; i != last; ++i)
{
CGUIControl *control = i->second;
if (control->IsVisible())
if (control->IsGroup())
{ // first add all the subitems of this group (if they exist)
const LookupMap map = ((CGUIControlGroup *)control)->GetLookup();
- for (LookupMap::const_iterator i = map.begin(); i != map.end(); i++)
+ for (LookupMap::const_iterator i = map.begin(); i != map.end(); ++i)
m_lookup.insert(m_lookup.upper_bound(i->first), make_pair(i->first, i->second));
}
if (control->GetID())
if (control->IsGroup())
{ // remove the group's lookup
const LookupMap &map = ((CGUIControlGroup *)control)->GetLookup();
- for (LookupMap::const_iterator i = map.begin(); i != map.end(); i++)
+ for (LookupMap::const_iterator i = map.begin(); i != map.end(); ++i)
{ // remove this control
- for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
+ for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); ++it)
{
if (i->second == it->second)
{
// remove the actual control
if (control->GetID())
{
- for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
+ for (LookupMap::iterator it = m_lookup.begin(); it != m_lookup.end(); ++it)
{
if (control == it->second)
{
{
if (control->GetID())
{
- for (LookupMap::const_iterator it = m_lookup.begin(); it != m_lookup.end(); it++)
+ for (LookupMap::const_iterator it = m_lookup.begin(); it != m_lookup.end(); ++it)
{
if (control == it->second)
return true;
// first remove from the lookup table
if (m_parentControl)
{
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
+ for (iControls it = m_children.begin(); it != m_children.end(); ++it)
((CGUIControlGroup *)m_parentControl)->RemoveLookup(*it);
}
// and delete all our children
- for (iControls it = m_children.begin(); it != m_children.end(); it++)
+ for (iControls it = m_children.begin(); it != m_children.end(); ++it)
{
CGUIControl *control = *it;
delete control;
typedef std::multimap<int, CGUIControl *> LookupMap;
void AddLookup(CGUIControl *control);
void RemoveLookup(CGUIControl *control);
- const LookupMap &GetLookup() { return m_lookup; };
+ const LookupMap &GetLookup() const { return m_lookup; };
LookupMap m_lookup;
int m_defaultControl;
void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; };
- bool HasTextChangeActions() { return m_textChangeActions.HasActionsMeetingCondition(); };
+ bool HasTextChangeActions() const { return m_textChangeActions.HasActionsMeetingCondition(); };
protected:
virtual void ProcessText(unsigned int currentTime);
using namespace std;
CGUIFadeLabelControl::CGUIFadeLabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool scrollOut, unsigned int timeToDelayAtEnd, bool resetOnLabelChange)
- : CGUIControl(parentID, controlID, posX, posY, width, height), m_scrollInfo(50, labelInfo.offsetX, labelInfo.scrollSpeed)
+ : CGUIControl(parentID, controlID, posX, posY, width, height), m_label(labelInfo), m_scrollInfo(50, labelInfo.offsetX, labelInfo.scrollSpeed)
, m_textLayout(labelInfo.font, false)
+ , m_fadeAnim(CAnimation::CreateFader(100, 0, timeToDelayAtEnd, 200))
{
- m_label = labelInfo;
m_currentLabel = 0;
ControlType = GUICONTROL_FADELABEL;
m_scrollOut = scrollOut;
- m_fadeAnim = CAnimation::CreateFader(100, 0, timeToDelayAtEnd, 200);
m_fadeAnim.ApplyAnimation();
m_lastLabel = -1;
m_scrollSpeed = labelInfo.scrollSpeed; // save it for later
}
CGUIFadeLabelControl::CGUIFadeLabelControl(const CGUIFadeLabelControl &from)
-: CGUIControl(from), m_infoLabels(from.m_infoLabels), m_scrollInfo(from.m_scrollInfo), m_textLayout(from.m_textLayout)
+: CGUIControl(from), m_infoLabels(from.m_infoLabels), m_label(from.m_label), m_scrollInfo(from.m_scrollInfo), m_textLayout(from.m_textLayout),
+ m_fadeAnim(from.m_fadeAnim)
{
- m_label = from.m_label;
m_scrollOut = from.m_scrollOut;
m_scrollSpeed = from.m_scrollSpeed;
m_resetOnLabelChange = from.m_resetOnLabelChange;
- m_fadeAnim = from.m_fadeAnim;
m_fadeAnim.ApplyAnimation();
m_currentLabel = 0;
m_lastLabel = -1;
Clear();
}
-void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect) const
+void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect)
{
// set scaling resolution so that we can scale our font sizes correctly
// as fonts aren't scaled at render time (due to aliasing) we must scale
void GUIFontManager::UnloadTTFFonts()
{
- for (vector<CGUIFontTTFBase*>::iterator i = m_vecFontFiles.begin(); i != m_vecFontFiles.end(); i++)
+ for (vector<CGUIFontTTFBase*>::iterator i = m_vecFontFiles.begin(); i != m_vecFontFiles.end(); ++i)
delete (*i);
m_vecFontFiles.clear();
- for (vector<CGUIFont*>::iterator i = m_vecFonts.begin(); i != m_vecFonts.end(); i++)
+ for (vector<CGUIFont*>::iterator i = m_vecFonts.begin(); i != m_vecFonts.end(); ++i)
(*i)->SetFont(NULL);
}
void Clear();
void FreeFontFile(CGUIFontTTFBase *pFont);
- bool IsFontSetUnicode() { return m_fontsetUnicode; }
+ bool IsFontSetUnicode() const { return m_fontsetUnicode; }
bool IsFontSetUnicode(const CStdString& strFontSet);
bool GetFirstFontSetUnicode(CStdString& strFontSet);
static void SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t);
protected:
- void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect) const;
+ static void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect);
void LoadFonts(const TiXmlNode* fontNode);
CGUIFontTTFBase* GetFontFile(const CStdString& strFontFile);
bool OpenFontFile(CXBMCTinyXML& xmlDoc);
return stroker;
};
- void ReleaseFont(FT_Face face)
+ static void ReleaseFont(FT_Face face)
{
assert(face);
FT_Done_Face(face);
};
- void ReleaseStroker(FT_Stroker stroker)
+ static void ReleaseStroker(FT_Stroker stroker)
{
assert(stroker);
FT_Stroker_Done(stroker);
// first compute the size of the text to render in both characters and pixels
unsigned int lineChars = 0;
float linePixels = 0;
- for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
+ for (vecText::const_iterator pos = text.begin(); pos != text.end(); ++pos)
{
Character *ch = GetCharacter(*pos);
if (ch)
}
float cursorX = 0; // current position along the line
- for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
+ for (vecText::const_iterator pos = text.begin(); pos != text.end(); ++pos)
{
// If starting text on a new line, determine justification effects
// Get the current letter in the CStdString
int low = 0;
int high = m_numChars - 1;
- int mid;
while (low <= high)
{
- mid = (low + high) >> 1;
+ int mid = (low + high) >> 1;
if (ch > m_char[mid].letterAndStyle)
low = mid + 1;
else if (ch < m_char[mid].letterAndStyle)
// modifying glyphs
void EmboldenGlyph(FT_GlyphSlot slot);
- void ObliqueGlyph(FT_GlyphSlot slot);
+ static void ObliqueGlyph(FT_GlyphSlot slot);
CBaseTexture* m_texture; // texture that holds our rendered characters (8bit alpha only)
CStdString m_strFileName;
private:
+ CGUIFontTTFBase(const CGUIFontTTFBase&);
+ CGUIFontTTFBase& operator=(const CGUIFontTTFBase&);
int m_referenceCount;
};
}
LPDIRECT3DSURFACE9 pSource, pTarget;
- HRESULT hr;
// There might be data to copy from the previous texture
if ((newSpeedupTexture && m_speedupTexture) || (newTexture && m_texture))
{
const RECT rect = { 0, 0, m_textureWidth, m_textureHeight };
const POINT point = { 0, 0 };
- hr = g_Windowing.Get3DDevice()->UpdateSurface(pSource, &rect, pTarget, &point);
+ HRESULT hr = g_Windowing.Get3DDevice()->UpdateSurface(pSource, &rect, pTarget, &point);
SAFE_RELEASE(pSource);
SAFE_RELEASE(pTarget);
}
CGUIImage::CGUIImage(const CGUIImage &left)
- : CGUIControl(left), m_texture(left.m_texture)
+ : CGUIControl(left),
+ m_image(left.m_image),
+ m_info(left.m_info),
+ m_texture(left.m_texture),
+ m_fadingTextures(),
+ m_currentTexture(),
+ m_currentFallback()
{
- m_info = left.m_info;
m_crossFadeTime = left.m_crossFadeTime;
// defaults
m_currentFadeTime = 0;
if (!ProcessFading(*i, frameTime, currentTime))
i = m_fadingTextures.erase(i);
else
- i++;
+ ++i;
}
if (m_texture.ReadyToRender() || m_texture.GetFileName().IsEmpty())
{
if (!IsVisible()) return;
- for (vector<CFadingTexture *>::iterator itr = m_fadingTextures.begin(); itr != m_fadingTextures.end(); itr++)
+ for (vector<CFadingTexture *>::iterator itr = m_fadingTextures.begin(); itr != m_fadingTextures.end(); ++itr)
(*itr)->m_texture->Render();
m_texture.Render();
{
CRect region = m_texture.GetRenderRect();
- for (vector<CFadingTexture *>::const_iterator itr = m_fadingTextures.begin(); itr != m_fadingTextures.end(); itr++)
+ for (vector<CFadingTexture *>::const_iterator itr = m_fadingTextures.begin(); itr != m_fadingTextures.end(); ++itr)
region.Union( (*itr)->m_texture->GetRenderRect() );
return CGUIControl::CalcRenderRegion().Intersect(region);
CGUITexture *m_texture; ///< texture to fade out
unsigned int m_fadeTime; ///< time to fade out (ms)
bool m_fading; ///< whether we're fading out
+
+ private:
+ CFadingTexture(const CFadingTexture&);
+ CFadingTexture& operator=(const CFadingTexture&);
};
CGUIImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture);
m_info = 0;
}
-const CGUIInfoColor &CGUIInfoColor::operator=(color_t color)
+CGUIInfoColor &CGUIInfoColor::operator=(color_t color)
{
m_color = color;
m_info = 0;
return *this;
}
-const CGUIInfoColor &CGUIInfoColor::operator=(const CGUIInfoColor &color)
+CGUIInfoColor &CGUIInfoColor::operator=(const CGUIInfoColor &color)
{
m_color = color.m_color;
m_info = color.m_info;
public:
CGUIInfoColor(color_t color = 0);
- const CGUIInfoColor &operator=(const CGUIInfoColor &color);
- const CGUIInfoColor &operator=(color_t color);
+ CGUIInfoColor& operator=(const CGUIInfoColor &color);
+ CGUIInfoColor& operator=(color_t color);
operator color_t() const { return m_color; };
bool Update();
if (rect.Intersect(label2.m_renderRect).IsEmpty())
return false; // nothing to do (though it could potentially encroach on the min_space requirement)
- static const float min_space = 10;
// overlap vertically and horizontally - check alignment
CGUILabel &left = label1.m_renderRect.x1 <= label2.m_renderRect.x1 ? label1 : label2;
CGUILabel &right = label1.m_renderRect.x1 <= label2.m_renderRect.x1 ? label2 : label1;
if ((left.m_label.align & 3) == 0 && right.m_label.align & XBFONT_RIGHT)
{
+ static const float min_space = 10;
float chopPoint = (left.m_maxRect.x1 + left.GetMaxWidth() + right.m_maxRect.x2 - right.GetMaxWidth()) * 0.5f;
// [1 [2...[2 1].|..........1] 2]
// [1 [2.....[2 | 1]..1] 2]
return m_bSelected;
}
-const CGUIListItem& CGUIListItem::operator =(const CGUIListItem& item)
+CGUIListItem& CGUIListItem::operator =(const CGUIListItem& item)
{
if (&item == this) return * this;
m_strLabel2 = item.m_strLabel2;
ar << m_bSelected;
ar << m_overlayIcon;
ar << (int)m_mapProperties.size();
- for (PropertyMap::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); it++)
+ for (PropertyMap::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); ++it)
{
ar << it->first;
ar << it->second;
}
ar << (int)m_art.size();
- for (ArtMap::const_iterator i = m_art.begin(); i != m_art.end(); i++)
+ for (ArtMap::const_iterator i = m_art.begin(); i != m_art.end(); ++i)
{
ar << i->first;
ar << i->second;
}
ar << (int)m_artFallbacks.size();
- for (ArtMap::const_iterator i = m_artFallbacks.begin(); i != m_artFallbacks.end(); i++)
+ for (ArtMap::const_iterator i = m_artFallbacks.begin(); i != m_artFallbacks.end(); ++i)
{
ar << i->first;
ar << i->second;
value["strIcon"] = m_strIcon;
value["selected"] = m_bSelected;
- for (PropertyMap::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); it++)
+ for (PropertyMap::const_iterator it = m_mapProperties.begin(); it != m_mapProperties.end(); ++it)
{
value["properties"][it->first] = it->second;
}
- for (ArtMap::const_iterator it = m_art.begin(); it != m_art.end(); it++)
+ for (ArtMap::const_iterator it = m_art.begin(); it != m_art.end(); ++it)
value["art"][it->first] = it->second;
}
virtual ~CGUIListItem(void);
virtual CGUIListItem *Clone() const { return new CGUIListItem(*this); };
- const CGUIListItem& operator =(const CGUIListItem& item);
+ CGUIListItem& operator =(const CGUIListItem& item);
virtual void SetLabel(const CStdString& strLabel);
const CStdString& GetLabel() const;
void Serialize(CVariant& value);
bool HasProperty(const CStdString &strKey) const;
- bool HasProperties() const { return m_mapProperties.size() > 0; };
+ bool HasProperties() const { return !m_mapProperties.empty(); };
void ClearProperty(const CStdString &strKey);
CVariant GetProperty(const CStdString &strKey) const;
CGUIListLabel::CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &info, bool alwaysScroll)
: CGUIControl(parentID, controlID, posX, posY, width, height)
, m_label(posX, posY, width, height, labelInfo, alwaysScroll ? CGUILabel::OVER_FLOW_SCROLL : CGUILabel::OVER_FLOW_TRUNCATE)
+ , m_info(info)
{
- m_info = info;
m_alwaysScroll = alwaysScroll;
// TODO: Remove this "correction"
if (labelInfo.align & XBFONT_RIGHT)
}
-const CGUIMessage& CGUIMessage::operator = (const CGUIMessage& msg)
+CGUIMessage& CGUIMessage::operator = (const CGUIMessage& msg)
{
if (this == &msg) return * this;
CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
CGUIMessage(const CGUIMessage& msg);
virtual ~CGUIMessage(void);
- const CGUIMessage& operator = (const CGUIMessage& msg);
+ CGUIMessage& operator = (const CGUIMessage& msg);
int GetControlId() const ;
int GetMessage() const;
}
CGUIMultiImage::CGUIMultiImage(const CGUIMultiImage &from)
-: CGUIControl(from), m_image(from.m_image)
+ : CGUIControl(from), m_texturePath(), m_imageTimer(), m_files(), m_image(from.m_image)
{
- m_texturePath = from.m_texturePath;
m_timePerImage = from.m_timePerImage;
m_timeToPauseAtEnd = from.m_timeToPauseAtEnd;
m_randomized = from.m_randomized;
CGUIMultiSelectTextControl::CGUIMultiSelectTextControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo, const CGUIInfoLabel &content)
: CGUIControl(parentID, controlID, posX, posY, width, height)
+ , m_label(labelInfo)
+ , m_info(content)
, m_button(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
{
- m_info = content;
- m_label = labelInfo;
m_selectedItem = 0;
m_offset = 0;
m_totalWidth = 0;
CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, CStdString& strRSSTags)
: CGUIControl(parentID, controlID, posX, posY, width, height),
- m_scrollInfo(0,0,labelInfo.scrollSpeed,"")
+ m_label(labelInfo),
+ m_channelColor(channelColor),
+ m_headlineColor(headlineColor),
+ m_scrollInfo(0,0,labelInfo.scrollSpeed,""),
+ m_dirty(true)
{
- m_label = labelInfo;
- m_headlineColor = headlineColor;
- m_channelColor = channelColor;
-
m_strRSSTags = strRSSTags;
m_pReader = NULL;
}
CGUIRSSControl::CGUIRSSControl(const CGUIRSSControl &from)
-: CGUIControl(from),m_scrollInfo(from.m_scrollInfo), m_dirty(true)
+ : CGUIControl(from),
+ m_feed(),
+ m_label(from.m_label),
+ m_channelColor(from.m_channelColor),
+ m_headlineColor(from.m_headlineColor),
+ m_vecUrls(),
+ m_vecIntervals(),
+ m_scrollInfo(from.m_scrollInfo),
+ m_dirty(true)
{
- m_label = from.m_label;
- m_headlineColor = from.m_headlineColor;
- m_channelColor = from.m_channelColor;
m_strRSSTags = from.m_strRSSTags;
m_pReader = NULL;
m_rtl = from.m_rtl;
virtual bool OnMessage(CGUIMessage& message);
bool ProcessSelector(CGUITexture &nib, unsigned int currentTime, float fScaleY, RangeSelector selector);
void SetRangeSelection(bool rangeSelection);
- bool GetRangeSelection() { return m_rangeSelection; }
+ bool GetRangeSelection() const { return m_rangeSelection; }
void SetRangeSelector(RangeSelector selector);
void SwitchRangeSelector();
void SetInfo(int iInfo);
changed |= m_label.SetText(text);
- const float space = 5;
float textWidth = m_label.GetTextWidth() + 2 * m_label.GetLabelInfo().offsetX;
// Position the arrows
bool arrowsOnRight(0 != (m_label.GetLabelInfo().align & (XBFONT_RIGHT | XBFONT_CENTER_X)));
if (!arrowsOnRight)
{
+ const float space = 5;
changed |= m_imgspinDownFocus.SetPosition(m_posX + textWidth + space, m_posY);
changed |= m_imgspinDown.SetPosition(m_posX + textWidth + space, m_posY);
changed |= m_imgspinUpFocus.SetPosition(m_posX + textWidth + space + m_imgspinDown.GetWidth(), m_posY);
void CGUIStaticItem::UpdateProperties(int contextWindow)
{
- for (InfoVector::const_iterator i = m_info.begin(); i != m_info.end(); i++)
+ for (InfoVector::const_iterator i = m_info.begin(); i != m_info.end(); ++i)
{
const CGUIInfoLabel &info = i->first;
const CStdString &name = i->second;
const CLabelInfo& labelInfo, int scrollTime)
: CGUIControl(parentID, controlID, posX, posY, width, height)
, CGUITextLayout(labelInfo.font, true)
+ , m_label(labelInfo)
{
m_offset = 0;
m_scrollOffset = 0;
m_autoScrollDelay = 3000;
m_autoScrollDelayTime = 0;
m_autoScrollRepeatAnim = NULL;
- m_label = labelInfo;
}
CGUITextBox::CGUITextBox(const CGUITextBox &from)
alignment &= ~XBFONT_CENTER_Y;
}
m_font->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
{
const CGUIString &string = *i;
uint32_t align = alignment;
// any difference to the smoothness of scrolling though which will be
// jumpy with this sort of thing. It's not exactly a well used situation
// though, so this hack is probably OK.
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
{
const CGUIString &string = *i;
m_font->DrawScrollingText(x, y, m_colors, shadowColor, string.m_text, alignment, maxWidth, scrollInfo);
// adjust so the baselines of the fonts align
float by = y + m_font->GetTextBaseLine() - m_borderFont->GetTextBaseLine();
m_borderFont->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
{
const CGUIString &string = *i;
uint32_t align = alignment;
m_colors[0] = color;
m_font->Begin();
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
{
const CGUIString &string = *i;
uint32_t align = alignment;
// skip over spaces
pos = lastSpace;
while (pos != line.m_text.end() && IsSpace(*pos))
- pos++;
+ ++pos;
curLine.clear();
lastSpaceInLine = 0;
lastSpace = line.m_text.begin();
lastSpaceInLine = curLine.size();
}
curLine.push_back(letter);
- pos++;
+ ++pos;
}
// now add whatever we have left to the string
float width = m_font->GetTextWidth(curLine);
lines.push_back(string);
lineStart = pos + 1;
}
- pos++;
+ ++pos;
}
// handle the last line if non-empty
if (lineStart < text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
m_textHeight = 0;
if (!m_font) return;
- for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
{
const CGUIString &string = *i;
float w = m_font->GetTextWidth(string.m_text);
unsigned int CGUITextLayout::GetTextLength() const
{
unsigned int length = 0;
- for (vector<CGUIString>::const_iterator i = m_lines.begin(); i != m_lines.end(); i++)
+ for (vector<CGUIString>::const_iterator i = m_lines.begin(); i != m_lines.end(); ++i)
length += i->m_text.size();
return length;
}
protected:
void LineBreakText(const vecText &text, std::vector<CGUIString> &lines);
void WrapText(const vecText &text, float maxWidth);
- void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder);
- CStdStringW BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder);
+ static void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder);
+ static CStdStringW BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder);
void CalcTextExtent();
// our text to render
return *this;
}
-CGUITextureBase::CGUITextureBase(float posX, float posY, float width, float height, const CTextureInfo& texture)
+CGUITextureBase::CGUITextureBase(float posX, float posY, float width, float height, const CTextureInfo& texture) :
+ m_height(height), m_info(texture)
{
m_posX = posX;
m_posY = posY;
m_width = width;
- m_height = height;
- m_info = texture;
// defaults
m_visible = true;
m_invalid = true;
}
-CGUITextureBase::CGUITextureBase(const CGUITextureBase &right)
+CGUITextureBase::CGUITextureBase(const CGUITextureBase &right) :
+ m_height(right.m_height),
+ m_alpha(right.m_alpha),
+ m_info(right.m_info),
+ m_aspect(right.m_aspect)
{
m_posX = right.m_posX;
m_posY = right.m_posY;
m_width = right.m_width;
- m_height = right.m_height;
- m_info = right.m_info;
m_visible = right.m_visible;
m_diffuseColor = right.m_diffuseColor;
- m_alpha = right.m_alpha;
- m_aspect = right.m_aspect;
m_allocateDynamically = right.m_allocateDynamically;
bool AllocateOnDemand();
bool UpdateAnimFrame();
void Render(float left, float top, float bottom, float right, float u1, float v1, float u2, float v2, float u3, float v3);
- void OrientateTexture(CRect &rect, float width, float height, int orientation);
+ static void OrientateTexture(CRect &rect, float width, float height, int orientation);
// functions that our implementation classes handle
virtual void Allocate() {}; ///< called after our textures have been allocated
}
CGUIVisualisationControl::CGUIVisualisationControl(const CGUIVisualisationControl &from)
-: CGUIRenderingControl(from), m_bAttemptedLoad(false)
+ : CGUIRenderingControl(from), m_bAttemptedLoad(false), m_addon()
{
ControlType = GUICONTROL_VISUALISATION;
}
CLog::Log(LOGDEBUG, "Unfocus WindowID: %i, ControlID: %i",GetID(), control->GetID());
}
return true;
- break;
}
case GUI_MSG_SELCHANGED:
bool CGUIWindow::HasID(int controlID) const
{
- for (std::vector<int>::const_iterator it = m_idRange.begin(); it != m_idRange.end() ; it++)
+ for (std::vector<int>::const_iterator it = m_idRange.begin(); it != m_idRange.end() ; ++it)
{
if (controlID == *it)
return true;
dialog->OnMessage(message);
}
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
+ for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it)
{
CGUIWindow *pWindow = (*it).second;
pWindow->OnMessage(message);
// push back all the windows if there are more than one covered by this class
CSingleLock lock(g_graphicsContext);
const vector<int>& idRange = pWindow->GetIDRange();
- for (vector<int>::const_iterator idIt = idRange.begin(); idIt != idRange.end() ; idIt++)
+ for (vector<int>::const_iterator idIt = idRange.begin(); idIt != idRange.end() ; ++idIt)
{
WindowMap::iterator it = m_mapWindows.find(*idIt);
if (it != m_mapWindows.end())
if(*it2 == it->second)
it2 = m_activeDialogs.erase(it2);
else
- it2++;
+ ++it2;
}
m_mapWindows.erase(it);
// as all messages done in WINDOW_INIT will want to be sent to the new
// topmost window). If we are swapping windows, we pop the old window
// off the history stack
- if (swappingWindows && m_windowHistory.size())
+ if (swappingWindows && !m_windowHistory.empty())
m_windowHistory.pop();
AddToWindowHistory(iWindowID);
// g_infoManager.SetPreviousWindow(WINDOW_INVALID);
}
-void CGUIWindowManager::CloseDialogs(bool forceClose)
+void CGUIWindowManager::CloseDialogs(bool forceClose) const
{
CSingleLock lock(g_graphicsContext);
while (m_activeDialogs.size() > 0)
}
}
-bool CGUIWindowManager::OnAction(const CAction &action)
+bool CGUIWindowManager::OnAction(const CAction &action) const
{
CSingleLock lock(g_graphicsContext);
unsigned int topMost = m_activeDialogs.size();
pWindow->DoProcess(currentTime, dirtyregions);
// process all dialogs - visibility may change etc.
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
+ for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it)
{
CGUIWindow *pWindow = (*it).second;
if (pWindow && pWindow->IsDialog())
pWindow->DoProcess(currentTime, dirtyregions);
}
- for (CDirtyRegionList::iterator itr = dirtyregions.begin(); itr != dirtyregions.end(); itr++)
+ for (CDirtyRegionList::iterator itr = dirtyregions.begin(); itr != dirtyregions.end(); ++itr)
m_tracker.MarkDirtyRegion(*itr);
}
m_tracker.MarkDirtyRegion(rect);
}
-void CGUIWindowManager::RenderPass()
+void CGUIWindowManager::RenderPass() const
{
CGUIWindow* pWindow = GetWindow(GetActiveWindow());
if (pWindow)
}
else
{
- for (CDirtyRegionList::const_iterator i = dirtyRegions.begin(); i != dirtyRegions.end(); i++)
+ for (CDirtyRegionList::const_iterator i = dirtyRegions.begin(); i != dirtyRegions.end(); ++i)
{
if (i->IsEmpty())
continue;
{
g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
const CDirtyRegionList &markedRegions = m_tracker.GetMarkedRegions();
- for (CDirtyRegionList::const_iterator i = markedRegions.begin(); i != markedRegions.end(); i++)
+ for (CDirtyRegionList::const_iterator i = markedRegions.begin(); i != markedRegions.end(); ++i)
CGUITexture::DrawQuad(*i, 0x0fff0000);
- for (CDirtyRegionList::const_iterator i = dirtyRegions.begin(); i != dirtyRegions.end(); i++)
+ for (CDirtyRegionList::const_iterator i = dirtyRegions.begin(); i != dirtyRegions.end(); ++i)
CGUITexture::DrawQuad(*i, 0x4c00ff00);
}
if(m_iNested == 0)
{
// delete any windows queued for deletion
- for(iDialog it = m_deleteWindows.begin(); it != m_deleteWindows.end(); it++)
+ for(iDialog it = m_deleteWindows.begin(); it != m_deleteWindows.end(); ++it)
{
// Free any window resources
(*it)->FreeResources(true);
void CGUIWindowManager::DeInitialize()
{
CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
+ for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it)
{
CGUIWindow* pWindow = (*it).second;
if (IsWindowActive(it->first))
CSingleLock lock(m_critSection);
- for(int msgCount = m_vecThreadMessages.size(); m_vecThreadMessages.size() > 0 && msgCount > 0; --msgCount)
+ for(int msgCount = m_vecThreadMessages.size(); !m_vecThreadMessages.empty() && msgCount > 0; --msgCount)
{
// pop up one message per time to make messages be processed by order.
// this will ensure rule No.2 & No.3
void CGUIWindowManager::LoadNotOnDemandWindows()
{
CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
+ for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it)
{
CGUIWindow *pWindow = (*it).second;
if (pWindow->GetLoadType() == CGUIWindow::LOAD_ON_GUI_INIT)
void CGUIWindowManager::UnloadNotOnDemandWindows()
{
CSingleLock lock(g_graphicsContext);
- for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++)
+ for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it)
{
CGUIWindow *pWindow = (*it).second;
if (pWindow->GetLoadType() == CGUIWindow::LOAD_ON_GUI_INIT ||
// and if so, pop all the other windows off the stack so that we
// always have a predictable "Back" behaviour for each window
stack<int> historySave = m_windowHistory;
- while (historySave.size())
+ while (!historySave.empty())
{
if (historySave.top() == newWindowID)
break;
void CGUIWindowManager::ClearWindowHistory()
{
- while (m_windowHistory.size())
+ while (!m_windowHistory.empty())
m_windowHistory.pop();
}
void ActivateWindow(int iWindowID, const std::vector<CStdString>& params, bool swappingWindows = false);
void PreviousWindow();
- void CloseDialogs(bool forceClose = false);
+ void CloseDialogs(bool forceClose = false) const;
// OnAction() runs through our active dialogs and windows and sends the message
// off to the callbacks (application, python, playlist player) and to the
// currently focused window(s). Returns true only if the message is handled.
- bool OnAction(const CAction &action);
+ bool OnAction(const CAction &action) const;
/*! \brief Process active controls allowing them to animate before rendering.
*/
void DumpTextureUse();
#endif
private:
- void RenderPass();
+ void RenderPass() const;
void LoadNotOnDemandWindows();
void UnloadNotOnDemandWindows();
void CGraphicContext::SetOrigin(float x, float y)
{
- if (m_origins.size())
+ if (!m_origins.empty())
m_origins.push(CPoint(x,y) + m_origins.top());
else
m_origins.push(CPoint(x,y));
void CGraphicContext::RestoreOrigin()
{
- if (m_origins.size())
+ if (!m_origins.empty())
m_origins.pop();
RemoveTransform();
}
bool CGraphicContext::SetClipRegion(float x, float y, float w, float h)
{ // transform from our origin
CPoint origin;
- if (m_origins.size())
+ if (!m_origins.empty())
origin = m_origins.top();
// ok, now intersect with our old clip region
CRect rect(x, y, x + w, y + h);
rect += origin;
- if (m_clipRegions.size())
+ if (!m_clipRegions.empty())
{
// intersect with original clip region
rect.Intersect(m_clipRegions.top());
void CGraphicContext::RestoreClipRegion()
{
- if (m_clipRegions.size())
+ if (!m_clipRegions.empty())
m_clipRegions.pop();
// here we could reset the hardware clipping, if applicable
{
// this is the software clipping routine. If the graphics hardware is set to do the clipping
// (eg via SetClipPlane in D3D for instance) then this routine is unneeded.
- if (m_clipRegions.size())
+ if (!m_clipRegions.empty())
{
// take a copy of the vertex rectangle and intersect
// it with our clip region (moved to the same coordinate system)
CRect clipRegion(m_clipRegions.top());
- if (m_origins.size())
+ if (!m_origins.empty())
clipRegion -= m_origins.top();
CRect original(vertex);
vertex.Intersect(clipRegion);
}
// reset our origin and camera
- while (m_origins.size())
+ while (!m_origins.empty())
m_origins.pop();
m_origins.push(CPoint(0, 0));
- while (m_cameras.size())
+ while (!m_cameras.empty())
m_cameras.pop();
m_cameras.push(CPoint(0.5f*m_iScreenWidth, 0.5f*m_iScreenHeight));
{
m_stereoView = view;
- while(m_viewStack.size())
+ while(!m_viewStack.empty())
m_viewStack.pop();
CRect viewport(0.0f, 0.0f, (float)m_iScreenWidth, (float)m_iScreenHeight);
// offset the camera from our current location (this is in XML coordinates) and scale it up to
// the screen resolution
CPoint cam(camera);
- if (m_origins.size())
+ if (!m_origins.empty())
cam += m_origins.top();
cam.x *= (float)m_iScreenWidth / m_windowResolution.iWidth;
{
/* we need to trick renderer that we are fullscreen already so it gives us a valid value */
m_bFullScreenRoot = true;
- newRes = g_renderManager.GetResolution();
+ uiRes = g_renderManager.GetResolution();
m_bFullScreenRoot = false;
}
#endif
if (!free_space)
{ // (re)alloc
m_inputBuffSize += chunksize;
- m_inputBuff = (unsigned char *)realloc(m_inputBuff, m_inputBuffSize);
- if (!m_inputBuff)
+ unsigned char* new_buf = (unsigned char *)realloc(m_inputBuff, m_inputBuffSize);
+ if (!new_buf)
{
CLog::Log(LOGERROR, "%s unable to allocate buffer of size %u", __FUNCTION__, m_inputBuffSize);
+ free(m_inputBuff);
return false;
}
+ else
+ m_inputBuff = new_buf;
+
free_space = chunksize;
chunksize = std::min(chunksize*2, maxchunksize);
}
long unsigned int outBufSize = width * height;
unsigned char* result;
unsigned char* src = buffer;
- unsigned char* rgbbuf, *src2, *dst2;
+ unsigned char* rgbbuf;
if(buffer == NULL)
{
unsigned char* dst = rgbbuf;
for (unsigned int y = 0; y < height; y++)
{
- dst2 = dst;
- src2 = src;
+ unsigned char* dst2 = dst;
+ unsigned char* src2 = src;
for (unsigned int x = 0; x < width; x++, src2 += 4)
{
*dst2++ = src2[2];
JSAMPROW row_pointer[1];
long unsigned int outBufSize = width * height;
unsigned char* src = bufferin;
- unsigned char* rgbbuf, *src2, *dst2;
+ unsigned char* rgbbuf;
if(bufferin == NULL)
{
unsigned char* dst = rgbbuf;
for (unsigned int y = 0; y < height; y++)
{
- dst2 = dst;
- src2 = src;
+
+ unsigned char* dst2 = dst;
+ unsigned char* src2 = src;
for (unsigned int x = 0; x < width; x++, src2 += 4)
{
*dst2++ = src2[2];
bool Read(unsigned char* buffer, unsigned int bufSize, unsigned int minx, unsigned int miny);
bool CreateThumbnail(const CStdString& sourceFile, const CStdString& destFile, int minx, int miny, bool rotateExif);
bool CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const CStdString& destFile, unsigned int minx, unsigned int miny);
- bool CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile);
+ static bool CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile);
void Close();
// methods for the imagefactory
virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format);
protected:
static void jpeg_error_exit(j_common_ptr cinfo);
- unsigned int GetExifOrientation(unsigned char* exif_data, unsigned int exif_data_size);
+ static unsigned int GetExifOrientation(unsigned char* exif_data, unsigned int exif_data_size);
unsigned char *m_inputBuff;
unsigned int m_inputBuffSize;
m_held = 0;
}
-const CKey& CKey::operator=(const CKey& key)
+CKey& CKey::operator=(const CKey& key)
{
if (&key == this) return * this;
m_leftTrigger = key.m_leftTrigger;
CKey(const CKey& key);
virtual ~CKey(void);
- const CKey& operator=(const CKey& key);
+ CKey& operator=(const CKey& key);
uint8_t GetLeftTrigger() const;
uint8_t GetRightTrigger() const;
float GetLeftThumbX() const;
*/
bool LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset = 0);
- CStdString ToUTF8(const CStdString &encoding, const CStdString &str);
+ static CStdString ToUTF8(const CStdString &encoding, const CStdString &str);
std::map<uint32_t, LocStr> m_strings;
typedef std::map<uint32_t, LocStr>::const_iterator ciStrings;
typedef std::map<uint32_t, LocStr>::iterator iStrings;
void MultMatrixf(const GLfloat *matrix);
void LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz);
void PrintMatrix(void);
- bool Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz);
+ static bool Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz);
protected:
struct MatrixWrapper
{
- MatrixWrapper(){};
+ MatrixWrapper(){ memset(&m_values, 0, sizeof(m_values)); };
MatrixWrapper( const float values[16]) { memcpy(m_values,values,sizeof(m_values)); }
MatrixWrapper( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); }
MatrixWrapper &operator=( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); return *this;}
{
return iWidth * fPixelRatio / iHeight;
}
- RESOLUTION_INFO(const RESOLUTION_INFO& res)
+ RESOLUTION_INFO(const RESOLUTION_INFO& res) :
+ Overscan(res.Overscan)
{
- Overscan = res.Overscan; bFullScreen = res.bFullScreen;
+ bFullScreen = res.bFullScreen;
iScreen = res.iScreen; iWidth = res.iWidth; iHeight = res.iHeight;
iScreenWidth = res.iScreenWidth; iScreenHeight = res.iScreenHeight;
iSubtitles = res.iSubtitles; dwFlags = res.dwFlags;
virtual GLuint Handle() = 0;
virtual void SetSource(const string& src) { m_source = src; }
virtual bool LoadSource(const string& filename, const string& prefix = "");
- bool OK() { return m_compiled; }
+ bool OK() const { return m_compiled; }
protected:
string m_source;
virtual void Disable() = 0;
// returns true if shader is compiled and linked
- bool OK() { return m_ok; }
+ bool OK() const { return m_ok; }
// free resources
virtual void Free() {}
: virtual public CShaderProgram
{
public:
- CGLSLShaderProgram()
+ CGLSLShaderProgram() :
+ m_validated(false)
{
m_pFP = new CGLSLPixelShader();
m_pVP = new CGLSLVertexShader();
}
CGLSLShaderProgram(const std::string& vert
- , const std::string& frag)
+ , const std::string& frag) :
+ m_validated(false)
{
m_pFP = new CGLSLPixelShader();
m_pFP->LoadSource(frag);
RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode();
RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo();
- int idx_preferred = -1
- , idx_playing = -1
- , idx_mono = -1
- , idx_select = -1;
+ int idx_playing = -1
+ , idx_mono = -1;
+
// add choices
- idx_preferred = pDlgSelect->Add( g_localizeStrings.Get(36530)
+ int idx_preferred = pDlgSelect->Add( g_localizeStrings.Get(36530)
+ " ("
+ GetLabelForStereoMode(preferred)
+ ")");
+ GetLabelForStereoMode(playing)
+ ")");
- idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select
+ int idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select
pDlgSelect->DoModal();
if(!LoadIImage(pImage, (unsigned char *) inputBuff, inputBuffSize, width, height, autoRotate))
{
delete pImage;
- pImage = NULL;
pImage = ImageFactory::CreateFallbackLoader(texturePath);
if(!LoadIImage(pImage, (unsigned char *) inputBuff, inputBuffSize, width, height))
{
if(!LoadIImage(pImage, buffer, size, width, height))
{
delete pImage;
- pImage = NULL;
pImage = ImageFactory::CreateFallbackLoader(mimeType);
if(!LoadIImage(pImage, buffer, size, width, height))
{
void ClampToEdge();
static unsigned int PadPow2(unsigned int x);
- bool SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements = 4, unsigned int offset=0);
+ static bool SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements = 4, unsigned int offset=0);
private:
// no copy constructor
CAutoBuffer() { p = 0; }
explicit CAutoBuffer(size_t s) { p = (BYTE*)malloc(s); }
~CAutoBuffer() { free(p); }
-operator BYTE*() { return p; }
+operator BYTE*() const { return p; }
void Set(BYTE* buf) { free(p); p = buf; }
bool Resize(size_t s);
void Release() { p = 0; }
+
+private:
+ CAutoBuffer(const CAutoBuffer&);
+ CAutoBuffer& operator=(const CAutoBuffer&);
};
bool CAutoBuffer::Resize(size_t s)
CAutoTexBuffer() { p = 0; }
explicit CAutoTexBuffer(size_t s) { p = (BYTE*)XPhysicalAlloc(s, MAXULONG_PTR, 128, PAGE_READWRITE); }
~CAutoTexBuffer() { if (p) XPhysicalFree(p); }
-operator BYTE*() { return p; }
+operator BYTE*() const { return p; }
BYTE* Set(BYTE* buf) { if (p) XPhysicalFree(p); return p = buf; }
void Release() { p = 0; }
};
testPath += "\\";
int testLength = testPath.GetLength();
std::map<CStdString, FileHeader_t>::iterator it;
- for (it = m_FileHeaders.begin(); it != m_FileHeaders.end(); it++)
+ for (it = m_FileHeaders.begin(); it != m_FileHeaders.end(); ++it)
{
if (it->first.Left(testLength).Equals(testPath))
textures.push_back(it->first);
/************************************************************************/
/* */
/************************************************************************/
-bool CGUITextureManager::CanLoad(const CStdString &texturePath) const
+bool CGUITextureManager::CanLoad(const CStdString &texturePath)
{
if (texturePath == "-")
return false;
return emptyTexture;
}
- for (ilistUnused i = m_unusedTextures.begin(); i != m_unusedTextures.end(); i++)
+ for (ilistUnused i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
{
CTextureMap* pMap = i->first;
if (pMap->GetName() == strTextureName)
i = m_unusedTextures.erase(i);
}
else
- i++;
+ ++i;
}
#if defined(HAS_GL) || defined(HAS_GLES)
virtual ~CGUITextureManager(void);
bool HasTexture(const CStdString &textureName, CStdString *path = NULL, int *bundle = NULL, int *size = NULL);
- bool CanLoad(const CStdString &texturePath) const; ///< Returns true if the texture manager can load this texture
+ static bool CanLoad(const CStdString &texturePath); ///< Returns true if the texture manager can load this texture
const CTextureArray& Load(const CStdString& strTextureName, bool checkBundleOnly = false);
void ReleaseTexture(const CStdString& strTextureName);
void Cleanup();
return easeOut(time, start, change, duration);
}
protected:
- float easeOut(float time, float start, float change, float duration)
+ static float easeOut(float time, float start, float change, float duration)
{
time /= duration;
if (time < (1/2.75)) {
float _a;
float _p;
- float easeIn(float time, float start, float change, float duration)
+ float easeIn(float time, float start, float change, float duration) const
{
float s=0;
float a=_a;
return -(a * pow(2.0f, 10*time) * sin((time * duration - s) * (2 * M_PI) / p )) + start;
}
- float easeOut(float time, float start, float change, float duration)
+ float easeOut(float time, float start, float change, float duration) const
{
float s=0;
float a=_a;
return (a * pow(2.0f, -10*time) * sin((time * duration - s) * (2 * M_PI) / p )) + change + start;
}
- float easeInOut(float time, float start, float change, float duration)
+ float easeInOut(float time, float start, float change, float duration) const
{
float s=0;
float a=_a;
*this = src;
}
-const CAnimEffect &CAnimEffect::operator=(const CAnimEffect &src)
+CAnimEffect& CAnimEffect::operator=(const CAnimEffect &src)
{
if (&src == this) return *this;
m_matrix.SetZRotation(((m_endAngle - m_startAngle)*offset + m_startAngle) * degree_to_radian, m_center.x, m_center.y, g_graphicsContext.GetScalingPixelRatio());
}
-CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEffect(node, EFFECT_TYPE_ZOOM)
+CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEffect(node, EFFECT_TYPE_ZOOM), m_center(CPoint(0,0))
{
// effect defaults
m_startX = m_startY = 100;
m_endX = m_endY = 100;
- m_center = CPoint(0,0);
m_autoCenter = false;
float startPosX = rect.x1;
m_effects.clear();
}
-const CAnimation &CAnimation::operator =(const CAnimation &src)
+CAnimation &CAnimation::operator =(const CAnimation &src)
{
if (this == &src) return *this; // same
m_type = src.m_type;
*this = right;
}
-const CScroller &CScroller::operator=(const CScroller &right)
+CScroller& CScroller::operator=(const CScroller &right)
{
if (&right == this) return *this;
CAnimEffect(const CAnimEffect &src);
virtual ~CAnimEffect();
- const CAnimEffect &operator=(const CAnimEffect &src);
+ CAnimEffect& operator=(const CAnimEffect &src);
void Calculate(unsigned int time, const CPoint ¢er);
void ApplyState(ANIMATION_STATE state, const CPoint ¢er);
virtual ~CAnimation();
- const CAnimation &operator=(const CAnimation &src);
+ CAnimation& operator=(const CAnimation &src);
static CAnimation CreateFader(float start, float end, unsigned int delay, unsigned int length, ANIMATION_TYPE type = ANIM_TYPE_NONE);
public:
CScroller(unsigned int duration = 200, boost::shared_ptr<Tweener> tweener = boost::shared_ptr<Tweener>());
CScroller(const CScroller& right);
- const CScroller &operator=(const CScroller &src);
+ CScroller& operator=(const CScroller &src);
~CScroller();
/**
*/
virtual void ReleaseThumbnailBuffer() {return;}
- unsigned int Width() { return m_width; }
- unsigned int Height() { return m_height; }
- unsigned int originalWidth() { return m_originalWidth; }
- unsigned int originalHeight() { return m_originalHeight; }
- unsigned int Orientation() { return m_orientation; }
- bool hasAlpha() { return m_hasAlpha; }
+ unsigned int Width() const { return m_width; }
+ unsigned int Height() const { return m_height; }
+ unsigned int originalWidth() const { return m_originalWidth; }
+ unsigned int originalHeight() const { return m_originalHeight; }
+ unsigned int Orientation() const { return m_orientation; }
+ bool hasAlpha() const { return m_hasAlpha; }
protected:
Close();
}
-bool CBitstreamConverter::Open(enum CodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb)
+bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb)
{
m_to_annexb = to_annexb;
CBitstreamConverter();
~CBitstreamConverter();
- bool Open(enum CodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb);
+ bool Open(enum AVCodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb);
void Close(void);
bool NeedConvert(void) { return m_convert_bitstream; };
bool Convert(uint8_t *pData, int iSize);
else if (iType == VIDEODB_CONTENT_TVSHOWS)
database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId);
+ CStdString currentTitle;
+ if (detail.m_strSortTitle.IsEmpty())
+ currentTitle = detail.m_strTitle;
+ else
+ currentTitle = detail.m_strSortTitle;
+
// get the new sort title
- if (!CGUIKeyboardFactory::ShowAndGetInput(detail.m_strTitle, g_localizeStrings.Get(16107), false))
+ if (!CGUIKeyboardFactory::ShowAndGetInput(currentTitle, g_localizeStrings.Get(16107), false))
return false;
- return database.UpdateVideoSortTitle(iDbId, detail.m_strTitle, iType);
+ return database.UpdateVideoSortTitle(iDbId, currentTitle, iType);
}
bool CGUIDialogVideoInfo::LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database)