瀏覽代碼

obs-ffmpeg: Make sure hotkeys are actually pressed

Explicitly checks to make sure hotkeys are actually down, rather than
both down and up.  This was causing the restart hotkey to restart the
media twice, once on key down, once on key up.
jp9000 5 年之前
父節點
當前提交
f60c961ae1
共有 1 個文件被更改,包括 15 次插入4 次删除
  1. 15 4
      plugins/obs-ffmpeg/obs-ffmpeg-source.c

+ 15 - 4
plugins/obs-ffmpeg/obs-ffmpeg-source.c

@@ -385,7 +385,9 @@ static void restart_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
 {
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
-	UNUSED_PARAMETER(pressed);
+
+	if (!pressed)
+		return;
 
 	struct ffmpeg_source *s = data;
 	if (obs_source_active(s->source))
@@ -451,9 +453,12 @@ static bool ffmpeg_source_play_hotkey(void *data, obs_hotkey_pair_id id,
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
 
+	if (!pressed)
+		return false;
+
 	struct ffmpeg_source *s = data;
 
-	if (s->state == OBS_MEDIA_STATE_PLAYING || !pressed ||
+	if (s->state == OBS_MEDIA_STATE_PLAYING ||
 	    !obs_source_active(s->source))
 		return false;
 
@@ -467,9 +472,12 @@ static bool ffmpeg_source_pause_hotkey(void *data, obs_hotkey_pair_id id,
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
 
+	if (!pressed)
+		return false;
+
 	struct ffmpeg_source *s = data;
 
-	if (s->state != OBS_MEDIA_STATE_PLAYING || !pressed ||
+	if (s->state != OBS_MEDIA_STATE_PLAYING ||
 	    !obs_source_active(s->source))
 		return false;
 
@@ -483,9 +491,12 @@ static void ffmpeg_source_stop_hotkey(void *data, obs_hotkey_id id,
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
 
+	if (!pressed)
+		return;
+
 	struct ffmpeg_source *s = data;
 
-	if (pressed && obs_source_active(s->source))
+	if (obs_source_active(s->source))
 		obs_source_media_stop(s->source);
 }