From 94071d5ec1c3b66fc583d555c6dfd0f10b3e7897 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Mon, 30 Dec 2019 18:21:01 -0600 Subject: [PATCH] Fixed disc search/skip/step behavior to match Singe 1.18. --- singe/singe.c | 106 ++++++++++++++++++-------------------------------- 1 file changed, 38 insertions(+), 68 deletions(-) diff --git a/singe/singe.c b/singe/singe.c index 3c81c019e..dfb3498b7 100644 --- a/singe/singe.c +++ b/singe/singe.c @@ -512,34 +512,8 @@ int apiDiscPause(lua_State *L) { int apiDiscPauseAtFrame(lua_State *L) { - int n = lua_gettop(L); - int frame = 0; - bool result = false; - double d = 0; - - //***TODO*** WTF is this? Isn't this just DiskSearch? - - if (!_discStopped) { - if (n == 1) { - if (lua_isnumber(L, 1)) { - d = lua_tonumber(L, 1); frame = (int)d; - videoSeek(_videoHandle, frame); - videoPause(_videoHandle); - result = true; - } - } - } else { - luaTrace(L, "discPauseAtFrame", "Failed! Disc is stopped."); - return 0; - } - - if (result) { - luaTrace(L, "discPauseAtFrame", "%d", frame); - } else { - luaTrace(L, "discPauseAtFrame", "Failed!"); - } - - return 0; + // More RDG oddness. This appears to be identical to discSearch. + return apiDiscSearch(L); } @@ -558,18 +532,16 @@ int apiDiscSearch(lua_State *L) { bool result = false; double d = 0; - if (!_discStopped) { - if (n == 1) { - if (lua_isnumber(L, 1)) { - d = lua_tonumber(L, 1); frame = (int)d; - videoSeek(_videoHandle, frame); - videoPause(_videoHandle); - result = true; - } + // No matter the disc state, seek to the frame, display it, and pause. + + if (n == 1) { + if (lua_isnumber(L, 1)) { + d = lua_tonumber(L, 1); frame = (int)d; + videoSeek(_videoHandle, frame); + videoPause(_videoHandle); + _discStopped = false; + result = true; } - } else { - luaTrace(L, "discSearch", "Failed! Disc is stopped."); - return 0; } if (result) { @@ -604,12 +576,13 @@ int apiDiscSkipBackward(lua_State *L) { bool result = false; double d = 0; + // If disc is not stopped, seek backwards to given frame. Do not change play/pause state. + if (!_discStopped) { if (n == 1) { if (lua_isnumber(L, 1)) { d = lua_tonumber(L, 1); frame = videoGetFrame(_videoHandle) - (int)d; videoSeek(_videoHandle, frame); - videoPlay(_videoHandle); result = true; } } @@ -642,12 +615,13 @@ int apiDiscSkipForward(lua_State *L) { bool result = false; double d = 0; + // If disc is not stopped, seek ahead to given frame. Do not change play/pause state. + if (!_discStopped) { if (n == 1) { if (lua_isnumber(L, 1)) { d = lua_tonumber(L, 1); frame = videoGetFrame(_videoHandle) + (int)d; videoSeek(_videoHandle, frame); - videoPlay(_videoHandle); result = true; } } @@ -672,18 +646,16 @@ int apiDiscSkipToFrame(lua_State *L) { bool result = false; double d = 0; - if (!_discStopped) { - if (n == 1) { - if (lua_isnumber(L, 1)) { - d = lua_tonumber(L, 1); frame = (int)d; - videoSeek(_videoHandle, frame); - videoPlay(_videoHandle); - result = true; - } + // No matter disc state, seek to given frame and play. + + if (n == 1) { + if (lua_isnumber(L, 1)) { + d = lua_tonumber(L, 1); frame = (int)d; + videoSeek(_videoHandle, frame); + videoPlay(_videoHandle); + _discStopped = false; + result = true; } - } else { - luaTrace(L, "discSkipToFrame", "Failed! Disc is stopped."); - return 0; } if (result) { @@ -699,14 +671,13 @@ int apiDiscStepBackward(lua_State *L) { (void)L; - if (!_discStopped) { - frame = videoGetFrame(_videoHandle) - 1; - videoSeek(_videoHandle, frame); - videoPause(_videoHandle); - luaTrace(L, "discStepBackward", "%d", frame); - } else { - luaTrace(L, "discStepBackward", "Failed! Disc is stopped."); - } + // No matter disc state, go back a frame. If playing, pause. + + frame = videoGetFrame(_videoHandle) - 1; + videoSeek(_videoHandle, frame); + videoPause(_videoHandle); + luaTrace(L, "discStepBackward", "%d", frame); + return 0; } @@ -716,14 +687,13 @@ int apiDiscStepForward(lua_State *L) { (void)L; - if (!_discStopped) { - frame = videoGetFrame(_videoHandle) + 1; - videoSeek(_videoHandle, frame); - videoPause(_videoHandle); - luaTrace(L, "discStepForward", "%d", frame); - } else { - luaTrace(L, "discStepForward", "Failed! Disc is stopped."); - } + // No matter disc state, go forward a frame. If playing, pause. + + frame = videoGetFrame(_videoHandle) + 1; + videoSeek(_videoHandle, frame); + videoPause(_videoHandle); + luaTrace(L, "discStepForward", "%d", frame); + return 0; }