Merge pull request #107 from jusa/jb53992

Add quirks standby_set_route and speaker_before_voice.
This commit is contained in:
Juho Hämäläinen 2021-05-06 13:10:28 +03:00 committed by GitHub
commit 42af5e85c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View file

@ -388,6 +388,20 @@ Currently there are following quirks:
writing audio too early will break the calibration. In these cases
this quirk can be enabled and 10 seconds of sleep is added after
opening hw module.
* standby_set_route
* Disabled by default.
* Some devices don't like to receive set_parameters() call while they
are in write(), even if it seems the mutexes are correctly in place.
Standby is another synchronization point which seems to work better.
If there are hiccups like long delays when setting route during
voice call start try enabling this quirk.
* speaker_before_voice
* Disabled by default.
* Set route to speaker before changing audio mode to AUDIO_MODE_IN_CALL.
Some devices don't get routing right if the route is something else
(like AUDIO_DEVICE_OUT_WIRED_HEADSET) before calling set_mode().
If routing is wrong when call starts with wired accessory connected
try enabling this quirk.
For example, to disable input_atoi and enable close_input quirks, use module
argument

View file

@ -88,6 +88,8 @@ struct droid_quirk valid_quirks[] = {
{ "output_fast", QUIRK_OUTPUT_FAST },
{ "output_deep_buffer", QUIRK_OUTPUT_DEEP_BUFFER },
{ "audio_cal_wait", QUIRK_AUDIO_CAL_WAIT },
{ "standby_set_route", QUIRK_STANDBY_SET_ROUTE },
{ "speaker_before_voice", QUIRK_SPEAKER_BEFORE_VOICE },
};
#define QUIRK_AUDIO_CAL_WAIT_S (10)
@ -1915,6 +1917,13 @@ static int droid_output_stream_set_route(pa_droid_stream *s, audio_devices_t dev
if (slave == s)
continue;
if (pa_droid_quirk(s->module, QUIRK_STANDBY_SET_ROUTE)) {
/* Some devices don't like to receive set_parameters() call while they
* are in write(), even if it seems the mutexes are correctly in place.
* Standby is another synchronization point which seems to work better. */
slave->output->stream->common.standby(&slave->output->stream->common);
}
pa_log_debug("slave output stream %p set_parameters(%s)", (void *) slave, parameters);
ret = slave->output->stream->common.set_parameters(&slave->output->stream->common, parameters);
@ -2212,6 +2221,17 @@ bool pa_droid_hw_set_mode(pa_droid_hw_module *hw_module, audio_mode_t mode) {
pa_log_info("Set mode to %s.", audio_mode_to_string(mode));
if (pa_droid_quirk(hw_module, QUIRK_SPEAKER_BEFORE_VOICE) &&
hw_module->state.mode != mode && mode == AUDIO_MODE_IN_CALL) {
pa_droid_stream *primary_output;
/* Set route to speaker before changing audio mode to AUDIO_MODE_IN_CALL.
* Some devices don't get routing right if the route is something else
* (like AUDIO_DEVICE_OUT_WIRED_HEADSET) before calling set_mode().*/
if ((primary_output = pa_droid_hw_primary_output_stream(hw_module)))
pa_droid_stream_set_route(primary_output, AUDIO_DEVICE_OUT_SPEAKER);
}
pa_droid_hw_module_lock(hw_module);
if (hw_module->device->set_mode(hw_module->device, mode) < 0) {
ret = false;

View file

@ -80,6 +80,8 @@ enum pa_droid_quirk_type {
QUIRK_OUTPUT_FAST,
QUIRK_OUTPUT_DEEP_BUFFER,
QUIRK_AUDIO_CAL_WAIT,
QUIRK_STANDBY_SET_ROUTE,
QUIRK_SPEAKER_BEFORE_VOICE,
QUIRK_COUNT
};