| ... | ... |
@@ -14,11 +14,11 @@ namespace UtfConverter |
| 14 | 14 |
auto result = std::vector<wchar_t>(widesize + 1, L'\0'); |
| 15 | 15 |
auto orig = std::vector<char>(widesize + 1, '\0'); |
| 16 | 16 |
std::copy(utf8string.begin(), utf8string.end(), orig.begin()); |
| 17 |
- auto *sourcestart = reinterpret_cast<const UTF8 *>(&orig[0]), *sourceend = sourcestart + widesize; |
|
| 17 |
+ auto sourcestart = reinterpret_cast<const UTF8 *>(&orig[0]), sourceend = sourcestart + widesize; |
|
| 18 | 18 |
ConversionResult res; |
| 19 | 19 |
if (sizeof(wchar_t) == 2) |
| 20 | 20 |
{
|
| 21 |
- auto *targetstart = reinterpret_cast<UTF16 *>(&result[0]), *targetend = targetstart + widesize; |
|
| 21 |
+ auto targetstart = reinterpret_cast<UTF16 *>(&result[0]), targetend = targetstart + widesize; |
|
| 22 | 22 |
res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion); |
| 23 | 23 |
*targetstart = 0; |
| 24 | 24 |
unsigned end = targetstart - reinterpret_cast<UTF16 *>(&result[0]); |
| ... | ... |
@@ -26,7 +26,7 @@ namespace UtfConverter |
| 26 | 26 |
} |
| 27 | 27 |
else if (sizeof(wchar_t) == 4) |
| 28 | 28 |
{
|
| 29 |
- auto *targetstart = reinterpret_cast<UTF32 *>(&result[0]), *targetend = targetstart + widesize; |
|
| 29 |
+ auto targetstart = reinterpret_cast<UTF32 *>(&result[0]), targetend = targetstart + widesize; |
|
| 30 | 30 |
res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion); |
| 31 | 31 |
*targetstart = 0; |
| 32 | 32 |
unsigned end = targetstart - reinterpret_cast<UTF32 *>(&result[0]); |
| ... | ... |
@@ -45,16 +45,16 @@ namespace UtfConverter |
| 45 | 45 |
auto result = std::vector<char>(utf8size, '\0'); |
| 46 | 46 |
auto orig = std::vector<wchar_t>(widesize + 1, L'\0'); |
| 47 | 47 |
std::copy(widestring.begin(), widestring.end(), orig.begin()); |
| 48 |
- auto *targetstart = reinterpret_cast<UTF8 *>(&result[0]), *targetend = targetstart + utf8size; |
|
| 48 |
+ auto targetstart = reinterpret_cast<UTF8 *>(&result[0]), targetend = targetstart + utf8size; |
|
| 49 | 49 |
ConversionResult res; |
| 50 | 50 |
if (sizeof(wchar_t) == 2) |
| 51 | 51 |
{
|
| 52 |
- auto *sourcestart = reinterpret_cast<const UTF16 *>(&orig[0]), *sourceend = sourcestart + widesize; |
|
| 52 |
+ auto sourcestart = reinterpret_cast<const UTF16 *>(&orig[0]), sourceend = sourcestart + widesize; |
|
| 53 | 53 |
res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); |
| 54 | 54 |
} |
| 55 | 55 |
else if (sizeof(wchar_t) == 4) |
| 56 | 56 |
{
|
| 57 |
- auto *sourcestart = reinterpret_cast<const UTF32 *>(&orig[0]), *sourceend = sourcestart + widesize; |
|
| 57 |
+ auto sourcestart = reinterpret_cast<const UTF32 *>(&orig[0]), sourceend = sourcestart + widesize; |
|
| 58 | 58 |
res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); |
| 59 | 59 |
} |
| 60 | 60 |
else |
| ... | ... |
@@ -76,14 +76,14 @@ template<typename T1, typename T2> inline void clamp(T1 &valueToClamp, const T2 |
| 76 | 76 |
|
| 77 | 77 |
inline bool FileExists(const std::string &filename) |
| 78 | 78 |
{
|
| 79 |
- std::ifstream file((filename.c_str())); |
|
| 79 |
+ std::ifstream file(filename.c_str()); |
|
| 80 | 80 |
return !!file; |
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
#ifdef _WIN32 |
| 84 | 84 |
inline bool FileExists(const std::wstring &filename) |
| 85 | 85 |
{
|
| 86 |
- std::ifstream file((filename.c_str())); |
|
| 86 |
+ std::ifstream file(filename.c_str()); |
|
| 87 | 87 |
return !!file; |
| 88 | 88 |
} |
| 89 | 89 |
#endif |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Core configuration handler |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-04-23 |
|
| 4 |
+ * Last modification on 2014-09-08 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -56,7 +56,7 @@ const String &XSFConfig::CommonNameWithVersion() |
| 56 | 56 |
|
| 57 | 57 |
std::wstring XSFConfig::GetTextFromWindow(HWND hwnd) |
| 58 | 58 |
{
|
| 59 |
- LRESULT length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); |
|
| 59 |
+ auto length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0); |
|
| 60 | 60 |
auto value = std::vector<wchar_t>(length + 1); |
| 61 | 61 |
length = SendMessageW(hwnd, WM_GETTEXT, length + 1, reinterpret_cast<LPARAM>(&value[0])); |
| 62 | 62 |
return std::wstring(value.begin(), value.begin() + length); |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* xSF - Core Player |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-05-07 |
|
| 4 |
+ * Last modification on 2014-09-08 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Partially based on the vio*sf framework |
| 7 | 7 |
*/ |
| ... | ... |
@@ -56,25 +56,21 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 56 | 56 |
bool endFlag = false; |
| 57 | 57 |
unsigned detectSilence = xSFConfig->GetDetectSilenceSec(); |
| 58 | 58 |
unsigned pos = 0, bufsize = buf.size() >> 2; |
| 59 |
- std::vector<uint8_t> trueBuffer; |
|
| 60 |
- if (this->uses32BitSamplesClampedTo16Bit) |
|
| 61 |
- trueBuffer.resize(bufsize << 3); |
|
| 62 |
- else |
|
| 63 |
- trueBuffer.resize(bufsize << 2); |
|
| 59 |
+ auto trueBuffer = std::vector<uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2)); |
|
| 64 | 60 |
auto longBuffer = std::vector<uint8_t>(bufsize << 3); |
| 65 |
- int32_t *bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]); |
|
| 61 |
+ auto bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]); |
|
| 66 | 62 |
while (pos < bufsize) |
| 67 | 63 |
{
|
| 68 | 64 |
unsigned remain = bufsize - pos, offset = pos; |
| 69 | 65 |
this->GenerateSamples(trueBuffer, pos << (this->uses32BitSamplesClampedTo16Bit ? 2 : 1), remain); |
| 70 | 66 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 71 | 67 |
{
|
| 72 |
- int32_t *trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 68 |
+ auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 73 | 69 |
std::copy(&trueBufLong[0], &trueBufLong[bufsize << 1], &bufLong[0]); |
| 74 | 70 |
} |
| 75 | 71 |
else |
| 76 | 72 |
{
|
| 77 |
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 73 |
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 78 | 74 |
std::copy(&trueBufShort[0], &trueBufShort[bufsize << 1], &bufLong[0]); |
| 79 | 75 |
} |
| 80 | 76 |
if (detectSilence || skipSilenceOnStartSec) |
| ... | ... |
@@ -134,12 +130,12 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 134 | 130 |
{
|
| 135 | 131 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 136 | 132 |
{
|
| 137 |
- int32_t *trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 133 |
+ auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 138 | 134 |
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufLong[0]); |
| 139 | 135 |
} |
| 140 | 136 |
else |
| 141 | 137 |
{
|
| 142 |
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 138 |
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 143 | 139 |
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufShort[0]); |
| 144 | 140 |
} |
| 145 | 141 |
} |
| ... | ... |
@@ -179,7 +175,7 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 179 | 175 |
|
| 180 | 176 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 181 | 177 |
{
|
| 182 |
- int16_t *bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 178 |
+ auto bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 183 | 179 |
for (unsigned ofs = 0; ofs < bufsize; ++ofs) |
| 184 | 180 |
{
|
| 185 | 181 |
int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1]; |
| ... | ... |
@@ -191,7 +187,7 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 191 | 187 |
} |
| 192 | 188 |
else |
| 193 | 189 |
{
|
| 194 |
- int16_t *trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 190 |
+ auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 195 | 191 |
std::copy(&bufLong[0], &bufLong[bufsize << 1], &trueBufShort[0]); |
| 196 | 192 |
std::copy(&trueBuffer[0], &trueBuffer[bufsize << 2], &buf[0]); |
| 197 | 193 |
} |
| ... | ... |
@@ -199,7 +195,7 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 199 | 195 |
/* Fading */ |
| 200 | 196 |
if (!xSFConfig->GetPlayInfinitely() && this->fadeSample && this->currentSample + bufsize >= this->lengthSample) |
| 201 | 197 |
{
|
| 202 |
- int16_t *bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 198 |
+ auto bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 203 | 199 |
for (unsigned ofs = 0; ofs < bufsize; ++ofs) |
| 204 | 200 |
{
|
| 205 | 201 |
if (this->currentSample + ofs >= this->lengthSample && this->currentSample + ofs < this->lengthSample + this->fadeSample) |