, _audio_mapping (audio_mapping)
, _audio_channels (audio_channels)
, _stop_thread (false)
+ , _disable_audio (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));
delete _thread;
}
+bool
+Butler::should_run () const
+{
+ return (_video.size() < VIDEO_READAHEAD || _audio.size() < AUDIO_READAHEAD) && !_stop_thread && !_finished;
+}
+
void
Butler::thread ()
try
boost::mutex::scoped_lock lm (_mutex);
/* Wait until we have something to do */
- while ((_video.size() >= VIDEO_READAHEAD && _audio.size() >= AUDIO_READAHEAD && !_pending_seek_position) || _stop_thread) {
+ while (!should_run() && !_pending_seek_position) {
_summon.wait (lm);
}
while lm is unlocked, as in that state nothing will be added to
_video/_audio.
*/
- while ((_video.size() < VIDEO_READAHEAD || _audio.size() < AUDIO_READAHEAD) && !_pending_seek_position && !_stop_thread) {
+ while (should_run() && !_pending_seek_position) {
lm.unlock ();
if (_player->pass ()) {
_finished = true;
{
boost::mutex::scoped_lock lm (_mutex);
_video.clear ();
+ _audio.clear ();
_finished = false;
_pending_seek_position = position;
_pending_seek_accurate = accurate;
{
{
boost::mutex::scoped_lock lm (_mutex);
- if (_pending_seek_position) {
- /* Don't store any audio while a seek is pending */
+ if (_pending_seek_position || _disable_audio) {
+ /* Don't store any audio while a seek is pending, or if audio is disabled */
return;
}
}
_audio.get (out, _audio_channels, frames);
_summon.notify_all ();
}
+
+void
+Butler::disable_audio ()
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ _disable_audio = true;
+}