CRAS: iodev_list - Use fallback iodev at open iodev failure

When an iodev fails to open, an error is returned immediately by
current implementation.  That makes the new connected stream
an orphan because it doesn't attach to any iodev. If it happens
on a video app, video will hang because it needs to align with audio.

For better user experience, this error case can be handled by
enabling fallback device and move streams to it. After the change
user will just hear nothing instead of seeing blocked video if audio
device fails to open.  It's also a better hint for user to guess this
is more an audio issue and not related to video.

BUG=chromium:666405
TEST=Unittest.
Use hack patch to make a2dp iodev always fail to open and test:
1. select a2dp as output, play YouTube and see video doesn't hang.
Select audio output to/from internal speaker to verify audio routes
correctly and video playback is smooth.
2. select internal speaker as output, and play YouTUbe. From
system tray select output node to a2dp to verify video plays
smoothly. Switch output node back to speaker, verify audio plays
and aligned to video.

Change-Id: I12cf3000b79ed4fc93984c206335657912990518
Reviewed-on: https://chromium-review.googlesource.com/413790
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2 files changed