Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
f60c961ae1
1 zmenil súbory, kde vykonal 15 pridanie a 4 odobranie
  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(id);
 	UNUSED_PARAMETER(hotkey);
 	UNUSED_PARAMETER(hotkey);
-	UNUSED_PARAMETER(pressed);
+
+	if (!pressed)
+		return;
 
 
 	struct ffmpeg_source *s = data;
 	struct ffmpeg_source *s = data;
 	if (obs_source_active(s->source))
 	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(id);
 	UNUSED_PARAMETER(hotkey);
 	UNUSED_PARAMETER(hotkey);
 
 
+	if (!pressed)
+		return false;
+
 	struct ffmpeg_source *s = data;
 	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))
 	    !obs_source_active(s->source))
 		return false;
 		return false;
 
 
@@ -467,9 +472,12 @@ static bool ffmpeg_source_pause_hotkey(void *data, obs_hotkey_pair_id id,
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
 	UNUSED_PARAMETER(hotkey);
 
 
+	if (!pressed)
+		return false;
+
 	struct ffmpeg_source *s = data;
 	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))
 	    !obs_source_active(s->source))
 		return false;
 		return false;
 
 
@@ -483,9 +491,12 @@ static void ffmpeg_source_stop_hotkey(void *data, obs_hotkey_id id,
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(id);
 	UNUSED_PARAMETER(hotkey);
 	UNUSED_PARAMETER(hotkey);
 
 
+	if (!pressed)
+		return;
+
 	struct ffmpeg_source *s = data;
 	struct ffmpeg_source *s = data;
 
 
-	if (pressed && obs_source_active(s->source))
+	if (obs_source_active(s->source))
 		obs_source_media_stop(s->source);
 		obs_source_media_stop(s->source);
 }
 }