return;
}
+ if (_writer->thrown ()) {
+ _writer->rethrow ();
+ }
+
if (_writer->can_fake_write (_video_frames_out)) {
_writer->fake_write (_video_frames_out);
_have_a_real_frame = false;
*/
+#ifndef DVDOMATIC_EXCEPTIONS_H
+#define DVDOMATIC_EXCEPTIONS_H
+
/** @file src/exceptions.h
* @brief Our exceptions.
*/
#include <stdexcept>
#include <sstream>
#include <cstring>
+#include <boost/exception/all.hpp>
+#include <boost/thread.hpp>
/** @class StringError
* @brief A parent class for exceptions using messages held in a std::string
: StringError (s)
{}
};
+
+class ExceptionStore
+{
+public:
+ bool thrown () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _exception;
+ }
+
+ void rethrow () {
+ boost::mutex::scoped_lock lm (_mutex);
+ boost::rethrow_exception (_exception);
+ }
+
+protected:
+
+ void store_current () {
+ boost::mutex::scoped_lock lm (_mutex);
+ _exception = boost::current_exception ();
+ }
+
+private:
+ boost::exception_ptr _exception;
+ mutable boost::mutex _mutex;
+};
+
+#endif
_sound_asset_writer = _sound_asset->start_write ();
}
-
+
_thread = new boost::thread (boost::bind (&Writer::thread, this));
}
void
Writer::thread ()
+try
{
while (1)
{
--_queued_full_in_memory;
}
}
-
+}
+catch (...)
+{
+ store_current ();
}
void
lock.unlock ();
_thread->join ();
+ if (thrown ()) {
+ rethrow ();
+ }
+
delete _thread;
_thread = 0;
return (frame != 0 && frame < _first_nonexistant_frame);
}
-
bool
operator< (QueueItem const & a, QueueItem const & b)
{
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/thread/condition.hpp>
+#include "exceptions.h"
class Film;
class EncodedData;
bool operator< (QueueItem const & a, QueueItem const & b);
bool operator== (QueueItem const & a, QueueItem const & b);
-class Writer
+class Writer : public ExceptionStore
{
public:
Writer (boost::shared_ptr<Film>);
due to the limit of frames to be held in memory.
*/
int _pushed_to_disk;
-
+
boost::shared_ptr<libdcp::MonoPictureAsset> _picture_asset;
boost::shared_ptr<libdcp::MonoPictureAssetWriter> _picture_asset_writer;
boost::shared_ptr<libdcp::SoundAsset> _sound_asset;