using std::cout;
using std::pair;
using std::make_pair;
+using std::string;
using boost::weak_ptr;
using boost::shared_ptr;
using boost::bind;
/** Minimum video readahead in frames */
#define MINIMUM_VIDEO_READAHEAD 10
/** Maximum video readahead in frames; should never be reached unless there are bugs in Player */
-#define MAXIMUM_VIDEO_READAHEAD 240
+#define MAXIMUM_VIDEO_READAHEAD 24
/** Minimum audio readahead in frames */
-#define MINIMUM_AUDIO_READAHEAD (48000*5)
+#define MINIMUM_AUDIO_READAHEAD (48000 * MINIMUM_VIDEO_READAHEAD / 24)
/** Minimum audio readahead in frames; should never be reached unless there are bugs in Player */
-#define MAXIMUM_AUDIO_READAHEAD (48000*60)
+#define MAXIMUM_AUDIO_READAHEAD (48000 * MAXIMUM_VIDEO_READAHEAD / 24)
#define LOG_WARNING(...) _log->log (String::compose(__VA_ARGS__), LogEntry::TYPE_WARNING);
{
_player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2));
_player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1));
- _player_changed_connection = _player->Changed.connect (bind (&Butler::player_changed, this));
_thread = new boost::thread (bind (&Butler::thread, this));
/* Create some threads to do work on the PlayerVideos we are creating; at present this is used to
LOG_WARNING ("Butler audio buffers reached %1 frames", _audio.size());
}
- return (_video.size() < MINIMUM_VIDEO_READAHEAD || (!_disable_audio && _audio.size() < MINIMUM_AUDIO_READAHEAD))
- && (_video.size() < MAXIMUM_VIDEO_READAHEAD)
- && (_audio.size() < MAXIMUM_AUDIO_READAHEAD)
- && !_stop_thread
- && !_finished
- && !_died;
+ if (_stop_thread || _finished || _died) {
+ /* Definitely do not run */
+ return false;
+ }
+
+ if (_video.size() < MINIMUM_VIDEO_READAHEAD || (!_disable_audio && _audio.size() < MINIMUM_AUDIO_READAHEAD)) {
+ /* Definitely do run: we need data */
+ return true;
+ }
+
+ /* Run if we aren't full of video or audio */
+ return (_video.size() < MAXIMUM_VIDEO_READAHEAD) && (_audio.size() < MAXIMUM_AUDIO_READAHEAD);
}
void
_audio.put (remap (audio, _audio_channels, _audio_mapping));
}
-void
-Butler::player_changed ()
-{
- _video.clear ();
- _audio.clear ();
- _summon.notify_all ();
-}
-
/** Try to get `frames' frames of audio and copy it into `out'. Silence
* will be filled if no audio is available.
* @return true if there was a buffer underrun, otherwise false.
boost::mutex::scoped_lock lm (_mutex);
_disable_audio = true;
}
+
+pair<size_t, string>
+Butler::memory_used () const
+{
+ /* XXX: should also look at _audio.memory_used() */
+ return _video.memory_used();
+}