Skip to content

Commit 1195fa8

Browse files
authored
Merge pull request #2579 from HiFiPhile/uvc_race
Fix tud_video_n_streaming check
2 parents 42decf2 + b0568e3 commit 1195fa8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/class/video/video_device.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,8 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
763763
tusb_desc_endpoint_t const *ep = (tusb_desc_endpoint_t const*)(desc + ofs_ep);
764764
/* Only ISO endpoints needs to be closed */
765765
if(ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
766-
usbd_edpt_close(rhport, ep->bEndpointAddress);
767766
stm->desc.ep[i] = 0;
767+
usbd_edpt_close(rhport, ep->bEndpointAddress);
768768
TU_LOG_DRV(" close EP%02x\r\n", ep->bEndpointAddress);
769769
}
770770
}
@@ -1186,6 +1186,16 @@ bool tud_video_n_streaming(uint_fast8_t ctl_idx, uint_fast8_t stm_idx)
11861186
videod_streaming_interface_t *stm = _get_instance_streaming(ctl_idx, stm_idx);
11871187
if (!stm || !stm->desc.ep[0]) return false;
11881188
if (stm->state == VS_STATE_PROBING) return false;
1189+
1190+
#ifdef TUP_DCD_EDPT_ISO_ALLOC
1191+
uint8_t const *desc = _videod_itf[stm->index_vc].beg;
1192+
uint_fast16_t ofs_ep = stm->desc.ep[0];
1193+
tusb_desc_endpoint_t const *ep = (tusb_desc_endpoint_t const*)(desc + ofs_ep);
1194+
if (ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
1195+
if (stm->state == VS_STATE_COMMITTED) return false;
1196+
}
1197+
#endif
1198+
11891199
return true;
11901200
}
11911201

0 commit comments

Comments
 (0)