mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Test sync on pause
This commit is contained in:
@@ -136,7 +136,6 @@ private:
|
||||
glm::ivec2 _videoResolution = glm::ivec2(2048, 1024); // Used for the fbos
|
||||
bool _isPaused = false;
|
||||
PlaybackMode _playbackMode = PlaybackMode::RealTimeLoop; // Default is to loop
|
||||
bool _playAtNextFrame = false;
|
||||
|
||||
// Maps for keeping track of libmpv commands and formats
|
||||
std::map<MpvKey, const char*> keys;
|
||||
@@ -144,6 +143,8 @@ private:
|
||||
|
||||
// Syncing with multiple nodes
|
||||
double _correctPlaybackTime = 0.0;
|
||||
bool _playAtNextFrame = false;
|
||||
bool _adjustAtNextFrame = false;
|
||||
|
||||
// Video stretching: map to simulation time animation mode
|
||||
double _startJ200Time = 0.0;
|
||||
|
||||
@@ -393,6 +393,10 @@ void VideoPlayer::initializeMpv() {
|
||||
// https://mpv.io/manual/master/#options-video-timing-offset
|
||||
setPropertyStringMpv("video-timing-offset", "0");
|
||||
|
||||
// Use precise seek whenever possible (slower than default behaviour)
|
||||
// https://mpv.io/manual/master/#options-hr-seek
|
||||
setPropertyStringMpv("hr-seek", "yes");
|
||||
|
||||
// Turn off audio as default
|
||||
setPropertyStringMpv("mute", "yes");
|
||||
|
||||
@@ -726,6 +730,7 @@ void VideoPlayer::handleMpvProperties(mpv_event* event) {
|
||||
}
|
||||
int* videoIsPaused = reinterpret_cast<int*>(prop->data);
|
||||
_isPaused = (* videoIsPaused == 1);
|
||||
_adjustAtNextFrame = _isPaused;
|
||||
break;
|
||||
}
|
||||
case MpvKey::Meta: {
|
||||
@@ -778,11 +783,13 @@ void VideoPlayer::preSync(bool isMaster) {
|
||||
void VideoPlayer::encode(SyncBuffer* syncBuffer) {
|
||||
syncBuffer->encode(_correctPlaybackTime);
|
||||
syncBuffer->encode(_playAtNextFrame);
|
||||
syncBuffer->encode(_adjustAtNextFrame);
|
||||
}
|
||||
|
||||
void VideoPlayer::decode(SyncBuffer* syncBuffer) {
|
||||
syncBuffer->decode(_correctPlaybackTime);
|
||||
syncBuffer->decode(_playAtNextFrame);
|
||||
syncBuffer->decode(_adjustAtNextFrame);
|
||||
}
|
||||
|
||||
void VideoPlayer::postSync(bool isMaster) {
|
||||
@@ -815,8 +822,15 @@ void VideoPlayer::postSync(bool isMaster) {
|
||||
if (_playbackMode == PlaybackMode::MapToSimulationTime) {
|
||||
seekToTime(correctVideoPlaybackTime());
|
||||
}
|
||||
|
||||
if (_mpvRenderContext && _mpvHandle) {
|
||||
if (_isPaused && _playAtNextFrame) {
|
||||
if (_isPaused && _adjustAtNextFrame) {
|
||||
if (!isMaster) {
|
||||
seekToTime(_correctPlaybackTime);
|
||||
}
|
||||
_adjustAtNextFrame = false;
|
||||
}
|
||||
else if (_isPaused && _playAtNextFrame) {
|
||||
play();
|
||||
_playAtNextFrame = false;
|
||||
_isPaused = false;
|
||||
|
||||
Reference in New Issue
Block a user