M src/OpusWriteStream.cpp +3 -1
@@ 33,6 33,7 @@
*/
#ifdef HAVE_OPUS
+#ifndef HAVE_OPUS_READ_ONLY
//#define DEBUG_OPUS_WRITE 1
@@ 157,4 158,5 @@ OpusWriteStream::putInterleavedFrames(si
}
-#endif
+#endif // !HAVE_OPUS_READ_ONLY
+#endif // HAVE_OPUS
M src/OpusWriteStream.h +3 -1
@@ 38,6 38,7 @@
#include "../bqaudiostream/AudioWriteStream.h"
#ifdef HAVE_OPUS
+#ifndef HAVE_OPUS_READ_ONLY
namespace breakfastquay
{
@@ 61,6 62,7 @@ protected:
}
-#endif
+#endif // !HAVE_OPUS_READ_ONLY
+#endif // HAVE_OPUS
#endif
M src/SimpleWavFileReadStream.cpp +18 -3
@@ 64,9 64,24 @@ SimpleWavFileReadStream::SimpleWavFileRe
m_dataReadOffset(0),
m_dataReadStart(0)
{
- m_file = new std::ifstream(filename.c_str(),
- std::ios::in | std::ios::binary);
-
+#ifdef _MSC_VER
+ // This is behind _MSC_VER not _WIN32 because the fstream
+ // constructors from wchar bufs are an MSVC extension not
+ // available in e.g. MinGW
+ int wlen = MultiByteToWideChar
+ (CP_UTF8, 0, m_path.c_str(), m_path.length(), 0, 0);
+ if (wlen > 0) {
+ wchar_t *buf = new wchar_t[wlen+1];
+ (void)MultiByteToWideChar
+ (CP_UTF8, 0, m_path.c_str(), m_path.length(), buf, wlen);
+ buf[wlen] = L'\0';
+ m_file = new std::ifstream(buf, std::ios::in | std::ios::binary);
+ delete[] buf;
+ }
+#else
+ m_file = new std::ifstream(m_path.c_str(), std::ios::in | std::ios::binary);
+#endif
+
if (!*m_file) {
delete m_file;
m_file = 0;
M src/SimpleWavFileReadStream.h +4 -0
@@ 40,6 40,10 @@
// If we have libsndfile, we shouldn't be using this class
#if ! (defined(HAVE_LIBSNDFILE) || defined(HAVE_SNDFILE))
+#ifdef _MSC_VER
+#include <windows.h>
+#endif
+
#include <fstream>
#include <string>
#include <vector>
M src/SimpleWavFileWriteStream.cpp +21 -3
@@ 63,14 63,32 @@ SimpleWavFileWriteStream::SimpleWavFileW
m_bitDepth(24),
m_file(0)
{
- m_file = new std::ofstream(getPath().c_str(), std::ios::out | std::ios::binary);
+ std::string path = getPath();
+
+#ifdef _MSC_VER
+ // This is behind _MSC_VER not _WIN32 because the fstream
+ // constructors from wchar bufs are an MSVC extension not
+ // available in e.g. MinGW
+ int wlen = MultiByteToWideChar
+ (CP_UTF8, 0, path.c_str(), path.length(), 0, 0);
+ if (wlen > 0) {
+ wchar_t *buf = new wchar_t[wlen+1];
+ (void)MultiByteToWideChar
+ (CP_UTF8, 0, path.c_str(), path.length(), buf, wlen);
+ buf[wlen] = L'\0';
+ m_file = new std::ofstream(buf, std::ios::out | std::ios::binary);
+ delete[] buf;
+ }
+#else
+ m_file = new std::ofstream(path.c_str(), std::ios::out | std::ios::binary);
+#endif
if (!*m_file) {
delete m_file;
m_file = 0;
m_error = std::string("Failed to open audio file '") +
- getPath() + "' for writing";
- throw FailedToWriteFile(getPath());
+ path + "' for writing";
+ throw FailedToWriteFile(path);
}
writeFormatChunk();
M src/SimpleWavFileWriteStream.h +4 -0
@@ 40,6 40,10 @@
// If we have libsndfile, we shouldn't be using this class
#if ! (defined(HAVE_LIBSNDFILE) || defined(HAVE_SNDFILE))
+#ifdef _MSC_VER
+#include <windows.h>
+#endif
+
#include <fstream>
#include <string>
M src/WavFileWriteStream.cpp +17 -3
@@ 65,12 65,26 @@ WavFileWriteStream::WavFileWriteStream(T
m_fileInfo.channels = getChannelCount();
m_fileInfo.samplerate = getSampleRate();
- m_file = sf_open(getPath().c_str(), SFM_WRITE, &m_fileInfo);
+ auto path = getPath();
+#ifdef _WIN32
+ int wlen = MultiByteToWideChar
+ (CP_UTF8, 0, path.c_str(), path.length(), 0, 0);
+ if (wlen > 0) {
+ wchar_t *buf = new wchar_t[wlen+1];
+ (void)MultiByteToWideChar
+ (CP_UTF8, 0, path.c_str(), path.length(), buf, wlen);
+ buf[wlen] = L'\0';
+ m_file = sf_wchar_open(buf, SFM_WRITE, &m_fileInfo);
+ delete[] buf;
+ }
+#else
+ m_file = sf_open(path.c_str(), SFM_WRITE, &m_fileInfo);
+#endif
if (!m_file) {
m_error = std::string("Failed to open audio file '") +
- getPath() + "' for writing";
- throw FailedToWriteFile(getPath());
+ path + "' for writing";
+ throw FailedToWriteFile(path);
}
}
M src/WavFileWriteStream.h +5 -0
@@ 39,6 39,11 @@
#if defined(HAVE_LIBSNDFILE) || defined(HAVE_SNDFILE)
+#ifdef _WIN32
+#include <windows.h>
+#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
+#endif
+
#include <sndfile.h>
namespace breakfastquay