CRAS: Deduplicate snd_pcm_open calls when opening a device.
The current open device flow includes several functions like
cras_alsa_fill_properties and update_channel_layout. They are used only
once in the flow but each calls snd_pcm_open and then snd_pcm_close the
device. Since snd_pcm_open is one of the most time-consuming hardware
operations, the CL extracts the snd_pcm_open calls to the beginning of
the device open flow to save time.
1. Update cras_alsa_fill_properties and update_channel_layout to take a
handle as argument and do not invoke snd_pcm_open.
2. Rename existing open_dev functions to configure_dev. open_dev is now
called at the beginning of the device open flow and invokes the
snd_pcm_open call.
3. Put open_dev, cras_iodev_set_format, and configure_dev inside the
cras_iodev_open function.
BUG=b:719812
TEST=make check and tested on reef
Cuts time to open speakers from 78ms to 42ms
Change-Id: I9b161217def5e87bf892f4ca8148f07bed5e71a5
Reviewed-on: https://chromium-review.googlesource.com/505974
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
21 files changed