Skip to content

Commit

Permalink
[source] Set and keep IN_VOICE_CALL for voicecall source.
Browse files Browse the repository at this point in the history
After AUDIO_DEVICE_IN_VOICE_CALL has been enabled for source, do not
switch to any other routing. This would break the recording. Changing
output routing changes input routing correctly to match the output route
(for example with earpiece output use internal mic for input, for
headset output use headset mic for input) as long as input has
AUDIO_DEVICE_IN_VOICE_CALL route.
  • Loading branch information
Juho Hämäläinen committed Nov 18, 2014
1 parent b0dfba9 commit 89c4b53
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/droid/droid-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ static int source_set_port_cb(pa_source *s, pa_device_port *p) {
return 0;
}

static void source_set_voicecall_source_port(struct userdata *u) {
pa_device_port *port;
pa_droid_port_data *data;
void *state;

pa_assert(u);
pa_assert(u->source);

PA_HASHMAP_FOREACH(port, u->source->ports, state) {
data = PA_DEVICE_PORT_DATA(port);

if (data->device & AUDIO_DEVICE_IN_VOICE_CALL) {
pa_source_set_port(u->source, port->name, false);
break;
}
}
}

static void source_set_name(pa_modargs *ma, pa_source_new_data *data, const char *module_id) {
const char *tmp;
Expand Down Expand Up @@ -442,8 +459,8 @@ pa_source *pa_droid_source_new(pa_module *m,
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);

/* Enabled routing changes by default. */
u->routing_changes_enabled = true;
/* Enabled routing changes by default, except for voicecall source. */
u->routing_changes_enabled = voicecall_source ? false : true;

if (card_data) {
pa_assert(card);
Expand Down Expand Up @@ -612,9 +629,12 @@ pa_source *pa_droid_source_new(pa_module *m,
pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->buffer_size, &sample_spec));
pa_log_debug("Set fixed latency %" PRIu64 " usec", pa_bytes_to_usec(u->buffer_size, &sample_spec));

if (u->source->active_port)
if (!voicecall_source && u->source->active_port)
source_set_port_cb(u->source, u->source->active_port);

if (voicecall_source)
source_set_voicecall_source_port(u);

pa_source_put(u->source);

return u->source;
Expand Down

0 comments on commit 89c4b53

Please sign in to comment.