Skip to content
Snippets Groups Projects
Commit b6482d89 authored by fryshorts's avatar fryshorts
Browse files

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.
parent bbc62f26
No related branches found
No related tags found
No related merge requests found
...@@ -167,21 +167,36 @@ static void pulse_server_info(pa_context *c, const pa_server_info *i, ...@@ -167,21 +167,36 @@ static void pulse_server_info(pa_context *c, const pa_server_info *i,
void *userdata) void *userdata)
{ {
UNUSED_PARAMETER(c); UNUSED_PARAMETER(c);
PULSE_DATA(userdata); UNUSED_PARAMETER(userdata);
blog(LOG_INFO, "pulse-input: Server name: '%s %s'", blog(LOG_INFO, "pulse-input: Server name: '%s %s'",
i->server_name, i->server_version); 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->format = i->sample_spec.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, "pulse-input: " blog(LOG_INFO, "pulse-input: "
"Audio format: %s, %u Hz, %u channels", "Audio format: %s, %"PRIuFAST32" Hz, %"PRIuFAST8" channels",
pa_sample_format_to_string(i->sample_spec.format), pa_sample_format_to_string(data->format),
i->sample_spec.rate, data->samples_per_sec,
i->sample_spec.channels); data->channels);
skip:
pulse_signal(0); pulse_signal(0);
} }
...@@ -200,6 +215,12 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data) ...@@ -200,6 +215,12 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data)
return -1; 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; pa_sample_spec spec;
spec.format = data->format; spec.format = data->format;
spec.rate = data->samples_per_sec; spec.rate = data->samples_per_sec;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment