forked from PAWPAW-Mirror/lib_xua
BUG 11356: Keep iAP messages together by sending length before data
This commit is contained in:
@@ -675,6 +675,8 @@ void decouple(chanend c_mix_out,
|
||||
int iap_waiting_on_send_to_host = 0;
|
||||
int iap_to_host_flag = 0;
|
||||
int iap_from_host_flag = 0;
|
||||
int iap_expecting_length = 1;
|
||||
int iap_expecting_data_length = 0;
|
||||
#endif
|
||||
|
||||
int t = array_to_xc_ptr(outAudioBuff);
|
||||
@@ -1168,6 +1170,7 @@ void decouple(chanend c_mix_out,
|
||||
if (iap_reset) {
|
||||
iap_send_reset(c_iap); // What if this happen in the middle of a send/ack?
|
||||
iap_reset = 0;
|
||||
iap_expecting_length = 1;
|
||||
SET_SHARED_GLOBAL(g_iap_reset, iap_reset); // Reset has been signalled
|
||||
}
|
||||
// Need to handle sending ZLP on iap_to_host_usb_ep_int to signal iOS device to collect from bulk endpoint.
|
||||
@@ -1256,6 +1259,10 @@ void decouple(chanend c_mix_out,
|
||||
{
|
||||
/* The iap/uart thread has sent us some data - handshake back */
|
||||
iap_send_ack(c_iap);
|
||||
if (iap_expecting_length) {
|
||||
iap_expecting_data_length = datum_iap;
|
||||
iap_expecting_length = 0;
|
||||
} else {
|
||||
if (iap_data_collected_from_device < IAP_USB_BUFFER_TO_HOST_SIZE)
|
||||
{
|
||||
/* There is room in the collecting buffer for the data */
|
||||
@@ -1269,8 +1276,8 @@ void decouple(chanend c_mix_out,
|
||||
// Too many events from device - drop
|
||||
}
|
||||
|
||||
// If we are not sending data to the host then initiate it
|
||||
if (!iap_waiting_on_send_to_host)
|
||||
// If we are not sending data to the host then initiate it (ONLY IF GOT WHOLE MESSAGE)
|
||||
if (!iap_waiting_on_send_to_host && (iap_data_collected_from_device == iap_expecting_data_length))
|
||||
{
|
||||
// Set first element of buffer to length i.e. iap_to_host_buffer_being_collected[0] = iap_data_collected_from_device;
|
||||
write_via_xc_ptr(iap_to_host_buffer_being_collected, iap_data_collected_from_device);
|
||||
@@ -1282,6 +1289,8 @@ void decouple(chanend c_mix_out,
|
||||
XUD_SetReady_In(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device);
|
||||
iap_data_collected_from_device = 0;
|
||||
iap_waiting_on_send_to_host = 1;
|
||||
iap_expecting_length = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user