From 8166932d00b40488ac4e43dc6fd1fee57909e7f8 Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Tue, 7 Oct 2014 21:10:06 +0200 Subject: [PATCH 1/2] Fix PulseAudio audio format to OBS audio format mapping The format PA_SAMPLE_S24_32LE is a 24 bit audio format in 32 bit integers and not a 32 bit audio format and so it should no be mapped to AUDIO_FORMAT_32BIT. --- plugins/linux-pulseaudio/pulse-input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/linux-pulseaudio/pulse-input.c b/plugins/linux-pulseaudio/pulse-input.c index 1167e2d8a..ced5dfc8c 100644 --- a/plugins/linux-pulseaudio/pulse-input.c +++ b/plugins/linux-pulseaudio/pulse-input.c @@ -58,7 +58,7 @@ static enum audio_format pulse_to_obs_audio_format( switch (format) { case PA_SAMPLE_U8: return AUDIO_FORMAT_U8BIT; case PA_SAMPLE_S16LE: return AUDIO_FORMAT_16BIT; - case PA_SAMPLE_S24_32LE: return AUDIO_FORMAT_32BIT; + case PA_SAMPLE_S32LE: return AUDIO_FORMAT_32BIT; case PA_SAMPLE_FLOAT32LE: return AUDIO_FORMAT_FLOAT; default: return AUDIO_FORMAT_UNKNOWN; } From ed1430622b8fb8a657a69b75c3cb0f8b42fcf2de Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Tue, 7 Oct 2014 21:55:24 +0200 Subject: [PATCH 2/2] 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. --- plugins/linux-pulseaudio/pulse-input.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/linux-pulseaudio/pulse-input.c b/plugins/linux-pulseaudio/pulse-input.c index ced5dfc8c..80a4b5c04 100644 --- a/plugins/linux-pulseaudio/pulse-input.c +++ b/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); }