소스 검색

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 년 전
부모
커밋
ed1430622b
1개의 변경된 파일16개의 추가작업 그리고 7개의 파일을 삭제
  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)
 	if (eol != 0)
 		goto skip;
 		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->samples_per_sec = i->sample_spec.rate;
 	data->channels        = i->sample_spec.channels;
 	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:
 skip:
 	pulse_signal(0);
 	pulse_signal(0);
 }
 }