• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
USB Audio streaming start
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

USB Audio streaming start


  • Subject: USB Audio streaming start
  • From: Vyacheslav Matyushin <email@hidden>
  • Date: Mon, 10 Oct 2011 07:06:15 -0700 (PDT)

Hi,

I'm developing an USB Audio driver and I'm stuck with streaming start.

For streaming to work without gaps I must have a number of USB transactions queued ahead,
so when a callback for completed transactions is called there will still be queued transactions to be sent over a bus.
Right now I have 4 buffers each containing 32 transactions (or 4 ms of data) for output stream.

When a transaction for a buffer is completed a callback is called which queues samples for output again.
As it takes 4 ms to process 32 transactions (or 32 micro frames) a callback is constantly called every 4 ms.

CoreAudio assumes that audio engine advances through it's buffers (increasing and wrapping an offset) at a constant rate.
So at the beginning of the streaming I can't send all 4 buffers with real samples
because I will have to take 16 ms of data from output stream buffers and advance audio engine's offset by 16 ms.
Next callbacks will advance the offset by only 4 ms each.

This way I will stream our first (sample_rate/10) output samples faster than tenth of a second.
This will produce a HAL error because I will wrap around audio engine buffers earlier than HAL expected.

Current implementation sends 4 empty buffers at the streaming start so I don't have to touch IOAudioEngine's offset.

When they are sent and their callbacks are called I finally start to output samples using them.
Unfortunately this means that I will have to send 16 ms of zero data before real samples.

If I decrease 4 buffers to 2 chances are higher that under increased system load
I will start to receive an error from IOUSBFamily complaining about an outdated number of queued transaction.

If anyone is aware of a better way to start streaming and keep USB busy I would be happy to know it.

Thanks,
Vyacheslav Matyushin.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: USB Audio streaming start
      • From: Daniel Mack <email@hidden>
    • Re: USB Audio streaming start
      • From: Vyacheslav Matyushin <email@hidden>
  • Prev by Date: Re: best way to divert callbacks to main thread from audio thread
  • Next by Date: Re: USB Audio streaming start
  • Previous by thread: With or without Garbage Collection for AU FX
  • Next by thread: Re: USB Audio streaming start
  • Index(es):
    • Date
    • Thread