Skip to content

Commit bdda522

Browse files
Yu-HsuanChromeos LUCI
Yu-Hsuan
authored and
Chromeos LUCI
committed
CRAS: Initialize poll_fd in open_dev
configure_dev is not called in update_max_supported_channels. It will make aio->poll_fd not be initialized and send wrong msg to the audio thread when closing a device. Initialize poll_fd in open_dev and fix this issue. BUG=b:329545142 TEST=Plug audio device and check whether there is msg_id:10 in the audio thread log. Change-Id: Iace20b09869001d27a26d7c9fec605fb46a48bdf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5539096 Reviewed-by: Hsinyu Chao <[email protected]> Tested-by: Yu-Hsuan Hsu <[email protected]> Commit-Queue: Yu-Hsuan Hsu <[email protected]> Tested-by: [email protected] <[email protected]> Reviewed-by: Curtis Malainey <[email protected]>
1 parent f466040 commit bdda522

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

cras/src/server/cras_alsa_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ static int open_dev(struct cras_iodev* iodev) {
255255
struct alsa_io* aio = (struct alsa_io*)iodev;
256256
const char* pcm_name = NULL;
257257

258+
aio->common.poll_fd = -1;
258259
/* For DependentPCM usage in HiFi.conf only.
259260
* Normally the pcm name should come from the alsa_io device, not from nodes.
260261
*/
@@ -343,7 +344,6 @@ static int configure_dev(struct cras_iodev* iodev) {
343344
// Initialize device settings.
344345
init_device_settings(aio);
345346

346-
aio->common.poll_fd = -1;
347347
if (iodev->active_node->type == CRAS_NODE_TYPE_HOTWORD) {
348348
struct pollfd* ufds;
349349
int count, i;

cras/src/server/cras_alsa_usb_io.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static int usb_open_dev(struct cras_iodev* iodev) {
117117
(struct alsa_common_node*)aio->common.base.active_node;
118118
const char* pcm_name = anode->pcm_name;
119119

120+
aio->common.poll_fd = -1;
120121
audio_peripheral_info(aio->common.vendor_id, aio->common.product_id,
121122
CRAS_NODE_TYPE_USB);
122123

@@ -178,8 +179,6 @@ static int usb_configure_dev(struct cras_iodev* iodev) {
178179
// Initialize device settings.
179180
usb_init_device_settings(aio);
180181

181-
aio->common.poll_fd = -1;
182-
183182
// Capture starts right away, playback will wait for samples.
184183
if (aio->common.alsa_stream == SND_PCM_STREAM_CAPTURE) {
185184
rc = cras_alsa_pcm_start(aio->common.handle);

0 commit comments

Comments
 (0)