Call processor process_end methods as required. Remove questionable padding of audio...
[dcpomatic.git] / src / lib / transcoder.cc
index 2ee96790a270d9bc5c83235e6f42550f42cfcd91..537b9b66452d6f4b8e30dbe4f824b9983166fb0b 100644 (file)
@@ -56,9 +56,9 @@ Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j,
        assert (_encoder);
 
        if (f->audio_stream()) {
-               AudioStream st = f->audio_stream().get();
-               _matcher.reset (new Matcher (f->log(), st.sample_rate(), f->frames_per_second()));
-               _delay_line.reset (new DelayLine (f->log(), st.channels(), f->audio_delay() * st.sample_rate() / 1000));
+               shared_ptr<AudioStream> st = f->audio_stream();
+               _matcher.reset (new Matcher (f->log(), st->sample_rate(), f->frames_per_second()));
+               _delay_line.reset (new DelayLine (f->log(), st->channels(), f->audio_delay() * st->sample_rate() / 1000));
                _gain.reset (new Gain (f->log(), f->audio_gain()));
        }
 
@@ -109,12 +109,18 @@ Transcoder::go ()
                }
                
        } catch (...) {
-               /* process_end() is important as the decoder may have worker
-                  threads that need to be cleaned up.
-               */
                _encoder->process_end ();
                throw;
        }
-
+       
+       if (_delay_line) {
+               _delay_line->process_end ();
+       }
+       if (_matcher) {
+               _matcher->process_end ();
+       }
+       if (_gain) {
+               _gain->process_end ();
+       }
        _encoder->process_end ();
 }