Use source instead of server info to get format for recording in pulse input

When setting up the capture, the plugin will now query pulse for the default
format of the specific source instead of the server.
This is useful if a source has different settings than what the defaults are
for the server, e.g. when the source is an output with 5.1 surround sound
and the microphone input is mono while the server defaults to stereo sound.
This commit is contained in:
fryshorts
2014-08-29 17:12:17 +02:00
parent bbc62f2602
commit b6482d8995

View File

@@ -167,21 +167,36 @@ static void pulse_server_info(pa_context *c, const pa_server_info *i,
void *userdata)
{
UNUSED_PARAMETER(c);
PULSE_DATA(userdata);
UNUSED_PARAMETER(userdata);
blog(LOG_INFO, "pulse-input: Server name: '%s %s'",
i->server_name, i->server_version);
pulse_signal(0);
}
/**
* Source info callback
*/
static void pulse_source_info(pa_context *c, const pa_source_info *i, int eol,
void *userdata)
{
UNUSED_PARAMETER(c);
PULSE_DATA(userdata);
if (eol != 0)
goto skip;
data->format = i->sample_spec.format;
data->samples_per_sec = i->sample_spec.rate;
data->channels = i->sample_spec.channels;
blog(LOG_INFO, "pulse-input: "
"Audio format: %s, %u Hz, %u channels",
pa_sample_format_to_string(i->sample_spec.format),
i->sample_spec.rate,
i->sample_spec.channels);
"Audio format: %s, %"PRIuFAST32" Hz, %"PRIuFAST8" channels",
pa_sample_format_to_string(data->format),
data->samples_per_sec,
data->channels);
skip:
pulse_signal(0);
}
@@ -200,6 +215,12 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data)
return -1;
}
if (pulse_get_source_info(pulse_source_info, data->device,
(void *) data) < 0) {
blog(LOG_ERROR, "pulse-input: Unable to get source info !");
return -1;
}
pa_sample_spec spec;
spec.format = data->format;
spec.rate = data->samples_per_sec;