Add some basic JSON stuff.
[dcpomatic.git] / src / lib / transcode_job.cc
index 87fd5daefca06d06ed1e2fee5cf6eb89237d4104..7b304cb35b48d549e683bd403ec8b5d923b0e4e9 100644 (file)
@@ -50,6 +50,12 @@ TranscodeJob::name () const
        return String::compose (_("Transcode %1"), _film->name());
 }
 
+string
+TranscodeJob::json_name () const
+{
+       return N_("transcode");
+}
+
 void
 TranscodeJob::run ()
 {
@@ -63,6 +69,7 @@ TranscodeJob::run ()
                set_state (FINISHED_OK);
 
                _film->log()->log (N_("Transcode job completed successfully"));
+               _transcoder.reset ();
 
        } catch (...) {
                set_progress (1);
@@ -99,17 +106,20 @@ TranscodeJob::status () const
 int
 TranscodeJob::remaining_time () const
 {
-       if (!_transcoder) {
+       /* _transcoder might be destroyed by the job-runner thread */
+       shared_ptr<Transcoder> t = _transcoder;
+       
+       if (!t) {
                return 0;
        }
        
-       float fps = _transcoder->current_encoding_rate ();
+       float fps = t->current_encoding_rate ();
 
        if (fps == 0) {
                return 0;
        }
 
        /* Compute approximate proposed length here, as it's only here that we need it */
-       OutputVideoFrame const left = _film->time_to_video_frames (_film->length ()) - _transcoder->video_frames_out();
+       OutputVideoFrame const left = _film->time_to_video_frames (_film->length ()) - t->video_frames_out();
        return left / fps;
 }