summaryrefslogtreecommitdiff
path: root/cras/src/server/cras_iodev_list.c
diff options
context:
space:
mode:
authorPin-chih Lin <johnylin@google.com>2020-09-22 17:23:39 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-26 05:33:16 +0000
commit4fa13010bf930872cce05bced26273c1430f8519 (patch)
tree37c0522543bec5e2ffa9c6df72e490a50befb95b /cras/src/server/cras_iodev_list.c
parent49bdcc555a4ede3c93b75d6cafa1db04be28ddb2 (diff)
downloadadhd-4fa13010bf930872cce05bced26273c1430f8519.tar.gz
CRAS: check max_supported_channels before re-opening iodev
crrev.com/c/2319443 introduced iodev re-opening for higher channel capability requested by new stream. However, it became a burden in the case of Bluetooth HFP mode. HFP iodev only supports mono channel format, but unfortunately usually new added streams from client may be stereo. Such cases always trigger iodev re-opening redundantly and might cause more crashes. To fix this issue, max_supported_channels of iodev should be the additional condition to check whether higher channel count could be obtained by iodev re-opening. BUG=b:165134431 TEST=On Stadia gameplay, it will first provide two 2-channel streams then a 6-channel stream. Check num_channels in device stat is 6 (for a 5.1 sound system) and all 6 channels have sounds. TEST=FEATURES="test" emerge adhd Change-Id: I3086227d14c0079ec3d0c45c5b21a6ac6d2b922f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2423763 Tested-by: Pin-chih Lin <johnylin@chromium.org> Auto-Submit: Pin-chih Lin <johnylin@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
Diffstat (limited to 'cras/src/server/cras_iodev_list.c')
-rw-r--r--cras/src/server/cras_iodev_list.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cras/src/server/cras_iodev_list.c b/cras/src/server/cras_iodev_list.c
index db50d660..866144f0 100644
--- a/cras/src/server/cras_iodev_list.c
+++ b/cras/src/server/cras_iodev_list.c
@@ -833,11 +833,15 @@ static int stream_added_cb(struct cras_rstream *rstream)
if (cras_iodev_is_open(edev->dev) &&
(rstream->format.num_channels >
- edev->dev->format->num_channels)) {
+ edev->dev->format->num_channels) &&
+ (rstream->format.num_channels <=
+ edev->dev->info.max_supported_channels)) {
/* Re-open the device with the format of the attached
* stream if it has higher channel count than the
- * current format of the device. Fallback device will
- * be transciently enabled during the device re-opening.
+ * current format of the device, and doesn't exceed the
+ * max_supported_channels of the device.
+ * Fallback device will be transciently enabled during
+ * the device re-opening.
*/
MAINLOG(main_log, MAIN_THREAD_DEV_REOPEN,
rstream->format.num_channels,