Преглед изворни кода

libobs: Fix bug (source resampler not resetting)

If the audio data had the same format/samplerate as the obs audio
subsystem, it would fail to simply destroy the resampler and set it to
NULL, and then any audio data going through would use the resampler that
was being used before that, causing audio to become garbage.

This bug only started appearing when I recently changed the libobs
internal audio subsystem format to non-interleaved floating point, which
is a common format, and thus caused this bug to actually occur more
often.
jp9000 пре 10 година
родитељ
комит
0f31880c3c
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      libobs/obs-source.c

+ 3 - 1
libobs/obs-source.c

@@ -1575,6 +1575,9 @@ static inline void reset_resampler(obs_source_t *source,
 	source->sample_info.samples_per_sec = audio->samples_per_sec;
 	source->sample_info.speakers        = audio->speakers;
 
+	audio_resampler_destroy(source->resampler);
+	source->resampler = NULL;
+
 	if (source->sample_info.samples_per_sec == obs_info->samples_per_sec &&
 	    source->sample_info.format          == obs_info->format          &&
 	    source->sample_info.speakers        == obs_info->speakers) {
@@ -1582,7 +1585,6 @@ static inline void reset_resampler(obs_source_t *source,
 		return;
 	}
 
-	audio_resampler_destroy(source->resampler);
 	source->resampler = audio_resampler_create(&output_info,
 			&source->sample_info);