Try to fix windows build failure (#1071).
authorCarl Hetherington <cth@carlh.net>
Fri, 12 May 2017 20:17:09 +0000 (21:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 12 May 2017 20:17:09 +0000 (21:17 +0100)
src/lib/cross.cc
src/lib/cross.h
src/lib/ffmpeg_encoder.cc

index 454fe044cb51b2e19b3c646ba4d87738cbf762dc..a484d17388c523d009e2f3d418cf2f75518bb91e 100644 (file)
@@ -22,6 +22,9 @@
 #include "compose.hpp"
 #include "log.h"
 #include "exceptions.h"
+extern "C" {
+#include <libavformat/avio.h>
+}
 #include <boost/algorithm/string.hpp>
 #ifdef DCPOMATIC_LINUX
 #include <unistd.h>
@@ -406,3 +409,18 @@ thread_id ()
        return (uint64_t) pthread_self ();
 #endif
 }
+
+int
+avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
+{
+#ifdef DCPOMATIC_WINDOWS
+       int const length = (file.length() + 1) * 2;
+       char* utf8 = new char[length];
+       WideCharToMultibyte (CP_UTF8, 0, file.c_str(), -1, utf8, length, 0, 0);
+       int const r = avio_open_boost (s, file.c_str(), flags);
+       delete[] utf8;
+       return r;
+#else
+       return avio_open_boost (s, file.c_str(), flags);
+#endif
+}
index 9fac7e64362536eb25c0f9d1b6e224a5def1cf94..02839eb68a5678bfbe2bed0fc98fd432720c6a73 100644 (file)
@@ -35,6 +35,7 @@
 #endif
 
 class Log;
+struct AVIOContext;
 
 void dcpomatic_sleep (int);
 extern std::string cpu_info ();
@@ -49,6 +50,7 @@ extern FILE * fopen_boost (boost::filesystem::path, std::string);
 extern int dcpomatic_fseek (FILE *, int64_t, int);
 extern void start_batch_converter (boost::filesystem::path dcpomatic);
 extern uint64_t thread_id ();
+extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
 
 /** @class Waker
  *  @brief A class which tries to keep the computer awake on various operating systems.
index 8464faf7d854dfd8d50d20e898735d7a5f03943f..f26f66bfff320e909b598a54799eb183f8791ed6 100644 (file)
@@ -25,6 +25,7 @@
 #include "player_video.h"
 #include "log.h"
 #include "image.h"
+#include "cross.h"
 #include "compose.hpp"
 #include <iostream>
 
@@ -159,7 +160,7 @@ FFmpegEncoder::go ()
                throw runtime_error (String::compose ("could not open FFmpeg audio codec (%1)", buffer));
        }
 
-       if (avio_open (&_format_context->pb, _output.c_str(), AVIO_FLAG_WRITE) < 0) {
+       if (avio_open_boost (&_format_context->pb, _output, AVIO_FLAG_WRITE) < 0) {
                throw runtime_error ("could not open FFmpeg output file");
        }