Browse Source

libobs: Don't call discard_if_stopped if not minor data

Only allow discard_if_stopped to be called if the audio data is marked
as pending, and the pending audio data is below the audio tick threshold
size.
jp9000 9 years ago
parent
commit
ac3b2a08ad
1 changed files with 6 additions and 1 deletions
  1. 6 1
      libobs/obs-audio.c

+ 6 - 1
libobs/obs-audio.c

@@ -125,6 +125,8 @@ static bool discard_if_stopped(obs_source_t *source, size_t channels)
 	}
 }
 
+#define MAX_AUDIO_SIZE (AUDIO_OUTPUT_FRAMES * sizeof(float))
+
 static inline void discard_audio(struct obs_core_audio *audio,
 		obs_source_t *source, size_t channels, size_t sample_rate,
 		struct ts_info *ts)
@@ -152,8 +154,11 @@ static inline void discard_audio(struct obs_core_audio *audio,
 	}
 
 	if (source->audio_ts < (ts->start - 1)) {
-		if (discard_if_stopped(source, channels))
+		if (source->audio_pending &&
+		    source->audio_input_buf[0].size < MAX_AUDIO_SIZE &&
+		    discard_if_stopped(source, channels))
 			return;
+
 #if DEBUG_AUDIO == 1
 		if (is_audio_source) {
 			blog(LOG_DEBUG, "can't discard, source "