, _finished (false)
, _audio_mapping (audio_mapping)
, _audio_channels (audio_channels)
+ , _stop_thread (false)
{
_player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2));
_player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1, _2));
Butler::~Butler ()
{
+ _stop_thread = true;
_thread->interrupt ();
try {
_thread->join ();
void
Butler::thread ()
+try
{
while (true) {
boost::mutex::scoped_lock lm (_mutex);
/* Wait until we have something to do */
- while (_video.size() >= VIDEO_READAHEAD && !_pending_seek_position) {
+ while ((_video.size() >= VIDEO_READAHEAD && !_pending_seek_position) || _stop_thread) {
_summon.wait (lm);
}
while lm is unlocked, as in that state nothing will be added to
_video.
*/
- while (_video.size() < VIDEO_READAHEAD && !_pending_seek_position) {
+ while (_video.size() < VIDEO_READAHEAD && !_pending_seek_position && !_stop_thread) {
lm.unlock ();
if (_player->pass ()) {
_finished = true;
_arrived.notify_all ();
}
}
+} catch (boost::thread_interrupted) {
+ /* The butler thread is being terminated */
}
pair<shared_ptr<PlayerVideo>, DCPTime>
AudioMapping _audio_mapping;
int _audio_channels;
+ bool _stop_thread;
+
boost::signals2::scoped_connection _player_video_connection;
boost::signals2::scoped_connection _player_audio_connection;
boost::signals2::scoped_connection _player_changed_connection;