Bläddra i källkod

Force PulseAudio sample format if the source format is not supported by OBS

If the sample format used by PulseAudio can not be converted into an
OBS audio format it will be handled as AUDIO_FORMAT_UNKNOWN which will
not result in a proper audio recording. So instead we request a format
that OBS supports from PulseAudio and let it do the format conversion.
Christoph Hohmann 11 år sedan
förälder
incheckning
ed1430622b
1 ändrade filer med 16 tillägg och 7 borttagningar
  1. 16 7
      plugins/linux-pulseaudio/pulse-input.c

+ 16 - 7
plugins/linux-pulseaudio/pulse-input.c

@@ -183,16 +183,25 @@ static void pulse_source_info(pa_context *c, const pa_source_info *i, int eol,
 	if (eol != 0)
 		goto skip;
 
-	data->format          = i->sample_spec.format;
+	blog(LOG_INFO, "Audio format: %s, %"PRIu32" Hz"
+		", %"PRIu8" channels",
+		pa_sample_format_to_string(i->sample_spec.format),
+		i->sample_spec.rate,
+		i->sample_spec.channels);
+
+	pa_sample_format_t format = i->sample_spec.format;
+	if (pulse_to_obs_audio_format(format) == AUDIO_FORMAT_UNKNOWN) {
+		format = PA_SAMPLE_S16LE;
+
+		blog(LOG_INFO, "Sample format %s not supported by OBS, using %s instead for recording",
+			pa_sample_format_to_string(i->sample_spec.format),
+			pa_sample_format_to_string(format));
+	}
+
+	data->format          = format;
 	data->samples_per_sec = i->sample_spec.rate;
 	data->channels        = i->sample_spec.channels;
 
-	blog(LOG_INFO, "Audio format: %s, %"PRIuFAST32" Hz"
-		", %"PRIuFAST8" channels",
-		pa_sample_format_to_string(data->format),
-		data->samples_per_sec,
-		data->channels);
-
 skip:
 	pulse_signal(0);
 }