Various fixups.
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Dec 2012 14:42:54 +0000 (14:42 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 16 Dec 2012 14:42:54 +0000 (14:42 +0000)
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_decoder.h
src/wx/film_viewer.cc

index 314ab7c06f99095073420e06f9f6affe9e1cb232..24ee89b21c30fb0f81d516683ecbed9cd69cdd12 100644 (file)
@@ -78,7 +78,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<Film> f, shared_ptr<const DecodeOptions
        setup_audio ();
        setup_subtitle ();
 
-       f->Changed.connect (bind (&FFmpegDecoder::film_changed, this, _1));
+       _film_connection = f->Changed.connect (bind (&FFmpegDecoder::film_changed, this, _1));
 }
 
 FFmpegDecoder::~FFmpegDecoder ()
index 9cf3de28f7e022b430728bc3c488345d3e749839..1db46a4230c7390b908ea651684be5d9b06820c7 100644 (file)
@@ -120,6 +120,7 @@ private:
        boost::shared_ptr<AudioBuffers> deinterleave_audio (uint8_t* data, int size);
 
        void film_changed (Film::Property);
+       boost::signals2::scoped_connection _film_connection;
 
        std::string stream_name (AVStream* s) const;
 
index 5c3e26a31ddeeb4074b2d0f6a389d78983de8919..1cf45fd4e47a568b22ae3af5c94aceb6a069535f 100644 (file)
@@ -82,6 +82,16 @@ FilmViewer::film_changed (Film::Property p)
                calculate_sizes ();
                update_from_raw ();
                break;
+       case Film::CONTENT:
+       {
+               shared_ptr<DecodeOptions> o (new DecodeOptions);
+               o->decode_audio = false;
+               o->video_sync = false;
+               _decoders = decoder_factory (_film, o, 0);
+               _decoders.video->Video.connect (bind (&FilmViewer::process_video, this, _1, _2));
+               _decoders.video->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
+               break;
+       }
        default:
                break;
        }
@@ -102,13 +112,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
 
        _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));
 
-       shared_ptr<DecodeOptions> o (new DecodeOptions);
-       o->decode_audio = false;
-       o->video_sync = false;
-       _decoders = decoder_factory (_film, o, 0);
-       _decoders.video->Video.connect (bind (&FilmViewer::process_video, this, _1, _2));
-       _decoders.video->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
-
+       film_changed (Film::CONTENT);
        film_changed (Film::CROP);
        film_changed (Film::FORMAT);
 }
@@ -130,9 +134,11 @@ FilmViewer::timer (wxTimerEvent& ev)
                _decoders.video->pass ();
        }
 
-       int const new_slider_position = 4096 * _decoders.video->last_source_frame() / _film->length().get();
-       if (new_slider_position != _slider->GetValue()) {
-               _slider->SetValue (new_slider_position);
+       if (_film->length()) {
+               int const new_slider_position = 4096 * _decoders.video->last_source_frame() / _film->length().get();
+               if (new_slider_position != _slider->GetValue()) {
+                       _slider->SetValue (new_slider_position);
+               }
        }
 }
 
@@ -154,7 +160,9 @@ FilmViewer::paint_panel (wxPaintEvent& ev)
 void
 FilmViewer::slider_moved (wxCommandEvent& ev)
 {
-       seek_and_update (_slider->GetValue() * _film->length().get() / 4096);
+       if (_film->length()) {
+               seek_and_update (_slider->GetValue() * _film->length().get() / 4096);
+       }
 }
 
 void