-#ifdef DVDOMATIC_POSIX
- int const r = symlink (a.c_str(), b.c_str());
- if (r) {
- throw EncodeError (String::compose ("could not create symlink from %1 to %2", a, b));
- }
-#endif
-
-#ifdef DVDOMATIC_WINDOWS
- boost::filesystem::copy_file (a, b);
-#endif
-}
-
-void
-Encoder::writer_thread ()
-{
- while (1)
- {
- boost::mutex::scoped_lock lock (_writer_mutex);
- TIMING ("writer sleeps with a queue of %1", _write_queue.size());
- while (_write_queue.empty() && !_terminate_writer) {
- _writer_condition.wait (lock);
- }
- TIMING ("writer wakes with a queue of %1", _write_queue.size());
-
- if (_terminate_writer) {
- return;
+ AudioMapping m (_film->audio_channels ());
+ if (m.dcp_channels() != _film->audio_channels()) {
+
+ /* Remap (currently just for mono -> 5.1) */
+
+ shared_ptr<AudioBuffers> b (new AudioBuffers (m.dcp_channels(), data->frames ()));
+ for (int i = 0; i < m.dcp_channels(); ++i) {
+ optional<int> s = m.dcp_to_source (static_cast<libdcp::Channel> (i));
+ if (!s) {
+ b->make_silent (i);
+ } else {
+ memcpy (b->data()[i], data->data()[s.get()], data->frames() * sizeof(float));
+ }