Skip to content

Commit

Permalink
Merge pull request #2579 from HiFiPhile/uvc_race
Browse files Browse the repository at this point in the history
Fix tud_video_n_streaming check
  • Loading branch information
hathach authored Apr 9, 2024
2 parents 42decf2 + b0568e3 commit 1195fa8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/class/video/video_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 1195fa8

Please sign in to comment.