Browse Source

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 years ago
parent
commit
f60c961ae1
1 changed files with 15 additions and 4 deletions
  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);
 }