Minor cleanups in the framework.
--- a/src/in_xsf_framework/UtfConverter.cpp
+++ b/src/in_xsf_framework/UtfConverter.cpp
@@ -14,11 +14,11 @@
auto result = std::vector<wchar_t>(widesize + 1, L'\0');
auto orig = std::vector<char>(widesize + 1, '\0');
std::copy(utf8string.begin(), utf8string.end(), orig.begin());
- auto *sourcestart = reinterpret_cast<const UTF8 *>(&orig[0]), *sourceend = sourcestart + widesize;
+ auto sourcestart = reinterpret_cast<const UTF8 *>(&orig[0]), sourceend = sourcestart + widesize;
ConversionResult res;
if (sizeof(wchar_t) == 2)
{
- auto *targetstart = reinterpret_cast<UTF16 *>(&result[0]), *targetend = targetstart + widesize;
+ auto targetstart = reinterpret_cast<UTF16 *>(&result[0]), targetend = targetstart + widesize;
res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
*targetstart = 0;
unsigned end = targetstart - reinterpret_cast<UTF16 *>(&result[0]);
@@ -26,7 +26,7 @@
}
else if (sizeof(wchar_t) == 4)
{
- auto *targetstart = reinterpret_cast<UTF32 *>(&result[0]), *targetend = targetstart + widesize;
+ auto targetstart = reinterpret_cast<UTF32 *>(&result[0]), targetend = targetstart + widesize;
res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
*targetstart = 0;
unsigned end = targetstart - reinterpret_cast<UTF32 *>(&result[0]);
@@ -45,16 +45,16 @@
auto result = std::vector<char>(utf8size, '\0');
auto orig = std::vector<wchar_t>(widesize + 1, L'\0');
std::copy(widestring.begin(), widestring.end(), orig.begin());
- auto *targetstart = reinterpret_cast<UTF8 *>(&result[0]), *targetend = targetstart + utf8size;
+ auto targetstart = reinterpret_cast<UTF8 *>(&result[0]), targetend = targetstart + utf8size;
ConversionResult res;
if (sizeof(wchar_t) == 2)
{
- auto *sourcestart = reinterpret_cast<const UTF16 *>(&orig[0]), *sourceend = sourcestart + widesize;
+ auto sourcestart = reinterpret_cast<const UTF16 *>(&orig[0]), sourceend = sourcestart + widesize;
res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
}
else if (sizeof(wchar_t) == 4)
{
- auto *sourcestart = reinterpret_cast<const UTF32 *>(&orig[0]), *sourceend = sourcestart + widesize;
+ auto sourcestart = reinterpret_cast<const UTF32 *>(&orig[0]), sourceend = sourcestart + widesize;
res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
}
else
--- a/src/in_xsf_framework/XSFCommon.h
+++ b/src/in_xsf_framework/XSFCommon.h
@@ -76,14 +76,14 @@
inline bool FileExists(const std::string &filename)
{
- std::ifstream file((filename.c_str()));
+ std::ifstream file(filename.c_str());
return !!file;
}
#ifdef _WIN32
inline bool FileExists(const std::wstring &filename)
{
- std::ifstream file((filename.c_str()));
+ std::ifstream file(filename.c_str());
return !!file;
}
#endif
--- a/src/in_xsf_framework/XSFConfig.cpp
+++ b/src/in_xsf_framework/XSFConfig.cpp
@@ -1,7 +1,7 @@
/*
* xSF - Core configuration handler
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
- * Last modification on 2013-04-23
+ * Last modification on 2014-09-08
*
* Partially based on the vio*sf framework
*/
@@ -56,7 +56,7 @@
std::wstring XSFConfig::GetTextFromWindow(HWND hwnd)
{
- LRESULT length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
+ auto length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
auto value = std::vector<wchar_t>(length + 1);
length = SendMessageW(hwnd, WM_GETTEXT, length + 1, reinterpret_cast<LPARAM>(&value[0]));
return std::wstring(value.begin(), value.begin() + length);
--- a/src/in_xsf_framework/XSFPlayer.cpp
+++ b/src/in_xsf_framework/XSFPlayer.cpp
@@ -1,7 +1,7 @@
/*
* xSF - Core Player
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
- * Last modification on 2013-05-07
+ * Last modification on 2014-09-08
*
* Partially based on the vio*sf framework
*/
@@ -56,25 +56,21 @@
bool endFlag = false;
unsigned detectSilence = xSFConfig->GetDetectSilenceSec();
unsigned pos = 0, bufsize = buf.size() >> 2;
- std::vector<uint8_t> trueBuffer;
- if (this->uses32BitSamplesClampedTo16Bit)
- trueBuffer.resize(bufsize << 3);
- else
- trueBuffer.resize(bufsize << 2);
+ auto trueBuffer = std::vector<uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2));
auto longBuffer = std::vector<uint8_t>(bufsize << 3);
- int32_t *bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]);
+ auto bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]);
while (pos < bufsize)
{
unsigned remain = bufsize - pos, offset = pos;
this->GenerateSamples(trueBuffer, pos << (this->uses32BitSamplesClampedTo16Bit ? 2 : 1), remain);
if (this->uses32BitSamplesClampedTo16Bit)
{
- int32_t *trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
+ auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
std::copy(&trueBufLong[0], &trueBufLong[bufsize << 1], &bufLong[0]);
}
else
{
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
std::copy(&trueBufShort[0], &trueBufShort[bufsize << 1], &bufLong[0]);
}
if (detectSilence || skipSilenceOnStartSec)
@@ -134,12 +130,12 @@
{
if (this->uses32BitSamplesClampedTo16Bit)
{
- int32_t *trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
+ auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufLong[0]);
}
else
{
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufShort[0]);
}
}
@@ -179,7 +175,7 @@
if (this->uses32BitSamplesClampedTo16Bit)
{
- int16_t *bufShort = reinterpret_cast<int16_t *>(&buf[0]);
+ auto bufShort = reinterpret_cast<int16_t *>(&buf[0]);
for (unsigned ofs = 0; ofs < bufsize; ++ofs)
{
int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1];
@@ -191,7 +187,7 @@
}
else
{
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufShort[0]);
std::copy(&trueBuffer[0], &trueBuffer[bufsize << 2], &buf[0]);
}
@@ -199,7 +195,7 @@
/* Fading */
if (!xSFConfig->GetPlayInfinitely() && this->fadeSample && this->currentSample + bufsize >= this->lengthSample)
{
- int16_t *bufShort = reinterpret_cast<int16_t *>(&buf[0]);
+ auto bufShort = reinterpret_cast<int16_t *>(&buf[0]);
for (unsigned ofs = 0; ofs < bufsize; ++ofs)
{
if (this->currentSample + ofs >= this->lengthSample && this->currentSample + ofs < this->lengthSample + this->fadeSample)