diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_decoder.cc | 26 | ||||
| -rw-r--r-- | src/lib/audio_decoder.h | 1 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 27 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 5 |
4 files changed, 49 insertions, 10 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index e4f98c678..e4c82f64c 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -19,12 +19,9 @@ #include "audio_decoder.h" #include "audio_buffers.h" -#include "exceptions.h" -#include "log.h" +#include "audio_processor.h" #include "resampler.h" #include "util.h" -#include "film.h" -#include "audio_processor.h" #include "i18n.h" @@ -171,6 +168,12 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time) assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames())); + add (data); +} + +void +AudioDecoder::add (shared_ptr<const AudioBuffers> data) +{ /* Resize _decoded_audio to fit the new data */ int new_size = 0; if (_decoded_audio.audio->frames() == 0) { @@ -188,9 +191,17 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time) /* Copy new data in */ _decoded_audio.audio->copy_from (data.get(), data->frames(), 0, _audio_position.get() - _decoded_audio.frame); _audio_position = _audio_position.get() + data->frames (); + + /* Limit the amount of data we keep in case nobody is asking for it */ + int const max_frames = _audio_content->resampled_audio_frame_rate () * 10; + if (_decoded_audio.audio->frames() > max_frames) { + int const to_remove = _decoded_audio.audio->frames() - max_frames; + _decoded_audio.frame += to_remove; + _decoded_audio.audio->move (to_remove, 0, max_frames); + _decoded_audio.audio->set_frames (max_frames); + } } -/* XXX: called? */ void AudioDecoder::flush () { @@ -198,13 +209,10 @@ AudioDecoder::flush () return; } - /* shared_ptr<const AudioBuffers> b = _resampler->flush (); if (b) { - _pending.push_back (shared_ptr<DecodedAudio> (new DecodedAudio (b, _audio_position.get ()))); - _audio_position = _audio_position.get() + b->frames (); + add (b); } - */ } void diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index 045efc002..750ecd360 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -58,6 +58,7 @@ protected: void audio (boost::shared_ptr<const AudioBuffers>, ContentTime); void flush (); void reset_decoded_audio (); + void add (boost::shared_ptr<const AudioBuffers>); boost::shared_ptr<const AudioContent> _audio_content; boost::shared_ptr<Resampler> _resampler; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 96e20a281..f2f6ba23d 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -114,6 +114,8 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) JobManager::instance()->ActiveJobsChanged.connect ( bind (&FilmViewer::active_jobs_changed, this, _1) ); + + setup_sensitivity (); } void @@ -142,8 +144,10 @@ FilmViewer::set_film (shared_ptr<Film> f) return; } + _film_connection = _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1)); + _player->set_approximate_size (); - _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); + _player_connection = _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); calculate_sizes (); get (_position, _last_get_accurate); @@ -402,3 +406,24 @@ FilmViewer::player_changed (bool frequent) calculate_sizes (); get (_position, _last_get_accurate); } + +void +FilmViewer::setup_sensitivity () +{ + bool const c = !_film->content().empty (); + _slider->Enable (c); + _back_button->Enable (c); + _forward_button->Enable (c); + _play_button->Enable (c); + _outline_content->Enable (c); + _frame_number->Enable (c); + _timecode->Enable (c); +} + +void +FilmViewer::film_changed (Film::Property p) +{ + if (p == Film::CONTENT) { + setup_sensitivity (); + } +} diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 930937596..0235d225f 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -55,6 +55,8 @@ private: void set_position_text (); void get (DCPTime, bool); void refresh_panel (); + void setup_sensitivity (); + void film_changed (Film::Property); boost::shared_ptr<Film> _film; boost::shared_ptr<Player> _player; @@ -84,4 +86,7 @@ private: * can get the same one that we got last time. */ bool _last_get_accurate; + + boost::signals2::scoped_connection _film_connection; + boost::signals2::scoped_connection _player_connection; }; |
