usb_audio: Stop before reallocating buffers and add more error checks.

Also print strerror() for SetGlobalFormat.
This commit is contained in:
Augustin Cavalier
2019-07-14 16:31:02 -04:00
parent 553ff67585
commit d5aa7f00a2
2 changed files with 9 additions and 4 deletions
@@ -832,7 +832,10 @@ Device::_SetupEndpoints()
if (fAudioControl.InitCheck() == B_OK && fStreams.Count() > 0) {
TRACE(INF, "Found device %#06x:%#06x\n", fVendorID, fProductID);
gUSBModule->set_configuration(fDevice, config);
status_t status = gUSBModule->set_configuration(fDevice, config);
if (status != B_OK)
return status;
for (int i = 0; i < fStreams.Count(); i++)
fStreams[i]->OnSetConfiguration(fDevice, config);
@@ -170,8 +170,10 @@ Stream::_SetupBuffers()
return B_BAD_VALUE;
}
if (fArea != -1)
if (fArea != -1) {
Stop();
delete_area(fArea);
}
fAreaSize = (sizeof(usb_iso_packet_descriptor) + fPacketSize)
* sampleSize * 1024 / fPacketSize;
@@ -441,9 +443,9 @@ Stream::SetGlobalFormat(multi_format_info* Format)
USB_AUDIO_SET_CUR, USB_AUDIO_SAMPLING_FREQ_CONTROL << 8,
address, sizeof(freq), &freq, &actualLength);
TRACE(ERR, "set_speed %02x%02x%02x for ep %#x %d: %x\n",
TRACE(ERR, "set_speed %02x%02x%02x for ep %#x %d: %s\n",
freq.bytes[0], freq.bytes[1], freq.bytes[2],
address, actualLength, status);
address, actualLength, strerror(status));
return status;
}