Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: USB Audio with iPhone 12 as source (T4.0)

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Location
    Piedmont, OK
    Posts
    19

    USB Audio with iPhone 12 as source (T4.0)

    One of my test users is experiencing audio issues when using an iPhone 12 as a source to a teensy 4.0. The issue does not happen with Windows, Linux, or Android as a source in my testing, only the iPhone. It manifests as very short 'breaks' in the audio periodically during playback. Does anyone happen to have knowledge of issues with Apple's USB stack or transfer when used as a USB audio source to the Teensy? Any thoughts on how I might go about troubleshooting this or where I might look for clues on the Teensy end? Something there isn't quite right...
    Thanks for any help or direction!

  2. #2
    Junior Member
    Join Date
    Nov 2019
    Location
    Piedmont, OK
    Posts
    19
    I managed to get ahold of an iPhone, and that - after some time has passed - the iPhone begins causing buffer overruns. Although overruns are seen in the Android and Windows cases, they appear as single overruns spaced out so there is time for them to be handled. in the case of the iPhone, they arrive in bunches. When this happens it appears as though the overrun recovery is taking too long to return and is causing a short break in the audio. Anything that increases latency through usb_audio_receive_callback() in usb_audio.cpp makes the problem worse. This is true at both 12Mbit and 480Mbit USB rates. Reducing the packet burst rate has no effect.

  3. #3
    How is the iPhone connected to the Teensy? USB hubs may cause issues. Try connecting directly or with different ports.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Never seen that hubs can cause issues with Teensy USB audio. Ok, if there are several devices connected, of course, because they need the bandwidth. But not with a Teensy alone...
    Do you have a link? Where is this information from?

  5. #5
    Junior Member
    Join Date
    Nov 2019
    Location
    Piedmont, OK
    Posts
    19
    This issue is not hub related. The Teensy connects to the source device directly for Android and Windows cases, and through the 'Apple Camera Adapter' for iPhone cases. The Camera Adapter is necessary as the iPhone lacks a native USB port.

  6. #6
    Quote Originally Posted by Frank B View Post
    Never seen that hubs can cause issues with Teensy USB audio. Ok, if there are several devices connected, of course, because they need the bandwidth. But not with a Teensy alone...
    Do you have a link? Where is this information from?
    I had an issue in this link. https://forum.pjrc.com/threads/69032...s-records-once

    Paulís article on a USB hub bug. https://www.pjrc.com/usb-hub-bug-hun...ssons-learned/

  7. #7
    Quote Originally Posted by highly View Post
    This issue is not hub related. The Teensy connects to the source device directly for Android and Windows cases, and through the 'Apple Camera Adapter' for iPhone cases. The Camera Adapter is necessary as the iPhone lacks a native USB port.
    If it doesnít work connected to the adapter, try using a USB hub on the adapter or try other adapters.

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Quote Originally Posted by btspp;296599

    Paul’s article on a USB hub bug. [URL
    https://www.pjrc.com/usb-hub-bug-hunting-lessons-learned/[/URL]
    That's not an article about a buggy hub. It's about a bug in the Teensy HOST code that is fixed now...

  9. #9
    Junior Member
    Join Date
    Nov 2019
    Location
    Piedmont, OK
    Posts
    19
    Speaking of fixed, the issue appears to be corrected by enabling the feedback accumulator code in usb_audio.cpp

    Code:
    if (f) {
    		int diff = AUDIO_BLOCK_SAMPLES/2 - (int)c;
    		feedback_accumulator += diff * 1;
    	-->	int32_t feedback = (feedback_accumulator >> 8) + diff * 100;
    	-->	usb_audio_sync_feedback = feedback;
    
    		//printf(diff >= 0 ? "." : "^");
    	}
    This has no impact on playback from Windows or Android, and corrects the intermittent glitches on the iPhone.
    This thread appears to describe a long-fixed bug with similar symptoms.
    Last edited by highly; 01-01-2022 at 02:26 PM. Reason: formatting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •