Which descriptor of audio device determine the audio data playing rate

Hi, all,

Now I am implement a usb audio device.

for out direction, it composed by two terminal, as following:
usb stream input(0c)–>speaker output(0e)

because I have not actually let the speaker fetch the output data and make the speaker works, so I can’t listen the music/audio play by host yet.

But when I playing a avi file, the playing speed is very fast see from the video.

So I think, it is definite lead by my audio device descriptors, but do not known, which one?

Does any one have experience on this?

workingmailing@163.com wrote:

Now I am implement a usb audio device.

for out direction, it composed by two terminal, as following:
usb stream input(0c)–>speaker output(0e)

because I have not actually let the speaker fetch the output data and make the speaker works, so I can’t listen the music/audio play by host yet.

But when I playing a avi file, the playing speed is very fast see from the video.

So I think, it is definite lead by my audio device descriptors, but do not known, which one?

How are you handling the data rate? Are you advertising several
different sampling rates in your descriptors, or just one fixed rate?
If you handle several rates, are you handling the format negotiation?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

It seems that in data format descriptor: (copy from a handset device in maket)
two frequency is listed:
8000hz and 48000hz.

Format negotiation?
Do you refer to the Set CUR request send by host after the set alternatting from 0 bandwidth alt to with one iso out ep alt?

In my firmware, I just receive the SET CUR request, but do nothing, and return ERDY, then host change to the status stage.

I am not sure what to do, when host send this SET CUR request:
SETUP PACKET: 22 01 00 01 01 00 03 00
DATA STAGE: 44 AC 00

thank you.

I just review the spec.

I under stand this audio class specific request.

0xAC44 is 44.1K, but my device descriptor said that its support 8000 to 48000.

What should I do

  1. Just change my descriptor to 44.1 k?
    or any other?

I should say again, my device, just need to verify the ISO function.
Just want to play the EP ISO OUT data to the speaker.

Maybe there are other AC97 audio chip on my system, but it is other engineer’s work to fetch the EP OUT ISO data from the buffer address I supplied, where I DMA the data from host.

after I change my descriptor:

from:
static struct usb_audio_data_format_1 as11_data_format_1 = {
.bLength = 0x0e, /* 8 + ns*3 bytes */
.bDescriptorType = 0x24, /* 0x24 = CS_INTERFACE */
.bDescriptorSubtype = 0x02,/* 0x02 = FORMAT TYPE */
.bFormatType = 0x01, /* 0x01 type 1 */
.bNrChannels = 0x02, /* No of channels = nr */
.bSubframeSize = 0x02, /* 1, 2, 3, or 4-byte subs */
.bBitResolution = 0x10, /* No. used bits in subs */
.bSamFreqType = 0x00, /* Sampling freqs. = ns */
.iSamFreq[0][0] = 0x40, /* 24-bit freq. in 8000Hz */
.iSamFreq[0][1] = 0x1f,
.iSamFreq[0][2] = 0x00,

.iSamFreq[1][0] = 0x80,/* 24-bit freq. in 48000Hz */
.iSamFreq[1][1] = 0xbb,
.iSamFreq[1][2] = 0x00,
};

to

static struct usb_audio_data_format_1 as11_data_format_1 = {
.bLength = 0x0e, /* 8 + ns*3 bytes */
.bDescriptorType = 0x24, /* 0x24 = CS_INTERFACE */
.bDescriptorSubtype = 0x02,/* 0x02 = FORMAT TYPE */
.bFormatType = 0x01, /* 0x01 type 1 */
.bNrChannels = 0x02, /* No of channels = nr */
.bSubframeSize = 0x02, /* 1, 2, 3, or 4-byte subs */
.bBitResolution = 0x10, /* No. used bits in subs */
.bSamFreqType = 0x00, /* Sampling freqs. = ns */
.iSamFreq[0][0] = 0x44, /* 24-bit freq. in 8000Hz */
.iSamFreq[0][1] = 0xac,
.iSamFreq[0][2] = 0x00,

.iSamFreq[1][0] = 0x44,/* 24-bit freq. in 48000Hz */
.iSamFreq[1][1] = 0xac,
.iSamFreq[1][2] = 0x00,
};

Just the iSamFreq from 8000 to 48000, to both equal to 44.1K.

But when I playing the media, it also very fast?

Any other suggestions?

again:

When I change

bSamFreqType = 0x00, /* Sampling freqs. = ns */
to
bSamFreqType = 0x01, /* Sampling freqs. = ns */
or
bSamFreqType = 0x02, /* Sampling freqs. = ns */

the same

workingmailing@163.com wrote:

after I change my descriptor:

from:
static struct usb_audio_data_format_1 as11_data_format_1 = {
… .bSamFreqType = 0x00, /* Sampling freqs. = ns */
.iSamFreq[0][0] = 0x40, /* 24-bit freq. in 8000Hz */
.iSamFreq[0][1] = 0x1f,
.iSamFreq[0][2] = 0x00,

.iSamFreq[1][0] = 0x80,/* 24-bit freq. in 48000Hz */
.iSamFreq[1][1] = 0xbb,
.iSamFreq[1][2] = 0x00,
};

bSamFreqType 0 means the frequency can be anything between those two values.

static struct usb_audio_data_format_1 as11_data_format_1 = {
.bLength = 0x0e, /* 8 + ns*3 bytes */
.bDescriptorType = 0x24, /* 0x24 = CS_INTERFACE */
.bDescriptorSubtype = 0x02,/* 0x02 = FORMAT TYPE */
.bFormatType = 0x01, /* 0x01 type 1 */
.bNrChannels = 0x02, /* No of channels = nr */
.bSubframeSize = 0x02, /* 1, 2, 3, or 4-byte subs */
.bBitResolution = 0x10, /* No. used bits in subs */
.bSamFreqType = 0x00, /* Sampling freqs. = ns */
.iSamFreq[0][0] = 0x44, /* 24-bit freq. in 8000Hz */
.iSamFreq[0][1] = 0xac,
.iSamFreq[0][2] = 0x00,

.iSamFreq[1][0] = 0x44,/* 24-bit freq. in 48000Hz */
.iSamFreq[1][1] = 0xac,
.iSamFreq[1][2] = 0x00,
};

If you only have one frequency, then bSamFreqType should be 1, there
should only be one entry in iSamFreq, and the descriptor should be 11
bytes long, not 14.

But when I playing the media, it also very fast?

This now says 44,100 Hz, 16-bits per sample, stereo. Do you actually
have stereo data?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

–>descriptor should be 11 bytes long, not 14

when it is 14,
I change the bSamFreqType to 2 and ,both two entries set to 44.1K.

—>This now says 44,100 Hz, 16-bits per sample, stereo. Do you actually
have stereo data?

I am not very clear about your mentioned “have stereo data”.
I just play a video file on my PC.
It works with the USB handset, it’s descritpor is my USB audio device example.

workingmailing@163.com wrote:

–>descriptor should be 11 bytes long, not 14

when it is 14,
I change the bSamFreqType to 2 and ,both two entries set to 44.1K.

Yes, but it’s not clear that’s a valid thing to do. Follow the rules.
They are there for a reason.

—>This now says 44,100 Hz, 16-bits per sample, stereo. Do you actually
have stereo data?

I am not very clear about your mentioned “have stereo data”.
I just play a video file on my PC.
It works with the USB handset, it’s descritpor is my USB audio device example.

Perhaps I am making too many assumptions about what you are actually
doing. Are you saying that, when you play back a movie with your device
as the audio output, the movie plays faster than normal? That doesn’t
make any sense. Have you adjusted the isochronous endpoint packet size
to match your fixed audio format? That shouldn’t actually make a
difference; usbaudio.sys should parcel out the data correctly even if
the packet size is large.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

thank you all guys.

This issue is fixed.

After review the USB trace of the handset example.
It send out DP each 1ms not each 125us.

After chnage the descritpor interval from 1 to 4, video display normally.

Because it is a full speed device, interval with 1 is 1ms
when ss or hs need the 1ms service interval, it should change it to 4.

thank you again.