diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-11-09 20:29:19 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-11-09 20:29:19 +0000 |
| commit | 1c0f437ea1cbd6231ef9395b1f07c982cd408c39 (patch) | |
| tree | 1b951cfbaba9a85f75cb1a8ae54c6a997fc8fef8 /src/lib | |
| parent | 2b69ea346a5c8f550c3be474db9734dd754eb1a0 (diff) | |
Try to fix crash on drop()ping JobManager. More debugging when resampler fails.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/job_manager.cc | 22 | ||||
| -rw-r--r-- | src/lib/job_manager.h | 4 | ||||
| -rw-r--r-- | src/lib/player.cc | 6 | ||||
| -rw-r--r-- | src/lib/resampler.cc | 5 |
4 files changed, 34 insertions, 3 deletions
diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 2695d3d10..056b9f925 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -37,9 +37,23 @@ using boost::weak_ptr; JobManager* JobManager::_instance = 0; JobManager::JobManager () - : _last_active_jobs (false) + : _terminate (false) + , _last_active_jobs (false) + , _scheduler (new boost::thread (boost::bind (&JobManager::scheduler, this))) { - boost::thread (boost::bind (&JobManager::scheduler, this)); + +} + +JobManager::~JobManager () +{ + { + boost::mutex::scoped_lock lm (_mutex); + _terminate = true; + } + + if (_scheduler->joinable ()) { + _scheduler->join (); + } } shared_ptr<Job> @@ -98,6 +112,10 @@ JobManager::scheduler () { boost::mutex::scoped_lock lm (_mutex); + if (_terminate) { + return; + } + for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) { if (!(*i)->finished ()) { diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index d0dac7d19..0c92efd28 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -23,6 +23,7 @@ #include <list> #include <boost/thread/mutex.hpp> +#include <boost/thread.hpp> #include <boost/signals2.hpp> class Job; @@ -50,12 +51,15 @@ private: friend void ::wait_for_jobs (); JobManager (); + ~JobManager (); void scheduler (); mutable boost::mutex _mutex; std::list<boost::shared_ptr<Job> > _jobs; + bool _terminate; bool _last_active_jobs; + boost::thread* _scheduler; static JobManager* _instance; }; diff --git a/src/lib/player.cc b/src/lib/player.cc index 4fbd906c6..220cf83c0 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -564,6 +564,12 @@ Player::resampler (shared_ptr<AudioContent> c, bool create) if (!create) { return shared_ptr<Resampler> (); } + + _film->log()->log ( + String::compose ( + "Creating new resampler for %1 to %2 with %3 channels", c->content_audio_frame_rate(), c->output_audio_frame_rate(), c->audio_channels() + ) + ); shared_ptr<Resampler> r (new Resampler (c->content_audio_frame_rate(), c->output_audio_frame_rate(), c->audio_channels())); _resamplers[c] = r; diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index 7bc933fd0..d897bf562 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -23,6 +23,7 @@ extern "C" { #include "resampler.h" #include "audio_buffers.h" #include "exceptions.h" +#include "compose.hpp" #include "i18n.h" @@ -77,7 +78,9 @@ Resampler::run (shared_ptr<const AudioBuffers> in, AudioContent::Frame frame) ); if (resampled_frames < 0) { - throw EncodeError (_("could not run sample-rate converter")); + char buf[256]; + av_strerror (resampled_frames, buf, sizeof(buf)); + throw EncodeError (String::compose (_("could not run sample-rate converter for %1 samples (%2) (%3)"), in->frames(), resampled_frames, buf)); } resampled->set_frames (resampled_frames); |
