usb_audio: Yet more code cleanup.
Slight logic tweaks but no real behavioral changes intended.
This commit is contained in:
@@ -694,9 +694,10 @@ Device::_MultiBufferExchange(multi_buffer_info* multiInfo)
|
|||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fStreams.Count(); i++)
|
for (int i = 0; i < fStreams.Count(); i++) {
|
||||||
if (!fStreams[i]->IsRunning())
|
if (!fStreams[i]->IsRunning())
|
||||||
fStreams[i]->Start();
|
fStreams[i]->Start();
|
||||||
|
}
|
||||||
|
|
||||||
status_t status = acquire_sem_etc(fBuffersReadySem, 1,
|
status_t status = acquire_sem_etc(fBuffersReadySem, 1,
|
||||||
B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000);
|
B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000);
|
||||||
@@ -706,11 +707,12 @@ Device::_MultiBufferExchange(multi_buffer_info* multiInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
for (int i = 0; i < fStreams.Count(); i++)
|
for (int i = 0; i < fStreams.Count(); i++) {
|
||||||
if (fStreams[i]->ExchangeBuffer(&Info)) {
|
if (fStreams[i]->ExchangeBuffer(&Info)) {
|
||||||
status = B_OK;
|
status = B_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
TRACE(ERR, "Error processing buffers:%08x.\n", status);
|
TRACE(ERR, "Error processing buffers:%08x.\n", status);
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ Stream::Stream(Device* device, size_t interface, usb_interface_list* List)
|
|||||||
fDescriptors(NULL),
|
fDescriptors(NULL),
|
||||||
fDescriptorsCount(0),
|
fDescriptorsCount(0),
|
||||||
fCurrentBuffer(0),
|
fCurrentBuffer(0),
|
||||||
fStartingFrame(0),
|
|
||||||
fSamplesCount(0),
|
fSamplesCount(0),
|
||||||
|
fStartingFrame(0),
|
||||||
fPacketSize(0),
|
fPacketSize(0),
|
||||||
fProcessedBuffers(0),
|
fProcessedBuffers(0),
|
||||||
fInsideNotify(0)
|
fInsideNotify(0)
|
||||||
@@ -146,7 +146,7 @@ Stream::OnRemove()
|
|||||||
// not inside the callback anymore before returning, as we would otherwise
|
// not inside the callback anymore before returning, as we would otherwise
|
||||||
// violate the promise not to use any of the pipes after returning from the
|
// violate the promise not to use any of the pipes after returning from the
|
||||||
// removed callback
|
// removed callback
|
||||||
while (atomic_add(&fInsideNotify, 0) != 0)
|
while (atomic_get(&fInsideNotify) != 0)
|
||||||
snooze(100);
|
snooze(100);
|
||||||
|
|
||||||
gUSBModule->cancel_queued_transfers(fStreamEndpoint);
|
gUSBModule->cancel_queued_transfers(fStreamEndpoint);
|
||||||
@@ -285,7 +285,7 @@ Stream::Stop()
|
|||||||
{
|
{
|
||||||
if (fIsRunning) {
|
if (fIsRunning) {
|
||||||
// wait until possible notification handling finished...
|
// wait until possible notification handling finished...
|
||||||
while (atomic_add(&fInsideNotify, 0) != 0)
|
while (atomic_get(&fInsideNotify) != 0)
|
||||||
snooze(100);
|
snooze(100);
|
||||||
fIsRunning = false;
|
fIsRunning = false;
|
||||||
}
|
}
|
||||||
@@ -328,9 +328,9 @@ Stream::_TransferCallback(void* cookie, status_t status, void* data,
|
|||||||
Stream* stream = (Stream*)cookie;
|
Stream* stream = (Stream*)cookie;
|
||||||
atomic_add(&stream->fInsideNotify, 1);
|
atomic_add(&stream->fInsideNotify, 1);
|
||||||
if (status == B_CANCELED || stream->fDevice->fRemoved || !stream->fIsRunning) {
|
if (status == B_CANCELED || stream->fDevice->fRemoved || !stream->fIsRunning) {
|
||||||
atomic_add(&stream->fInsideNotify, -1);
|
|
||||||
TRACE(ERR, "Cancelled: c:%p st:%#010x, data:%#010x, len:%d\n",
|
TRACE(ERR, "Cancelled: c:%p st:%#010x, data:%#010x, len:%d\n",
|
||||||
cookie, status, data, actualLength);
|
cookie, status, data, actualLength);
|
||||||
|
atomic_add(&stream->fInsideNotify, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,10 +354,7 @@ Stream::_TransferCallback(void* cookie, status_t status, void* data,
|
|||||||
void
|
void
|
||||||
Stream::_DumpDescriptors()
|
Stream::_DumpDescriptors()
|
||||||
{
|
{
|
||||||
//size_t packetsCount = fDescriptorsCount / kSamplesBufferCount;
|
for (size_t i = 0; i < fDescriptorsCount; i++)
|
||||||
size_t from = /*fCurrentBuffer > 0 ? packetsCount :*/ 0 ;
|
|
||||||
size_t to = /*fCurrentBuffer > 0 ?*/ fDescriptorsCount /*: packetsCount*/ ;
|
|
||||||
for (size_t i = from; i < to; i++)
|
|
||||||
TRACE(ISO, "%d:req_len:%d; act_len:%d; stat:%#010x\n", i,
|
TRACE(ISO, "%d:req_len:%d; act_len:%d; stat:%#010x\n", i,
|
||||||
fDescriptors[i].request_length, fDescriptors[i].actual_length,
|
fDescriptors[i].request_length, fDescriptors[i].actual_length,
|
||||||
fDescriptors[i].status);
|
fDescriptors[i].status);
|
||||||
@@ -489,8 +486,6 @@ Stream::GetBuffers(multi_buffer_list* List)
|
|||||||
|
|
||||||
TypeIFormatDescriptor* format = static_cast<TypeIFormatDescriptor*>(
|
TypeIFormatDescriptor* format = static_cast<TypeIFormatDescriptor*>(
|
||||||
fAlternates[fActiveAlternate]->Format());
|
fAlternates[fActiveAlternate]->Format());
|
||||||
// const ASEndpointDescriptor* endpoint
|
|
||||||
// = fAlternates[fActiveAlternate]->Endpoint();
|
|
||||||
|
|
||||||
// [buffer][channel] init buffers
|
// [buffer][channel] init buffers
|
||||||
for (size_t buffer = 0; buffer < kSamplesBufferCount; buffer++) {
|
for (size_t buffer = 0; buffer < kSamplesBufferCount; buffer++) {
|
||||||
@@ -538,7 +533,7 @@ Stream::GetBuffers(multi_buffer_list* List)
|
|||||||
bool
|
bool
|
||||||
Stream::ExchangeBuffer(multi_buffer_info* Info)
|
Stream::ExchangeBuffer(multi_buffer_info* Info)
|
||||||
{
|
{
|
||||||
if (fProcessedBuffers <= 0)
|
if (atomic_get(&fProcessedBuffers) <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (fIsInput) {
|
if (fIsInput) {
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ public:
|
|||||||
status_t SetGlobalFormat(multi_format_info* Format);
|
status_t SetGlobalFormat(multi_format_info* Format);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Device* fDevice;
|
Device* fDevice;
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
|
|
||||||
uint8 fTerminalID;
|
uint8 fTerminalID;
|
||||||
usb_pipe fStreamEndpoint;
|
usb_pipe fStreamEndpoint;
|
||||||
|
|
||||||
bool fIsRunning;
|
bool fIsRunning;
|
||||||
area_id fArea, fKernelArea;
|
area_id fArea, fKernelArea;
|
||||||
size_t fAreaSize;
|
size_t fAreaSize;
|
||||||
@@ -56,9 +56,10 @@ protected:
|
|||||||
uint8* fBuffers;
|
uint8* fBuffers;
|
||||||
uint8* fKernelBuffers;
|
uint8* fKernelBuffers;
|
||||||
size_t fCurrentBuffer;
|
size_t fCurrentBuffer;
|
||||||
uint32 fStartingFrame;
|
|
||||||
size_t fSamplesCount;
|
size_t fSamplesCount;
|
||||||
|
|
||||||
size_t fPacketSize;
|
size_t fPacketSize;
|
||||||
|
uint32 fStartingFrame;
|
||||||
int32 fProcessedBuffers;
|
int32 fProcessedBuffers;
|
||||||
int32 fInsideNotify;
|
int32 fInsideNotify;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user