USB audio: Refactor TRACE-es for more configurability

This commit is contained in:
Siarzhuk Zharski 2013-06-27 21:22:54 +02:00
parent 1a6d941d1d
commit 7ff9cd33a9
8 changed files with 288 additions and 259 deletions

View File

@ -244,7 +244,7 @@ GetTerminalDescription(uint16 TerminalType)
case Instrument_IO: return "Musical Instrument";
} */
TRACE_ALWAYS("Unknown Terminal Type: %#06x", TerminalType);
TRACE(ERR, "Unknown Terminal Type: %#06x", TerminalType);
return "Unknown";
}
@ -355,10 +355,10 @@ InputTerminal::InputTerminal(AudioControlInterface* interface,
fTerminalType = Terminal->terminal_type;
fAssociatedTerminal = Terminal->assoc_terminal;
TRACE("Input Terminal ID:%d >>>\n", fID);
TRACE("Terminal type:%s (%#06x)\n",
TRACE(UAC, "Input Terminal ID:%d >>>\n", fID);
TRACE(UAC, "Terminal type:%s (%#06x)\n",
GetTerminalDescription(fTerminalType), fTerminalType);
TRACE("Assoc.terminal:%d\n", fAssociatedTerminal);
TRACE(UAC, "Assoc.terminal:%d\n", fAssociatedTerminal);
if (fInterface->SpecReleaseNumber() < 0x200) {
fOutChannelsNumber = Terminal->r1.num_channels;
@ -373,14 +373,14 @@ InputTerminal::InputTerminal(AudioControlInterface* interface,
fControlsBitmap = Terminal->r2.bm_controls;
fStringIndex = Terminal->r2.terminal;
TRACE("Clock Source ID:%d\n", fClockSourceId);
TRACE("Controls Bitmap:%#04x\n", fControlsBitmap);
TRACE(UAC, "Clock Source ID:%d\n", fClockSourceId);
TRACE(UAC, "Controls Bitmap:%#04x\n", fControlsBitmap);
}
TRACE("Out.channels num:%d\n", fOutChannelsNumber);
TRACE("Channels config:%#06x\n", fChannelsConfig);
TRACE("Channels names:%d\n", fChannelNames);
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "Out.channels num:%d\n", fOutChannelsNumber);
TRACE(UAC, "Channels config:%#06x\n", fChannelsConfig);
TRACE(UAC, "Channels names:%d\n", fChannelNames);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
fStatus = B_OK;
}
@ -404,11 +404,11 @@ OutputTerminal::OutputTerminal(AudioControlInterface* interface,
fAssociatedTerminal = Terminal->assoc_terminal;
fSourceID = Terminal->source_id;
TRACE("Output Terminal ID:%d >>>\n", fID);
TRACE("Terminal type:%s (%#06x)\n",
TRACE(UAC, "Output Terminal ID:%d >>>\n", fID);
TRACE(UAC, "Terminal type:%s (%#06x)\n",
GetTerminalDescription(fTerminalType), fTerminalType);
TRACE("Assoc.terminal:%d\n", fAssociatedTerminal);
TRACE("Source ID:%d\n", fSourceID);
TRACE(UAC, "Assoc.terminal:%d\n", fAssociatedTerminal);
TRACE(UAC, "Source ID:%d\n", fSourceID);
if (fInterface->SpecReleaseNumber() < 0x200) {
fStringIndex = Terminal->r1.terminal;
@ -417,11 +417,11 @@ OutputTerminal::OutputTerminal(AudioControlInterface* interface,
fControlsBitmap = Terminal->r2.bm_controls;
fStringIndex = Terminal->r2.terminal;
TRACE("Clock Source ID:%d\n", fClockSourceId);
TRACE("Controls Bitmap:%#04x\n", fControlsBitmap);
TRACE(UAC, "Clock Source ID:%d\n", fClockSourceId);
TRACE(UAC, "Controls Bitmap:%#04x\n", fControlsBitmap);
}
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
fStatus = B_OK;
}
@ -442,12 +442,12 @@ MixerUnit::MixerUnit(AudioControlInterface* interface,
= (usb_audio_mixer_unit_descriptor*) Header;
fID = Mixer->unit_id;
TRACE("Mixer ID:%d >>>\n", fID);
TRACE(UAC, "Mixer ID:%d >>>\n", fID);
TRACE("Number of input pins:%d\n", Mixer->num_input_pins);
TRACE(UAC, "Number of input pins:%d\n", Mixer->num_input_pins);
for (size_t i = 0; i < Mixer->num_input_pins; i++) {
fInputPins.PushBack(Mixer->input_pins[i]);
TRACE("Input pin #%d:%d\n", i, fInputPins[i]);
TRACE(UAC, "Input pin #%d:%d\n", i, fInputPins[i]);
}
uint8* mixerControlsData = NULL;
@ -479,20 +479,20 @@ MixerUnit::MixerUnit(AudioControlInterface* interface,
fControlsBitmap = *(mixerControlsData + mixerControlsSize);
fStringIndex = *(mixerControlsData + mixerControlsSize + 1);
TRACE("Control Bitmap:%#04x\n", fControlsBitmap);
TRACE(UAC, "Control Bitmap:%#04x\n", fControlsBitmap);
}
TRACE("Out channels number:%d\n", fOutChannelsNumber);
TRACE("Out channels config:%#06x\n", fChannelsConfig);
TRACE("Out channels names:%d\n", fChannelNames);
TRACE("Controls Size:%d\n", mixerControlsSize);
TRACE(UAC, "Out channels number:%d\n", fOutChannelsNumber);
TRACE(UAC, "Out channels config:%#06x\n", fChannelsConfig);
TRACE(UAC, "Out channels names:%d\n", fChannelNames);
TRACE(UAC, "Controls Size:%d\n", mixerControlsSize);
for (size_t i = 0; i < mixerControlsSize; i++) {
fProgrammableControls.PushBack(mixerControlsData[i]);
TRACE("Controls Data[%d]:%#x\n", i, fProgrammableControls[i]);
TRACE(UAC, "Controls Data[%d]:%#x\n", i, fProgrammableControls[i]);
}
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
fStatus = B_OK;
}
@ -513,12 +513,12 @@ SelectorUnit::SelectorUnit(AudioControlInterface* interface,
= (usb_audio_selector_unit_descriptor*) Header;
fID = Selector->unit_id;
TRACE("Selector ID:%d >>>\n", fID);
TRACE(UAC, "Selector ID:%d >>>\n", fID);
TRACE("Number of input pins:%d\n", Selector->num_input_pins);
TRACE(UAC, "Number of input pins:%d\n", Selector->num_input_pins);
for (size_t i = 0; i < Selector->num_input_pins; i++) {
fInputPins.PushBack(Selector->input_pins[i]);
TRACE("Input pin #%d:%d\n", i, fInputPins[i]);
TRACE(UAC, "Input pin #%d:%d\n", i, fInputPins[i]);
}
if (fInterface->SpecReleaseNumber() < 0x200) {
@ -527,10 +527,10 @@ SelectorUnit::SelectorUnit(AudioControlInterface* interface,
fControlsBitmap = Selector->input_pins[Selector->num_input_pins];
fStringIndex = Selector->input_pins[Selector->num_input_pins + 1];
TRACE("Controls Bitmap:%d\n", fControlsBitmap);
TRACE(UAC, "Controls Bitmap:%d\n", fControlsBitmap);
}
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
fStatus = B_OK;
}
@ -569,10 +569,10 @@ FeatureUnit::FeatureUnit(AudioControlInterface* interface,
= (usb_audio_feature_unit_descriptor*) Header;
fID = Feature->unit_id;
TRACE("Feature ID:%d >>>\n", fID);
TRACE(UAC, "Feature ID:%d >>>\n", fID);
fSourceID = Feature->source_id;
TRACE("Source ID:%d\n", fSourceID);
TRACE(UAC, "Source ID:%d\n", fSourceID);
uint8 controlSize = 4;
uint8 channelsCount = (Feature->length - 6) / controlSize;
@ -584,8 +584,8 @@ FeatureUnit::FeatureUnit(AudioControlInterface* interface,
ControlsBitmapPointer = &Feature->r1.bma_controls[0];
}
TRACE("Channel bitmap size:%d\n", controlSize);
TRACE("Channels number:%d\n", channelsCount - 1); // not add master!
TRACE(UAC, "Channel bitmap size:%d\n", controlSize);
TRACE(UAC, "Channels number:%d\n", channelsCount - 1); // not add master!
for (size_t i = 0; i < channelsCount; i++) {
uint8* controlPointer = &ControlsBitmapPointer[i* controlSize];
@ -594,7 +594,7 @@ FeatureUnit::FeatureUnit(AudioControlInterface* interface,
case 2: fControlBitmaps.PushBack(*(uint16*)controlPointer); break;
case 4: fControlBitmaps.PushBack(*(uint32*)controlPointer); break;
default:
TRACE_ALWAYS("Feature control of unsupported size %d ignored\n",
TRACE(ERR, "Feature control of unsupported size %d ignored\n",
controlSize);
continue;
}
@ -603,7 +603,7 @@ FeatureUnit::FeatureUnit(AudioControlInterface* interface,
}
fStringIndex = ControlsBitmapPointer[channelsCount* controlSize];
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
fStatus = B_OK;
}
@ -653,7 +653,7 @@ bool
FeatureUnit::HasControl(int32 Channel, uint32 Control)
{
if (Channel >= fControlBitmaps.Count()) {
TRACE_ALWAYS("Out of limits error of retrieving control %#010x "
TRACE(ERR, "Out of limits error of retrieving control %#010x "
"for channel %d\n", Control, Channel);
return false;
}
@ -666,7 +666,7 @@ void
FeatureUnit::NormalizeAndTraceChannel(int32 Channel)
{
if (Channel >= fControlBitmaps.Count()) {
TRACE_ALWAYS("Out of limits error of tracing channel %d\n", Channel);
TRACE(ERR, "Out of limits error of tracing channel %d\n", Channel);
return;
}
@ -693,9 +693,9 @@ FeatureUnit::NormalizeAndTraceChannel(int32 Channel)
};
if (Channel == 0)
TRACE("Master channel bitmap:%#x\n", fControlBitmaps[Channel]);
TRACE(UAC, "Master channel bitmap:%#x\n", fControlBitmaps[Channel]);
else
TRACE("Channel %d bitmap:%#x\n", Channel, fControlBitmaps[Channel]);
TRACE(UAC, "Channel %d bitmap:%#x\n", Channel, fControlBitmaps[Channel]);
bool isRev1 = (fInterface->SpecReleaseNumber() < 0x200);
@ -705,12 +705,13 @@ FeatureUnit::NormalizeAndTraceChannel(int32 Channel)
if ((fControlBitmaps[Channel] & bits) > 0) {
if (isRev1)
remappedBitmap |= remapInfos[i].rev2Bits;
TRACE("\t%s\n", remapInfos[i].name);
TRACE(UAC, "\t%s\n", remapInfos[i].name);
}
}
if (isRev1) {
TRACE("\t%#08x -> %#08x.\n", fControlBitmaps[Channel], remappedBitmap);
TRACE(UAC, "\t%#08x -> %#08x.\n",
fControlBitmaps[Channel], remappedBitmap);
fControlBitmaps[Channel] = remappedBitmap;
}
}
@ -723,7 +724,7 @@ EffectUnit::EffectUnit(AudioControlInterface* interface,
{
usb_audio_input_terminal_descriptor* D
= (usb_audio_input_terminal_descriptor*) Header;
TRACE("Effect Unit:%d >>>\n", D->terminal_id);
TRACE(UAC, "Effect Unit:%d >>>\n", D->terminal_id);
}
@ -743,15 +744,15 @@ ProcessingUnit::ProcessingUnit(AudioControlInterface* interface,
= (usb_audio_processing_unit_descriptor*) Header;
fID = Processing->unit_id;
TRACE("Processing ID:%d >>>\n", fID);
TRACE(UAC, "Processing ID:%d >>>\n", fID);
fProcessType = Processing->process_type;
TRACE("Processing Type:%d\n", fProcessType);
TRACE(UAC, "Processing Type:%d\n", fProcessType);
TRACE("Number of input pins:%d\n", Processing->num_input_pins);
TRACE(UAC, "Number of input pins:%d\n", Processing->num_input_pins);
for (size_t i = 0; i < Processing->num_input_pins; i++) {
fInputPins.PushBack(Processing->input_pins[i]);
TRACE("Input pin #%d:%d\n", i, fInputPins[i]);
TRACE(UAC, "Input pin #%d:%d\n", i, fInputPins[i]);
}
if (fInterface->SpecReleaseNumber() < 0x200) {
@ -772,23 +773,23 @@ ProcessingUnit::ProcessingUnit(AudioControlInterface* interface,
fChannelNames = OutChannels->channel_names;
}
TRACE("Out channels number:%d\n", fOutChannelsNumber);
TRACE("Out channels config:%#06x\n", fChannelsConfig);
TRACE("Out channels names:%d\n", fChannelNames);
TRACE(UAC, "Out channels number:%d\n", fOutChannelsNumber);
TRACE(UAC, "Out channels config:%#06x\n", fChannelsConfig);
TRACE(UAC, "Out channels names:%d\n", fChannelNames);
/*
uint8 controlsSize = Processing->length - 10 - Processing->num_input_pins;
TRACE("Controls Size:%d\n", controlsSize);
TRACE(UAC, "Controls Size:%d\n", controlsSize);
uint8* controlsData = (uint8*) ++OutChannels;
for (size_t i = 0; i < controlsSize; i++) {
fProgrammableControls.PushBack(controlsData[i]);
TRACE("Controls Data[%d]:%#x\n", i, controlsData[i]);
TRACE(UAC, "Controls Data[%d]:%#x\n", i, controlsData[i]);
}
fStringIndex = *(controlsData + controlsSize);
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
*/
fStatus = B_OK;
}
@ -810,15 +811,15 @@ ExtensionUnit::ExtensionUnit(AudioControlInterface* interface,
= (usb_audio_extension_unit_descriptor*) Header;
fID = Extension->unit_id;
TRACE("Extension ID:%d >>>\n", fID);
TRACE(UAC, "Extension ID:%d >>>\n", fID);
fExtensionCode = Extension->extension_code;
TRACE("Extension Type:%d\n", fExtensionCode);
TRACE(UAC, "Extension Type:%d\n", fExtensionCode);
TRACE("Number of input pins:%d\n", Extension->num_input_pins);
TRACE(UAC, "Number of input pins:%d\n", Extension->num_input_pins);
for (size_t i = 0; i < Extension->num_input_pins; i++) {
fInputPins.PushBack(Extension->input_pins[i]);
TRACE("Input pin #%d:%d\n", i, fInputPins[i]);
TRACE(UAC, "Input pin #%d:%d\n", i, fInputPins[i]);
}
if (fInterface->SpecReleaseNumber() < 0x200) {
@ -839,23 +840,23 @@ ExtensionUnit::ExtensionUnit(AudioControlInterface* interface,
fChannelNames = OutChannels->channel_names;
}
TRACE("Out channels number:%d\n", fOutChannelsNumber);
TRACE("Out channels config:%#06x\n", fChannelsConfig);
TRACE("Out channels names:%d\n", fChannelNames);
TRACE(UAC, "Out channels number:%d\n", fOutChannelsNumber);
TRACE(UAC, "Out channels config:%#06x\n", fChannelsConfig);
TRACE(UAC, "Out channels names:%d\n", fChannelNames);
/*
uint8 controlsSize = Processing->length - 10 - Processing->num_input_pins;
TRACE("Controls Size:%d\n", controlsSize);
TRACE(UAC, "Controls Size:%d\n", controlsSize);
uint8* controlsData = (uint8*) ++OutChannels;
for (size_t i = 0; i < controlsSize; i++) {
fProgrammableControls.PushBack(controlsData[i]);
TRACE("Controls Data[%d]:%#x\n", i, controlsData[i]);
TRACE(UAC, "Controls Data[%d]:%#x\n", i, controlsData[i]);
}
fStringIndex = *(controlsData + controlsSize);
TRACE("StringIndex:%d\n", fStringIndex);
TRACE(UAC, "StringIndex:%d\n", fStringIndex);
*/
fStatus = B_OK;
}
@ -871,9 +872,9 @@ ClockSource::ClockSource(AudioControlInterface* interface,
:
_AudioControl(interface, Header)
{
usb_audio_input_terminal_descriptor* D
usb_audio_input_terminal_descriptor* descriptor
= (usb_audio_input_terminal_descriptor*) Header;
TRACE("Clock Source:%d >>>\n", D->terminal_id);
TRACE(UAC, "Clock Source:%d >>>\n", descriptor->terminal_id);
}
@ -887,9 +888,9 @@ ClockSelector::ClockSelector(AudioControlInterface* interface,
:
_AudioControl(interface, Header)
{
usb_audio_input_terminal_descriptor* D
usb_audio_input_terminal_descriptor* descriptor
= (usb_audio_input_terminal_descriptor*) Header;
TRACE("Clock Selector:%d >>>\n", D->terminal_id);
TRACE(UAC, "Clock Selector:%d >>>\n", descriptor->terminal_id);
}
@ -903,9 +904,9 @@ ClockMultiplier::ClockMultiplier(AudioControlInterface* interface,
:
_AudioControl(interface, Header)
{
usb_audio_input_terminal_descriptor* D
usb_audio_input_terminal_descriptor* descriptor
= (usb_audio_input_terminal_descriptor*) Header;
TRACE("Clock Multiplier:%d >>>\n", D->terminal_id);
TRACE(UAC, "Clock Multiplier:%d >>>\n", descriptor->terminal_id);
}
@ -919,9 +920,9 @@ SampleRateConverter::SampleRateConverter(AudioControlInterface* interface,
:
_AudioControl(interface, Header)
{
usb_audio_input_terminal_descriptor* D
usb_audio_input_terminal_descriptor* descriptor
= (usb_audio_input_terminal_descriptor*) Header;
TRACE("Sample Rate Converter:%d >>>\n", D->terminal_id);
TRACE(UAC, "Sample Rate Converter:%d >>>\n", descriptor->terminal_id);
}
@ -966,7 +967,7 @@ AudioControlInterface::Init(size_t interface, usb_interface_info* Interface)
= (usb_audiocontrol_header_descriptor* )Interface->generic[i];
if (Header->descriptor_type != USB_AUDIO_CS_INTERFACE) {
TRACE_ALWAYS("Ignore Audio Control of "
TRACE(ERR, "Ignore Audio Control of "
"unknown descriptor type %#04x.\n", Header->descriptor_type);
continue;
}
@ -975,11 +976,11 @@ AudioControlInterface::Init(size_t interface, usb_interface_info* Interface)
switch(Header->descriptor_subtype) {
default:
TRACE_ALWAYS("Ignore Audio Control of unknown "
TRACE(ERR, "Ignore Audio Control of unknown "
"descriptor sub-type %#04x\n", Header->descriptor_subtype);
break;
case USB_AUDIO_AC_DESCRIPTOR_UNDEFINED:
TRACE_ALWAYS("Ignore Audio Control of undefined sub-type\n");
TRACE(ERR, "Ignore Audio Control of undefined sub-type\n");
break;
case USB_AUDIO_AC_HEADER:
InitACHeader(interface, Header);
@ -1071,19 +1072,19 @@ AudioControlInterface::InitACHeader(size_t interface,
fInterface = interface;
fADCSpecification = Header->bcd_release_no;
TRACE("ADCSpecification:%#06x\n", fADCSpecification);
TRACE(UAC, "ADCSpecification:%#06x\n", fADCSpecification);
if (fADCSpecification < 0x200) {
TRACE("InterfacesCount:%d\n", Header->r1.in_collection);
TRACE(UAC, "InterfacesCount:%d\n", Header->r1.in_collection);
for (size_t i = 0; i < Header->r1.in_collection; i++) {
fStreams.PushBack(Header->r1.interface_numbers[i]);
TRACE("Interface[%d] number is %d\n", i, fStreams[i]);
TRACE(UAC, "Interface[%d] number is %d\n", i, fStreams[i]);
}
} else {
fFunctionCategory = Header->r2.function_category;
fControlsBitmap = Header->r2.bm_controls;
TRACE("Function Category:%#04x\n", fFunctionCategory);
TRACE("Controls Bitmap:%#04x\n", fControlsBitmap);
TRACE(UAC, "Function Category:%#04x\n", fFunctionCategory);
TRACE(UAC, "Controls Bitmap:%#04x\n", fControlsBitmap);
}
return /*fStatus =*/ B_OK;
@ -1104,7 +1105,7 @@ AudioControlInterface::GetChannelsDescription(
AudioChannelCluster* cluster = Terminals[i]->OutCluster();
if (cluster == 0 || cluster->ChannelsCount() <= 0) {
TRACE_ALWAYS("Terminal #%d ignored due null "
TRACE(ERR, "Terminal #%d ignored due null "
"channels cluster (%08x)\n", Terminals[i]->ID(), cluster);
continue;
}
@ -1201,7 +1202,7 @@ AudioControlInterface::GetBusChannelsDescription(
AudioChannelCluster* cluster = control->OutCluster();
if (cluster == 0 || cluster->ChannelsCount() <= 0) {
TRACE_ALWAYS("Terminal #%d ignored due null "
TRACE(ERR, "Terminal #%d ignored due null "
"channels cluster (%08x)\n", control->ID(), cluster);
continue;
}
@ -1222,7 +1223,7 @@ AudioControlInterface::GetBusChannelsDescription(
AudioChannelCluster* cluster = control->OutCluster();
if (cluster == 0 || cluster->ChannelsCount() <= 0) {
TRACE_ALWAYS("Terminal #%d ignored due null "
TRACE(ERR, "Terminal #%d ignored due null "
"channels cluster (%08x)\n", control->ID(), cluster);
continue;
}
@ -1243,7 +1244,7 @@ AudioControlInterface::_HarvestRecordFeatureUnits(_AudioControl* rootControl,
AudioControlsMap& Map)
{
if (rootControl == 0) {
TRACE_ALWAYS("Not processing due NULL root control.\n");
TRACE(ERR, "Not processing due NULL root control.\n");
return;
}
@ -1294,7 +1295,7 @@ AudioControlInterface::_InitGainLimits(multi_mix_control& Control)
&gainInfos[i].data, &actualLength);
if (status != B_OK || actualLength != sizeof(gainInfos[i].data)) {
TRACE_ALWAYS("Request %d failed:%#08x; received %d of %d\n",
TRACE(ERR, "Request %d failed:%#08x; received %d of %d\n",
i, status, actualLength, sizeof(gainInfos[i].data));
continue;
}
@ -1302,7 +1303,7 @@ AudioControlInterface::_InitGainLimits(multi_mix_control& Control)
gainInfos[i].value = static_cast<float>(gainInfos[i].data) / 256.;
}
TRACE_ALWAYS("Control %s: from %f to %f dB, step %f dB.\n", Control.name,
TRACE(ERR, "Control %s: from %f to %f dB, step %f dB.\n", Control.name,
Control.gain.min_gain, Control.gain.max_gain, Control.gain.granularity);
}
@ -1337,7 +1338,7 @@ AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
name = "Auto Gain";
break;
default:
TRACE_ALWAYS("Unsupported type %#08x ignored.\n", controlType);
TRACE(ERR, "Unsupported type %#08x ignored.\n", controlType);
return 0;
}
@ -1380,13 +1381,13 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
{
FeatureUnit* unit = static_cast<FeatureUnit*>(control);
if (unit == 0) {
TRACE_ALWAYS("Feature Unit for null control ignored.\n");
TRACE(ERR, "Feature Unit for null control ignored.\n");
return 0;
}
AudioChannelCluster* cluster = unit->OutCluster();
if (cluster == 0) {
TRACE_ALWAYS("Control %s with null cluster ignored.\n", unit->Name());
TRACE(ERR, "Control %s with null cluster ignored.\n", unit->Name());
return 0;
}
@ -1457,7 +1458,8 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
if (_ListFeatureUnitOption(BMA_CTL_VOLUME, index, groupIndex, Info,
unit, channel, channelInfos[i].channels) == 0) {
masterIndex = (i == 0) ? groupIndex : 0 ;
TRACE("channel:%d set master index to %d\n", channel, masterIndex);
TRACE(UAC, "channel:%d set master index to %d\n",
channel, masterIndex);
}
// Auto Gain checkbox will be listed too
@ -1485,7 +1487,7 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
}
if (channelsConfig > 0)
TRACE_ALWAYS("Following channels were not processed: %#08x.\n",
TRACE(ERR, "Following channels were not processed: %#08x.\n",
channelsConfig);
// return last group index to stick possible selector unit to it. ;-)
@ -1543,7 +1545,7 @@ AudioControlInterface::_ListMixControlsPage(int32& index,
int32 group = groupIndex;
for (AudioControlsIterator I = Map.Begin(); I != Map.End(); I++) {
TRACE("%s control %d listed.\n", Name, I->Value()->ID());
TRACE(UAC, "%s control %d listed.\n", Name, I->Value()->ID());
switch(I->Value()->SubType()) {
case USB_AUDIO_AC_FEATURE_UNIT:
group = _ListFeatureUnitControl(index, groupIndex,
@ -1622,7 +1624,7 @@ AudioControlInterface::GetMix(multi_mix_value_info* Info)
length = 1;
break;
default:
TRACE_ALWAYS("Unsupported control type %#02x ignored.\n",
TRACE(ERR, "Unsupported control type %#02x ignored.\n",
CS_FROM_CTLID(Info->values[i].id));
continue;
}
@ -1634,7 +1636,7 @@ AudioControlInterface::GetMix(multi_mix_value_info* Info)
length, &data, &actualLength);
if (status != B_OK || actualLength != length) {
TRACE_ALWAYS("Request failed:%#08x; received %d of %d\n",
TRACE(ERR, "Request failed:%#08x; received %d of %d\n",
status, actualLength, length);
continue;
}
@ -1642,28 +1644,28 @@ AudioControlInterface::GetMix(multi_mix_value_info* Info)
switch(CS_FROM_CTLID(Info->values[i].id)) {
case USB_AUDIO_VOLUME_CONTROL:
Info->values[i].gain = static_cast<float>(data) / 256.;
TRACE("Gain control %d; channel: %d; is %f dB.\n",
TRACE(MIX, "Gain control %d; channel: %d; is %f dB.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].gain);
break;
case USB_AUDIO_MUTE_CONTROL:
Info->values[i].enable = data > 0;
TRACE("Mute control %d; channel: %d; is %d.\n",
TRACE(MIX, "Mute control %d; channel: %d; is %d.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].enable);
break;
case USB_AUDIO_AUTOMATIC_GAIN_CONTROL:
Info->values[i].enable = data > 0;
TRACE("AGain control %d; channel: %d; is %d.\n",
TRACE(MIX, "AGain control %d; channel: %d; is %d.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].enable);
break;
case 0: // Selector Unit
Info->values[i].mux = data;
TRACE("Selector control %d; is %d.\n",
TRACE(MIX, "Selector control %d; is %d.\n",
ID_FROM_CTLID(Info->values[i].id),
Info->values[i].mux);
break;
@ -1687,7 +1689,7 @@ AudioControlInterface::SetMix(multi_mix_value_info* Info)
case USB_AUDIO_VOLUME_CONTROL:
data = static_cast<int16>(Info->values[i].gain * 256.);
length = 2;
TRACE("Gain control %d; channel: %d; about to set to %f dB.\n",
TRACE(MIX, "Gain control %d; channel: %d; about to set to %f dB.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].gain);
@ -1695,7 +1697,7 @@ AudioControlInterface::SetMix(multi_mix_value_info* Info)
case USB_AUDIO_MUTE_CONTROL:
data = (Info->values[i].enable ? 1 : 0);
length = 1;
TRACE("Mute control %d; channel: %d; about to set to %d.\n",
TRACE(MIX, "Mute control %d; channel: %d; about to set to %d.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].enable);
@ -1703,7 +1705,7 @@ AudioControlInterface::SetMix(multi_mix_value_info* Info)
case USB_AUDIO_AUTOMATIC_GAIN_CONTROL:
data = (Info->values[i].enable ? 1 : 0);
length = 1;
TRACE("AGain control %d; channel: %d; about to set to %d.\n",
TRACE(MIX, "AGain control %d; channel: %d; about to set to %d.\n",
ID_FROM_CTLID(Info->values[i].id),
CN_FROM_CTLID(Info->values[i].id),
Info->values[i].enable);
@ -1711,12 +1713,12 @@ AudioControlInterface::SetMix(multi_mix_value_info* Info)
case 0: // Selector Unit
data = Info->values[i].mux;
length = 1;
TRACE("Selector Control %d about to set to %d.\n",
TRACE(MIX, "Selector Control %d about to set to %d.\n",
ID_FROM_CTLID(Info->values[i].id),
Info->values[i].mux);
break;
default:
TRACE_ALWAYS("Unsupported control type %#02x ignored.\n",
TRACE(ERR, "Unsupported control type %#02x ignored.\n",
CS_FROM_CTLID(Info->values[i].id));
continue;
}
@ -1728,12 +1730,12 @@ AudioControlInterface::SetMix(multi_mix_value_info* Info)
length, &data, &actualLength);
if (status != B_OK || actualLength != length) {
TRACE_ALWAYS("Request failed:%#08x; send %d of %d\n",
TRACE(ERR, "Request failed:%#08x; send %d of %d\n",
status, actualLength, length);
continue;
}
TRACE("Value set OK\n");
TRACE(MIX, "Value set OK\n");
}
return B_OK;

View File

@ -53,9 +53,9 @@ ASInterfaceDescriptor::ASInterfaceDescriptor(
fDelay = Descriptor->r1.delay;
fFormatTag = Descriptor->r1.format_tag;
TRACE("fTerminalLink:%d\n", fTerminalLink);
TRACE("fDelay:%d\n", fDelay);
TRACE("fFormatTag:%#06x\n", fFormatTag);
TRACE(UAC, "fTerminalLink:%d\n", fTerminalLink);
TRACE(UAC, "fDelay:%d\n", fDelay);
TRACE(UAC, "fFormatTag:%#06x\n", fFormatTag);
// fStatus = B_OK;
}
@ -85,12 +85,12 @@ ASEndpointDescriptor::ASEndpointDescriptor(usb_endpoint_descriptor* Endpoint,
fEndpointAddress = Endpoint->endpoint_address;
fMaxPacketSize = Endpoint->max_packet_size;
TRACE("fCSAttributes:%d\n", fCSAttributes);
TRACE("fLockDelayUnits:%d\n", fLockDelayUnits);
TRACE("fLockDelay:%d\n", fLockDelay);
TRACE("fMaxPacketSize:%d\n", fMaxPacketSize);
TRACE("fEndpointAddress:%#02x\n", fEndpointAddress);
TRACE("fEndpointAttributes:%d\n", fEndpointAttributes);
TRACE(UAC, "fCSAttributes:%d\n", fCSAttributes);
TRACE(UAC, "fLockDelayUnits:%d\n", fLockDelayUnits);
TRACE(UAC, "fLockDelay:%d\n", fLockDelay);
TRACE(UAC, "fMaxPacketSize:%d\n", fMaxPacketSize);
TRACE(UAC, "fEndpointAddress:%#02x\n", fEndpointAddress);
TRACE(UAC, "fEndpointAttributes:%d\n", fEndpointAttributes);
}
@ -171,13 +171,13 @@ TypeIFormatDescriptor::Init(usb_audio_format_descriptor* Descriptor)
fSampleFrequencies.PushBack(
GetSamFreq(Descriptor->typeI.sam_freqs[i]));
TRACE("fNumChannels:%d\n", fNumChannels);
TRACE("fSubframeSize:%d\n", fSubframeSize);
TRACE("fBitResolution:%d\n", fBitResolution);
TRACE("fSampleFrequencyType:%d\n", fSampleFrequencyType);
TRACE(UAC, "fNumChannels:%d\n", fNumChannels);
TRACE(UAC, "fSubframeSize:%d\n", fSubframeSize);
TRACE(UAC, "fBitResolution:%d\n", fBitResolution);
TRACE(UAC, "fSampleFrequencyType:%d\n", fSampleFrequencyType);
for (int32 i = 0; i < fSampleFrequencies.Count(); i++)
TRACE("Frequency #%d: %d\n", i, fSampleFrequencies[i]);
TRACE(UAC, "Frequency #%d: %d\n", i, fSampleFrequencies[i]);
return B_OK;
}
@ -241,7 +241,7 @@ AudioStreamAlternate::SetSamplingRate(uint32 newRate)
= static_cast<TypeIFormatDescriptor*>(Format());
if (format == NULL) {
TRACE_ALWAYS("Format not set for active alternate\n");
TRACE(ERR, "Format not set for active alternate\n");
return B_NO_INIT;
}
@ -260,7 +260,7 @@ AudioStreamAlternate::SetSamplingRate(uint32 newRate)
uint32 min = min_c(frequencies[0], frequencies[1]);
uint32 max = max_c(frequencies[0], frequencies[1]);
if (newRate < min || newRate > max) {
TRACE_ALWAYS("Rate %d outside of %d - %d ignored.\n",
TRACE(ERR, "Rate %d outside of %d - %d ignored.\n",
newRate, min, max);
return B_BAD_INDEX;
}
@ -271,7 +271,7 @@ AudioStreamAlternate::SetSamplingRate(uint32 newRate)
fSamplingRate = newRate;
return B_OK;
}
TRACE_ALWAYS("Rate %d not found - ignore it.\n", newRate);
TRACE(ERR, "Rate %d not found - ignore it.\n", newRate);
return B_BAD_INDEX;
}
}
@ -290,7 +290,7 @@ AudioStreamAlternate::GetSamplingRateId(uint32 rate)
if (ratesMap[i].rate == rate)
return ratesMap[i].rateId;
TRACE_ALWAYS("Ignore unsupported sample rate %d.\n", rate);
TRACE(ERR, "Ignore unsupported sample rate %d.\n", rate);
return 0;
}
@ -302,7 +302,7 @@ AudioStreamAlternate::GetSamplingRateIds()
= static_cast<TypeIFormatDescriptor*>(Format());
if (format == NULL) {
TRACE_ALWAYS("Format not set for active alternate\n");
TRACE(ERR, "Format not set for active alternate\n");
return 0;
}
@ -332,7 +332,7 @@ AudioStreamAlternate::GetFormatId()
= static_cast<TypeIFormatDescriptor*>(Format());
if (format == NULL || Interface() == NULL) {
TRACE_ALWAYS("Ignore alternate due format "
TRACE(ERR, "Ignore alternate due format "
"%#08x or interface %#08x null.\n", format, Interface());
return 0;
}
@ -354,14 +354,14 @@ AudioStreamAlternate::GetFormatId()
case 24: formats = B_FMT_24BIT; break;
case 32: formats = B_FMT_32BIT; break;
default:
TRACE_ALWAYS("Ignore unsupported "
TRACE(ERR, "Ignore unsupported "
"bit resolution %d for alternate.\n",
format->fBitResolution);
break;
}
break;
default:
TRACE_ALWAYS("Ignore unsupported "
TRACE(ERR, "Ignore unsupported "
"format bit resolution %d for alternate.\n",
Interface()->fFormatTag);
break;
@ -378,7 +378,7 @@ AudioStreamAlternate::SamplingRateFromId(uint32 id)
if (ratesMap[i].rateId == id)
return ratesMap[i].rate;
TRACE_ALWAYS("Unknown sample rate id: %d.\n", id);
TRACE(ERR, "Unknown sample rate id: %d.\n", id);
return 0;
}
@ -406,7 +406,7 @@ AudioStreamingInterface::AudioStreamingInterface(
fIsInput(false),
fActiveAlternate(0)
{
TRACE_ALWAYS("if[%d]:alt_count:%d\n", interface, List->alt_count);
TRACE(ERR, "if[%d]:alt_count:%d\n", interface, List->alt_count);
for (size_t alt = 0; alt < List->alt_count; alt++) {
ASInterfaceDescriptor* ASInterface = NULL;
@ -415,7 +415,7 @@ AudioStreamingInterface::AudioStreamingInterface(
usb_interface_info* Interface = &List->alt[alt];
TRACE_ALWAYS("if[%d]:alt[%d]:descrs_count:%d\n",
TRACE(ERR, "if[%d]:alt[%d]:descrs_count:%d\n",
interface, alt, Interface->generic_count);
for (size_t i = 0; i < Interface->generic_count; i++) {
usb_audiocontrol_header_descriptor* Header
@ -428,17 +428,17 @@ AudioStreamingInterface::AudioStreamingInterface(
ASInterface = new ASInterfaceDescriptor(
(usb_audio_streaming_interface_descriptor*)Header);
else
TRACE_ALWAYS("Duplicate AStream interface ignored.\n");
TRACE(ERR, "Duplicate AStream interface ignored.\n");
break;
case USB_AUDIO_AS_FORMAT_TYPE:
if (ASFormat == 0)
ASFormat = new TypeIFormatDescriptor(
(usb_audio_format_descriptor*) Header);
else
TRACE_ALWAYS("Duplicate AStream format ignored.\n");
TRACE(ERR, "Duplicate AStream format ignored.\n");
break;
default:
TRACE_ALWAYS("Ignore AStream descr subtype %#04x\n",
TRACE(ERR, "Ignore AStream descr subtype %#04x\n",
Header->descriptor_subtype);
break;
}
@ -452,11 +452,11 @@ AudioStreamingInterface::AudioStreamingInterface(
ASEndpoint = new ASEndpointDescriptor(Endpoint,
(usb_audio_streaming_endpoint_descriptor*)Header);
} else
TRACE_ALWAYS("Duplicate AStream endpoint ignored.\n");
TRACE(ERR, "Duplicate AStream endpoint ignored.\n");
continue;
}
TRACE_ALWAYS("Ignore Audio Stream of "
TRACE(ERR, "Ignore Audio Stream of "
"unknown descriptor type %#04x.\n", Header->descriptor_type);
}
@ -491,7 +491,7 @@ AudioStreamingInterface::ChannelCluster()
{
_AudioControl* control = fControlInterface->Find(TerminalLink());
if (control == 0) {
TRACE_ALWAYS("Control was not found for terminal id:%d.\n",
TRACE(ERR, "Control was not found for terminal id:%d.\n",
TerminalLink());
return NULL;
}

View File

@ -28,7 +28,7 @@ Device::Device(usb_device device)
= gUSBModule->get_device_descriptor(device);
if (deviceDescriptor == NULL) {
TRACE_ALWAYS("Error of getting USB device descriptor.\n");
TRACE(ERR, "Error of getting USB device descriptor.\n");
return;
}
@ -38,7 +38,7 @@ Device::Device(usb_device device)
fBuffersReadySem = create_sem(0, DRIVER_NAME "_buffers_ready");
if (fBuffersReadySem < B_OK) {
TRACE_ALWAYS("Error of creating ready "
TRACE(ERR, "Error of creating ready "
"buffers semaphore:%#010x\n", fBuffersReadySem);
return;
}
@ -131,15 +131,15 @@ Device::Control(uint32 op, void* buffer, size_t length)
return _MultiGetDescription((multi_description*)buffer);
case B_MULTI_GET_EVENT_INFO:
TRACE(("B_MULTI_GET_EVENT_INFO\n"));
TRACE(ERR, "B_MULTI_GET_EVENT_INFO n/i\n");
return B_ERROR;
case B_MULTI_SET_EVENT_INFO:
TRACE(("B_MULTI_SET_EVENT_INFO\n"));
TRACE(ERR, "B_MULTI_SET_EVENT_INFO n/i\n");
return B_ERROR;
case B_MULTI_GET_EVENT:
TRACE(("B_MULTI_GET_EVENT\n"));
TRACE(ERR, "B_MULTI_GET_EVENT n/i\n");
return B_ERROR;
case B_MULTI_GET_ENABLED_CHANNELS:
@ -155,11 +155,11 @@ Device::Control(uint32 op, void* buffer, size_t length)
return _MultiSetGlobalFormat((multi_format_info*)buffer);
case B_MULTI_GET_CHANNEL_FORMATS:
TRACE(("B_MULTI_GET_CHANNEL_FORMATS\n"));
TRACE(ERR, "B_MULTI_GET_CHANNEL_FORMATS n/i\n");
return B_ERROR;
case B_MULTI_SET_CHANNEL_FORMATS:
TRACE(("B_MULTI_SET_CHANNEL_FORMATS\n"));
TRACE(ERR, "B_MULTI_SET_CHANNEL_FORMATS n/i\n");
return B_ERROR;
case B_MULTI_GET_MIX:
@ -169,14 +169,14 @@ Device::Control(uint32 op, void* buffer, size_t length)
return _MultiSetMix((multi_mix_value_info*)buffer);
case B_MULTI_LIST_MIX_CHANNELS:
TRACE(("B_MULTI_LIST_MIX_CHANNELS\n"));
TRACE(ERR, "B_MULTI_LIST_MIX_CHANNELS n/i\n");
return B_ERROR;
case B_MULTI_LIST_MIX_CONTROLS:
return _MultiListMixControls((multi_mix_control_info*)buffer);
case B_MULTI_LIST_MIX_CONNECTIONS:
TRACE(("B_MULTI_LIST_MIX_CONNECTIONS\n"));
TRACE(ERR, "B_MULTI_LIST_MIX_CONNECTIONS n/i\n");
return B_ERROR;
case B_MULTI_GET_BUFFERS:
@ -185,12 +185,12 @@ Device::Control(uint32 op, void* buffer, size_t length)
case B_MULTI_SET_BUFFERS:
// Set what buffers to use, if the driver supports soft buffers.
TRACE(("B_MULTI_SET_BUFFERS\n"));
TRACE(ERR, "B_MULTI_SET_BUFFERS n/i\n");
return B_ERROR; /* we do not support soft buffers */
case B_MULTI_SET_START_TIME:
// When to actually start
TRACE(("B_MULTI_SET_START_TIME\n"));
TRACE(ERR, "B_MULTI_SET_START_TIME n/i\n");
return B_ERROR;
case B_MULTI_BUFFER_EXCHANGE:
@ -202,7 +202,7 @@ Device::Control(uint32 op, void* buffer, size_t length)
return _MultiBufferForceStop();
default:
TRACE_ALWAYS("Unhandled IOCTL catched: %#010x\n", op);
TRACE(ERR, "Unhandled IOCTL catched: %#010x\n", op);
}
return B_DEV_INVALID_IOCTL;
@ -233,7 +233,7 @@ Device::CompareAndReattach(usb_device device)
= gUSBModule->get_device_descriptor(device);
if (deviceDescriptor == NULL) {
TRACE_ALWAYS("Error of getting USB device descriptor.\n");
TRACE(ERR, "Error of getting USB device descriptor.\n");
return B_ERROR;
}
@ -347,37 +347,40 @@ void
Device::TraceMultiDescription(multi_description* Description,
Vector<multi_channel_info>& Channels)
{
TRACE("interface_version:%d\n", Description->interface_version);
TRACE("interface_minimum:%d\n", Description->interface_minimum);
TRACE("friendly_name:%s\n", Description->friendly_name);
TRACE("vendor_info:%s\n", Description->vendor_info);
TRACE("output_channel_count:%d\n", Description->output_channel_count);
TRACE("input_channel_count:%d\n", Description->input_channel_count);
TRACE("output_bus_channel_count:%d\n", Description->output_bus_channel_count);
TRACE("input_bus_channel_count:%d\n", Description->input_bus_channel_count);
TRACE("aux_bus_channel_count:%d\n", Description->aux_bus_channel_count);
TRACE("output_rates:%#08x\n", Description->output_rates);
TRACE("input_rates:%#08x\n", Description->input_rates);
TRACE("min_cvsr_rate:%f\n", Description->min_cvsr_rate);
TRACE("max_cvsr_rate:%f\n", Description->max_cvsr_rate);
TRACE("output_formats:%#08x\n", Description->output_formats);
TRACE("input_formats:%#08x\n", Description->input_formats);
TRACE("lock_sources:%d\n", Description->lock_sources);
TRACE("timecode_sources:%d\n", Description->timecode_sources);
TRACE("interface_flags:%#08x\n", Description->interface_flags);
TRACE("start_latency:%d\n", Description->start_latency);
TRACE("control_panel:%s\n", Description->control_panel);
TRACE(API, "interface_version:%d\n", Description->interface_version);
TRACE(API, "interface_minimum:%d\n", Description->interface_minimum);
TRACE(API, "friendly_name:%s\n", Description->friendly_name);
TRACE(API, "vendor_info:%s\n", Description->vendor_info);
TRACE(API, "output_channel_count:%d\n", Description->output_channel_count);
TRACE(API, "input_channel_count:%d\n", Description->input_channel_count);
TRACE(API, "output_bus_channel_count:%d\n",
Description->output_bus_channel_count);
TRACE(API, "input_bus_channel_count:%d\n",
Description->input_bus_channel_count);
TRACE(API, "aux_bus_channel_count:%d\n", Description->aux_bus_channel_count);
TRACE(API, "output_rates:%#08x\n", Description->output_rates);
TRACE(API, "input_rates:%#08x\n", Description->input_rates);
TRACE(API, "min_cvsr_rate:%f\n", Description->min_cvsr_rate);
TRACE(API, "max_cvsr_rate:%f\n", Description->max_cvsr_rate);
TRACE(API, "output_formats:%#08x\n", Description->output_formats);
TRACE(API, "input_formats:%#08x\n", Description->input_formats);
TRACE(API, "lock_sources:%d\n", Description->lock_sources);
TRACE(API, "timecode_sources:%d\n", Description->timecode_sources);
TRACE(API, "interface_flags:%#08x\n", Description->interface_flags);
TRACE(API, "start_latency:%d\n", Description->start_latency);
TRACE(API, "control_panel:%s\n", Description->control_panel);
// multi_channel_info* Channels = Description->channels;
// for (int i = 0; i < Description->request_channel_count; i++) {
for (int i = 0; i < Channels.Count(); i++) {
TRACE(" channel_id:%d\n", Channels[i].channel_id);
TRACE(" kind:%#02x\n", Channels[i].kind);
TRACE(" designations:%#08x\n", Channels[i].designations);
TRACE(" connectors:%#08x\n", Channels[i].connectors);
TRACE(API, " channel_id:%d\n", Channels[i].channel_id);
TRACE(API, " kind:%#02x\n", Channels[i].kind);
TRACE(API, " designations:%#08x\n", Channels[i].designations);
TRACE(API, " connectors:%#08x\n", Channels[i].connectors);
}
TRACE("request_channel_count:%d\n\n", Description->request_channel_count);
TRACE(API, "request_channel_count:%d\n\n",
Description->request_channel_count);
}
@ -430,9 +433,9 @@ Device::_MultiSetGlobalFormat(multi_format_info* Format)
{
status_t status = B_OK;
TRACE("output_latency:%lld\n", Format->output_latency);
TRACE("input_latency:%lld\n", Format->input_latency);
TRACE("timecode_kind:%#08x\n", Format->timecode_kind);
TRACE(API, "output_latency:%lld\n", Format->output_latency);
TRACE(API, "input_latency:%lld\n", Format->input_latency);
TRACE(API, "timecode_kind:%#08x\n", Format->timecode_kind);
// uint32 offset = 0;
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
@ -447,7 +450,7 @@ Device::_MultiGetBuffers(multi_buffer_list* List)
{
status_t status = B_OK;
TRACE("info_size:%d\n"
TRACE(API, "info_size:%d\n"
"request_playback_buffers:%d\n"
"request_playback_channels:%d\n"
"request_playback_buffer_size:%d\n"
@ -490,7 +493,7 @@ Device::_MultiBufferExchange(multi_buffer_info* multiInfo)
status = acquire_sem_etc(fBuffersReadySem, 1,
B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000);
if (status == B_TIMED_OUT) {
TRACE_ALWAYS("Timeout during buffers exchange.\n");
TRACE(ERR, "Timeout during buffers exchange.\n");
break;
}
@ -540,17 +543,17 @@ Device::_MultiListMixControls(multi_mix_control_info* Info)
void
Device::TraceListMixControls(multi_mix_control_info* Info)
{
TRACE("control_count:%d\n.", Info->control_count);
TRACE(MIX, "control_count:%d\n.", Info->control_count);
int32 i = 0;
while (Info->controls[i].id > 0) {
multi_mix_control &c = Info->controls[i];
TRACE("id:%#08x\n", c.id);
TRACE("flags:%#08x\n", c.flags);
TRACE("master:%#08x\n", c.master);
TRACE("parent:%#08x\n", c.parent);
TRACE("string:%d\n", c.string);
TRACE("name:%s\n", c.name);
TRACE(MIX, "id:%#08x\n", c.id);
TRACE(MIX, "flags:%#08x\n", c.flags);
TRACE(MIX, "master:%#08x\n", c.master);
TRACE(MIX, "parent:%#08x\n", c.parent);
TRACE(MIX, "string:%d\n", c.string);
TRACE(MIX, "name:%s\n", c.name);
i++;
}
}
@ -563,12 +566,12 @@ Device::_SetupEndpoints()
= gUSBModule->get_nth_configuration(fDevice, 0);
if (config == NULL) {
TRACE_ALWAYS("Error of getting USB device configuration.\n");
TRACE(ERR, "Error of getting USB device configuration.\n");
return B_ERROR;
}
if (config->interface_count <= 0) {
TRACE_ALWAYS("Error:no interfaces found in USB device configuration\n");
TRACE(ERR, "Error:no interfaces found in USB device configuration\n");
return B_ERROR;
}
@ -596,14 +599,14 @@ Device::_SetupEndpoints()
}
break;
default:
TRACE_ALWAYS("Ignore interface of unsupported subclass %#x.\n",
TRACE(ERR, "Ignore interface of unsupported subclass %#x.\n",
Interface->descr->interface_subclass);
break;
}
}
if (fAudioControl.InitCheck() == B_OK && fStreams.Count() > 0) {
TRACE("Found device %#06x:%#06x\n", fVendorID, fProductID);
TRACE(INF, "Found device %#06x:%#06x\n", fVendorID, fProductID);
gUSBModule->set_configuration(fDevice, config);
for (int i = 0; i < fStreams.Count(); i++)
@ -622,9 +625,9 @@ Device::StopDevice()
status_t result = B_OK;
if (result != B_OK)
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
TRACE(ERR, "Error of writing %#04x RX Control:%#010x\n", 0, result);
TRACE_RET(result);
//TRACE_RET(result);
return result;
}

View File

@ -40,7 +40,7 @@ usb_audio_device_added(usb_device device, void** cookie)
if (gDevices[i]->CompareAndReattach(device) != B_OK)
continue;
TRACE("The device is plugged back. Use entry at %ld.\n", i);
TRACE(INF, "The device is plugged back. Use entry at %ld.\n", i);
*cookie = gDevices[i];
return B_OK;
}
@ -69,12 +69,12 @@ usb_audio_device_added(usb_device device, void** cookie)
gDevices[i] = audioDevice;
*cookie = audioDevice;
TRACE("New device is added at %ld.\n", i);
TRACE(INF, "New device is added at %ld.\n", i);
return B_OK;
}
// no space for the device
TRACE_ALWAYS("Error: no more device entries availble.\n");
TRACE(ERR, "Error: no more device entries availble.\n");
delete audioDevice;
return B_ERROR;
@ -95,7 +95,7 @@ usb_audio_device_removed(void* cookie)
} else {
gDevices[i] = NULL;
delete device;
TRACE("Device at %ld deleted.\n", i);
TRACE(INF, "Device at %ld deleted.\n", i);
}
break;
}
@ -122,7 +122,7 @@ init_driver()
load_settings();
TRACE_ALWAYS("%s\n", kVersion);
TRACE(ERR, "%s\n", kVersion); // TODO: always???
for (int32 i = 0; i < MAX_DEVICES; i++)
gDevices[i] = NULL;
@ -234,7 +234,7 @@ usb_audio_free(void* cookie)
// removed hook has not deleted the object
gDevices[i] = NULL;
delete device;
TRACE("Device at %ld deleted.\n", i);
TRACE(INF, "Device at %ld deleted.\n", i);
break;
}
}
@ -261,10 +261,10 @@ publish_devices()
gDeviceNames[deviceCount] = (char*)malloc(strlen(sDeviceBaseName) + 4);
if (gDeviceNames[deviceCount]) {
sprintf(gDeviceNames[deviceCount], "%s%ld", sDeviceBaseName, i);
TRACE("publishing %s\n", gDeviceNames[deviceCount]);
TRACE(INF, "publishing %s\n", gDeviceNames[deviceCount]);
deviceCount++;
} else
TRACE_ALWAYS("Error: out of memory during allocating device name.\n");
TRACE(ERR, "Error: out of memory during allocating device name.\n");
}
gDeviceNames[deviceCount] = NULL;

View File

@ -18,10 +18,11 @@
#include "Driver.h"
bool gTraceOn = false;
//bool gTraceOn = false;
uint32 gTraceMask = ERR;
bool gTruncateLogFile = false;
bool gAddTimeStamp = true;
bool gTraceFlow = false;
//bool gTraceFlow = false;
static char* gLogFilePath = NULL;
mutex gLogLock;
@ -46,9 +47,10 @@ void load_settings()
if (handle == 0)
return;
gTraceOn = get_driver_boolean_parameter(handle, "trace", gTraceOn, true);
gTraceFlow = get_driver_boolean_parameter(handle, "trace_flow",
gTraceFlow, true);
//gTraceOn = get_driver_boolean_parameter(handle, "trace", gTraceOn, true);
gTraceMask = strtoul(get_driver_parameter(handle, "trace", "1", "0"), 0, 0);
//gTraceFlow = get_driver_boolean_parameter(handle, "trace_flow",
// gTraceFlow, true);
gTruncateLogFile = get_driver_boolean_parameter(handle, "truncate_logfile",
gTruncateLogFile, true);
gAddTimeStamp = get_driver_boolean_parameter(handle, "add_timestamp",
@ -73,9 +75,10 @@ void release_settings()
}
void usb_audio_trace(bool force, const char* func, const char* fmt, ...)
void usb_audio_trace(uint32 bits, const char* func, const char* fmt, ...)
{
if (!(force || gTraceOn))
//if (!(force || gTraceOn))
if ((gTraceMask & bits) == 0)
return;
va_list arg_list;

View File

@ -7,24 +7,35 @@
#ifndef _USB_AUDIO_SETTINGS_H_
#define _USB_AUDIO_SETTINGS_H_
#include <SupportDefs.h>
enum {
ERR = 0x00000001,
INF = 0x00000002,
MIX = 0x00000004,
API = 0x00000080,
DTA = 0x00000010,
ISO = 0x00000020,
UAC = 0x00000040
};
void load_settings();
void release_settings();
void usb_audio_trace(bool force, const char* func, const char* fmt, ...);
void usb_audio_trace(uint32 bits, const char* func, const char* fmt, ...);
#ifdef TRACE
#undef TRACE
#endif
#define TRACE(x...) usb_audio_trace(false, __func__, x)
#define TRACE_ALWAYS(x...) usb_audio_trace(true, __func__, x)
#define TRACE(__mask__, x...) usb_audio_trace(__mask__, __func__, x)
//#define TRACE(mask, x...) usb_audio_trace(true, __func__, x)
extern bool gTraceFlow;
#define TRACE_FLOW(x...) usb_audio_trace(gTraceFlow, NULL, x)
//extern bool gTraceFlow;
//#define TRACE_FLOW(x...) usb_audio_trace(gTraceFlow, NULL, x)
#define TRACE_RET(result) usb_audio_trace(false, __func__, \
"Returns:%#010x\n", result);
//#define TRACE_RET(result) usb_audio_trace(false, __func__,
// "Returns:%#010x\n", result);
#endif // _USB_AUDIO_SETTINGS_H_

View File

@ -49,19 +49,19 @@ Stream::_ChooseAlternate()
uint16 maxChxRes = 0;
for (int i = 0; i < fAlternates.Count(); i++) {
if (fAlternates[i]->Interface() == 0) {
TRACE("Ignore alternate %d - zero interface description.\n", i);
TRACE(INF, "Ignore alternate %d - zero interface description.\n", i);
continue;
}
if (fAlternates[i]->Format() == 0) {
TRACE("Ignore alternate %d - zero format description.\n", i);
TRACE(INF, "Ignore alternate %d - zero format description.\n", i);
continue;
}
if (fAlternates[i]->Format()->fFormatType
!= USB_AUDIO_FORMAT_TYPE_I) {
TRACE("Ignore alternate %d - format type %#02x is not supported.\n",
i, fAlternates[i]->Format()->fFormatType);
TRACE(ERR, "Ignore alternate %d - format type %#02x "
"is not supported.\n", i, fAlternates[i]->Format()->fFormatType);
continue;
}
@ -73,8 +73,8 @@ Stream::_ChooseAlternate()
// case USB_AUDIO_FORMAT_MULAW:
break;
default:
TRACE("Ignore alternate %d - format %#04x is not supported.\n",
i, fAlternates[i]->Interface()->fFormatTag);
TRACE(ERR, "Ignore alternate %d - format %#04x is not "
"supported.\n", i, fAlternates[i]->Interface()->fFormatTag);
continue;
}
@ -82,7 +82,7 @@ Stream::_ChooseAlternate()
= static_cast<TypeIFormatDescriptor*>(fAlternates[i]->Format());
if (format->fNumChannels > 2) {
TRACE("Ignore alternate %d - channel count %d "
TRACE(ERR, "Ignore alternate %d - channel count %d "
"is not supported.\n", i, format->fNumChannels);
continue;
}
@ -90,7 +90,7 @@ Stream::_ChooseAlternate()
if (fAlternates[i]->Interface()->fFormatTag == USB_AUDIO_FORMAT_PCM) {
switch(format->fBitResolution) {
default:
TRACE("Ignore alternate %d - bit resolution %d "
TRACE(ERR, "Ignore alternate %d - bit resolution %d "
"is not supported.\n", i, format->fBitResolution);
continue;
case 8: case 16: case 18: case 20: case 24: case 32:
@ -106,7 +106,8 @@ Stream::_ChooseAlternate()
}
if (maxChxRes <= 0) {
TRACE("No compatible alternate found. Stream initialization failed.\n");
TRACE(ERR, "No compatible alternate found. "
"Stream initialization failed.\n");
return B_NO_INIT;
}
@ -115,7 +116,7 @@ Stream::_ChooseAlternate()
fIsInput = (endpoint->fEndpointAddress & USB_ENDPOINT_ADDR_DIR_IN)
== USB_ENDPOINT_ADDR_DIR_IN;
TRACE("Alternate %d EP:%x selected for %s!\n",
TRACE(INF, "Alternate %d EP:%x selected for %s!\n",
fActiveAlternate, endpoint->fEndpointAddress,
fIsInput ? "recording" : "playback");
@ -159,16 +160,16 @@ Stream::_SetupBuffers()
// data size pro 1 ms USB 1 frame or 1/8 ms USB 2 microframe
fPacketSize = samplingRate * sampleSize
/ (fDevice->fUSBVersion < 0x0200 ? 1000 : 8000);
TRACE("packetSize:%ld\n", fPacketSize);
TRACE(INF, "packetSize:%ld\n", fPacketSize);
if (fArea == -1) {
fAreaSize = (sizeof(usb_iso_packet_descriptor) + fPacketSize)
* sampleSize * 1024 / fPacketSize;
TRACE("estimate fAreaSize:%d\n", fAreaSize);
TRACE(INF, "estimate fAreaSize:%d\n", fAreaSize);
// round up to B_PAGE_SIZE and create area
fAreaSize = (fAreaSize + (B_PAGE_SIZE - 1)) &~ (B_PAGE_SIZE - 1);
TRACE("rounded up fAreaSize:%d\n", fAreaSize);
TRACE(INF, "rounded up fAreaSize:%d\n", fAreaSize);
fArea = create_area( (fIsInput) ? DRIVER_NAME "_record_area"
: DRIVER_NAME "_playback_area", (void**)&fDescriptors,
@ -176,7 +177,7 @@ Stream::_SetupBuffers()
B_READ_AREA | B_WRITE_AREA);
if (fArea < 0) {
TRACE_ALWAYS("Error of creating %#x - "
TRACE(ERR, "Error of creating %#x - "
"bytes size buffer area:%#010x\n", fAreaSize, fArea);
fStatus = fArea;
return fStatus;
@ -185,7 +186,7 @@ Stream::_SetupBuffers()
// physical_entry PhysEntry;
// get_memory_map(fDescriptors, fAreaSize, &PhysEntry, 1);
TRACE_ALWAYS("Created area id:%d at addr:%#010x size:%#010lx\n",
TRACE(INF, "Created area id:%d at addr:%#010x size:%#010lx\n",
fArea, fDescriptors, fAreaSize);
}
@ -196,11 +197,11 @@ Stream::_SetupBuffers()
// we need same size sub-buffers. round it
fDescriptorsCount /= kSamplesBufferCount;
fDescriptorsCount *= kSamplesBufferCount;
TRACE("descriptorsCount:%d\n", fDescriptorsCount);
TRACE(INF, "descriptorsCount:%d\n", fDescriptorsCount);
// samples count
fSamplesCount = fDescriptorsCount * fPacketSize / sampleSize;
TRACE("samplesCount:%d\n", fSamplesCount);
TRACE(INF, "samplesCount:%d\n", fSamplesCount);
// initialize descriptors array
for (size_t i = 0; i < fDescriptorsCount; i++) {
@ -218,32 +219,32 @@ Stream::OnSetConfiguration(usb_device device,
const usb_configuration_info* config)
{
if (config == NULL) {
TRACE_ALWAYS("NULL configuration. Not set.\n");
TRACE(ERR, "NULL configuration. Not set.\n");
return B_ERROR;
}
usb_interface_info* interface
= &config->interface[fInterface].alt[fActiveAlternate];
if (interface == NULL) {
TRACE_ALWAYS("NULL interface. Not set.\n");
TRACE(ERR, "NULL interface. Not set.\n");
return B_ERROR;
}
status_t status = gUSBModule->set_alt_interface(device, interface);
uint8 address = fAlternates[fActiveAlternate]->Endpoint()->fEndpointAddress;
TRACE_ALWAYS("set_alt_interface %x\n", status);
TRACE(INF, "set_alt_interface %x\n", status);
for (size_t i = 0; i < interface->endpoint_count; i++) {
if (address == interface->endpoint[i].descr->endpoint_address) {
fStreamEndpoint = interface->endpoint[i].handle;
TRACE("%s Stream Endpoint [address %#04x] handle is: %#010x.\n",
TRACE(INF, "%s Stream Endpoint [address %#04x] handle is: %#010x.\n",
fIsInput ? "Input" : "Output", address, fStreamEndpoint);
return B_OK;
}
}
TRACE("%s Stream Endpoint [address %#04x] was not found.\n",
TRACE(INF, "%s Stream Endpoint [address %#04x] was not found.\n",
fIsInput ? "Input" : "Output", address);
return B_ERROR;
}
@ -293,7 +294,7 @@ Stream::_QueueNextTransfer(size_t queuedBuffer, bool start)
size_t packetsCount = fDescriptorsCount / kSamplesBufferCount;
TRACE("buffers:%#010x[%#x]\ndescrs:%#010x[%#x]\n",
TRACE(DTA, "buffers:%#010x[%#x]\ndescrs:%#010x[%#x]\n",
buffers + bufferSize * queuedBuffer, bufferSize,
fDescriptors + queuedBuffer * packetsCount, packetsCount);
@ -303,7 +304,7 @@ Stream::_QueueNextTransfer(size_t queuedBuffer, bool start)
&fStartingFrame, start ? USB_ISO_ASAP : 0,
Stream::_TransferCallback, this);
TRACE("frame:%#010x\n", fStartingFrame);
TRACE(DTA, "frame:%#010x\n", fStartingFrame);
return status; // B_OK;
}
@ -316,7 +317,7 @@ Stream::_TransferCallback(void* cookie, int32 status, void* data,
atomic_add(&stream->fInsideNotify, 1);
if (status == B_CANCELED || stream->fDevice->fRemoved) {
atomic_add(&stream->fInsideNotify, -1);
TRACE_ALWAYS("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);
return;
}
@ -328,11 +329,11 @@ Stream::_TransferCallback(void* cookie, int32 status, void* data,
/*status_t result =*/ stream->_QueueNextTransfer(stream->fCurrentBuffer, false);
if (atomic_add(&stream->fProcessedBuffers, 1) > (int32)kSamplesBufferCount)
TRACE_ALWAYS("Processed buffers overflow:%d\n", stream->fProcessedBuffers);
TRACE(ERR, "Processed buffers overflow:%d\n", stream->fProcessedBuffers);
release_sem_etc(stream->fDevice->fBuffersReadySem, 1, B_DO_NOT_RESCHEDULE);
TRACE("st:%#010x, data:%#010x, len:%d\n", status, data, actualLength);
TRACE(DTA, "st:%#010x, data:%#010x, len:%d\n", status, data, actualLength);
atomic_add(&stream->fInsideNotify, -1);
}
@ -345,7 +346,7 @@ Stream::_DumpDescriptors()
size_t from = /*fCurrentBuffer > 0 ? packetsCount :*/ 0 ;
size_t to = /*fCurrentBuffer > 0 ?*/ fDescriptorsCount /*: packetsCount*/ ;
for (size_t i = from; i < to; i++)
TRACE("%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].status);
}
@ -360,7 +361,7 @@ Stream::GetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
for (size_t i = 0; i < cluster->ChannelsCount(); i++) {
B_SET_CHANNEL(Enable->enable_bits, offset++, true);
TRACE("Report channel %d as enabled.\n", offset);
TRACE(INF, "Report channel %d as enabled.\n", offset);
}
return B_OK;
@ -375,7 +376,8 @@ Stream::SetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
return B_ERROR;
for (size_t i = 0; i < cluster->ChannelsCount(); i++)
TRACE("%s channel %d.\n", (B_TEST_CHANNEL(Enable->enable_bits, offset++)
TRACE(INF, "%s channel %d.\n",
(B_TEST_CHANNEL(Enable->enable_bits, offset++)
? "Enable" : "Disable"), offset + 1);
return B_OK;
@ -389,7 +391,7 @@ Stream::GetGlobalFormat(multi_format_info* Format)
format->cvsr = fAlternates[fActiveAlternate]->GetSamplingRate();
format->rate = fAlternates[fActiveAlternate]->GetSamplingRateId(0);
format->format = fAlternates[fActiveAlternate]->GetFormatId();
TRACE("%s.rate:%d cvsr:%f format:%#08x\n",
TRACE(INF, "%s.rate:%d cvsr:%f format:%#08x\n",
fIsInput ? "input" : "ouput",
format->rate, format->cvsr, format->format);
return B_OK;
@ -403,13 +405,13 @@ Stream::SetGlobalFormat(multi_format_info* Format)
AudioStreamAlternate* alternate = fAlternates[fActiveAlternate];
if (format->rate == alternate->GetSamplingRateId(0)
&& format->format == alternate->GetFormatId()) {
TRACE("No changes required\n");
TRACE(INF, "No changes required\n");
return B_OK;
}
alternate->SetSamplingRateById(format->rate);
alternate->SetFormatId(format->format);
TRACE("%s.rate:%d cvsr:%f format:%#08x\n",
TRACE(INF, "%s.rate:%d cvsr:%f format:%#08x\n",
fIsInput ? "input" : "ouput",
format->rate, format->cvsr, format->format);
@ -438,7 +440,7 @@ Stream::SetGlobalFormat(multi_format_info* Format)
USB_AUDIO_SET_CUR, USB_AUDIO_SAMPLING_FREQ_CONTROL << 8,
address, sizeof(freq), &freq, &actualLength);
TRACE_ALWAYS("set_speed %02x%02x%02x for ep %#x %d: %x\n",
TRACE(ERR, "set_speed %02x%02x%02x for ep %#x %d: %x\n",
freq.bytes[0], freq.bytes[1], freq.bytes[2],
address, actualLength, status);
return status;
@ -462,7 +464,7 @@ Stream::GetBuffers(multi_buffer_list* List)
startChannel = List->return_record_channels;
Buffers = List->record_buffers;
TRACE("flags:%#10x\nreturn_record_buffer_size:%#010x\n"
TRACE(DTA, "flags:%#10x\nreturn_record_buffer_size:%#010x\n"
"return_record_buffers:%#010x\n", List->flags,
List->return_record_buffer_size, List->return_record_buffers);
} else {
@ -470,7 +472,7 @@ Stream::GetBuffers(multi_buffer_list* List)
List->return_playback_buffer_size = fSamplesCount / kSamplesBufferCount;
List->return_playback_buffers = kSamplesBufferCount;
TRACE("flags:%#10x\nreturn_playback_buffer_size:%#010x\n"
TRACE(DTA, "flags:%#10x\nreturn_playback_buffer_size:%#010x\n"
"return_playback_buffers:%#010x\n", List->flags,
List->return_playback_buffer_size, List->return_playback_buffers);
}
@ -482,7 +484,7 @@ Stream::GetBuffers(multi_buffer_list* List)
// [buffer][channel] init buffers
for (size_t buffer = 0; buffer < kSamplesBufferCount; buffer++) {
TRACE("%s buffer #%d:\n", fIsInput ? "input" : "output", buffer + 1);
TRACE(DTA, "%s buffer #%d:\n", fIsInput ? "input" : "output", buffer + 1);
for (size_t channel = startChannel;
channel < format->fNumChannels; channel++) {
@ -500,18 +502,18 @@ Stream::GetBuffers(multi_buffer_list* List)
// shift for channel if required
Buffers[buffer][channel].base += channel * format->fSubframeSize;
TRACE("%d:%d: base:%#010x; stride:%#010x\n", buffer, channel,
TRACE(DTA, "%d:%d: base:%#010x; stride:%#010x\n", buffer, channel,
Buffers[buffer][channel].base, Buffers[buffer][channel].stride);
}
}
if (fIsInput) {
List->return_record_channels += format->fNumChannels;
TRACE("return_record_channels:%#010x\n",
TRACE(MIX, "return_record_channels:%#010x\n",
List->return_record_channels);
} else {
List->return_playback_channels += format->fNumChannels;
TRACE("return_playback_channels:%#010x\n",
TRACE(MIX, "return_playback_channels:%#010x\n",
List->return_playback_channels);
}

View File

@ -1,13 +1,21 @@
##
## Driver for USB Audio Device Class devices.
## Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
## Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
## Distributed under the terms of the MIT license.
##
## trace [on|off] - activate additional tracing.
## default value: off
## trace [mask] - activate different tracing levels
## mask - decimal or hexadecimal number combined from the following bits
## 0x01 - severe errors
## 0x02 - general messages
## 0x04 - controls map parsing and mixer control
## 0x08 - driver API calls
## 0x10 - data flow (without descriptors)
## 0x20 - dump iso descriptors
## 0x40 - USB audio control parsing
## default value: 0x01
trace on
#trace 0x7F
## logfile [full path to private log file]
## default path value: /var/log/usb_asix.log