summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2024-04-09 17:23:31 +0700
committerGitHub <[email protected]>2024-04-09 17:23:31 +0700
commit1195fa8ee36f704704a003a386fc47c2a9204474 (patch)
tree0ee11e7f0191f3d501588353d3624da417b3f4f0 /src
parent42decf28f1bf7512a4c3e7402c9daf83ee241191 (diff)
parentb0568e32a5d3ad427d296e0d3bcb1020d54d25a3 (diff)
Merge pull request #2579 from HiFiPhile/uvc_race
Fix tud_video_n_streaming check
Diffstat (limited to 'src')
-rw-r--r--src/class/video/video_device.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/class/video/video_device.c b/src/class/video/video_device.c
index d0a88eb17..4218835aa 100644
--- a/src/class/video/video_device.c
+++ b/src/class/video/video_device.c
@@ -763,8 +763,8 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
tusb_desc_endpoint_t const *ep = (tusb_desc_endpoint_t const*)(desc + ofs_ep);
/* Only ISO endpoints needs to be closed */
if(ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
- usbd_edpt_close(rhport, ep->bEndpointAddress);
stm->desc.ep[i] = 0;
+ usbd_edpt_close(rhport, ep->bEndpointAddress);
TU_LOG_DRV(" close EP%02x\r\n", ep->bEndpointAddress);
}
}
@@ -1186,6 +1186,16 @@ bool tud_video_n_streaming(uint_fast8_t ctl_idx, uint_fast8_t stm_idx)
videod_streaming_interface_t *stm = _get_instance_streaming(ctl_idx, stm_idx);
if (!stm || !stm->desc.ep[0]) return false;
if (stm->state == VS_STATE_PROBING) return false;
+
+#ifdef TUP_DCD_EDPT_ISO_ALLOC
+ uint8_t const *desc = _videod_itf[stm->index_vc].beg;
+ uint_fast16_t ofs_ep = stm->desc.ep[0];
+ tusb_desc_endpoint_t const *ep = (tusb_desc_endpoint_t const*)(desc + ofs_ep);
+ if (ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
+ if (stm->state == VS_STATE_COMMITTED) return false;
+ }
+#endif
+
return true;
}