Author Topic: Audio Lag, or why does my audio output have a ~1000ms delay  (Read 26569 times)

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Really great work on porting Mupen64Plus to the OUYA, thank you so much for that :)

I got my OUYA today, and the first thing I tried was to play Snowboard Kids :) It works great, except for the fact that there is a pretty large audio delay. Interestingly enough, it doesn't seem to change at all if I switch resolution. Native resolutions seems to have the same audio delay than 640x480. Both resolutions appear to have a good FPS rate, so there doesn't seem to be any visual lag.

Is there anything I could try to get the audio to sync? :)

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #1 on: July 08, 2013, 06:52:26 AM »
Is the delay really approximately a full second?  I honestly haven't noticed delay (I'm sure there is some).  I feel like I would have noticed if it were that long, but maybe not.  I'll check on my OUYA when I get home later.  Either way, Android just has very bad latency, and I am not sure of any way around it.  We recently discussed this on Github in Issue #147.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #2 on: July 08, 2013, 07:21:24 AM »
Thanks for the quick reply! I'll try to measure the delay when I get home, but it certainly felt longer than 500ms.

I don't have any Android experience so far, so I have to ask: I also installed BombSquad, and the audio seems to be fine there, or so it seems. How does the way that BS and Mupen do audio output differ? I would think the OUYA team wouldn't built a gaming console based on a system which, by definition, has audio problems :D
Please don't get me wrong, I'm not trying to offend, just trying to understand the issue at hand :)

Offline harrisrwe

  • bit
  • Posts: 5
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #3 on: July 08, 2013, 07:42:51 AM »
BombSquad is a game built to run on Android, not a game built for some other system and ported to Android, which means any audio or video programming was built to run on the Android system. Mupen64 is an Emulator, which means that it doesn't convert the games you play to Android, it makes the roms think they're running on an original N64, and by doing that you get some unsolvable problems. Emulators use a lot of resources to run smoothly, hence the reason there aren't any Xbox 360 or PS3 Emulators out there. Computers just aren't stong enough to run them. Simply put, Mupen64 and BombSquad are two completely different types of apps and will run differently.

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #4 on: July 08, 2013, 07:55:12 AM »
Thanks for the explanation :) I'm aware of the fact that emulating consumes a lot of resources. But resource usage doesn't seem to be the problem here (please correct me if I'm wrong), because the framerate is smooth and the audio doesn't stutter, but it is simply delayed.

From your answer I understand that Mupen64 for android, being ported, simply uses another Audio API (supposedly SDL) than a game explicitly written for Android? What API would that be? And would it be feasibly to use that same API for the OUYA version in order to circumvent the audio delay issues? (Just brainstorming, I'm not trying to make it sound like this would be done in a day).

PS: I'm very positively surprised by the quick feedback I've been getting. Kudos to all of you working hard on this emulator :) At some point in the past I tried to submit a bugfix to VBA-M (a gamboy advance emulator), and it took weeks until they got back to me ^^
« Last Edit: July 08, 2013, 07:57:07 AM by x3ro »

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #5 on: July 08, 2013, 07:59:07 AM »
@x3ro - Is there audio latency in any other N64 games you've tried?  E.g. Super Mario 64, Mario Kart, Zelda OoT, etc.?  I haven't experienced any audio latency on any of my devices (including OUYA).  The issue is probably just unique to Snowboard Kids.

2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #6 on: July 08, 2013, 08:02:54 AM »
I'll try other games as soon as I get home (as well as try to measure the delay). If this is Snowboard Kids specific, I'd really be interested in pointers (not xkcd style please) on how I could debug and possibly fix the problem :)

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #7 on: July 08, 2013, 08:06:30 AM »
Absolutely. :)

Also, in my experience Android is not a bad platform for audio, and SDL is a perfectly fine API (it's just a generalized wrapper that calls the platform-specific sound APIs).  The most common "audio" problems are stutter, which is typically not a flaw in the audio system at all (occurs when other processes like video or computation are bogging down the system).
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #8 on: July 08, 2013, 04:07:22 PM »
Hey there. I tried to measure the audio delay in Snowboard kids, and it seems to be around 750-850ms. In other games, such as Mario Kart 64, it really seems to be lower, around 400-500ms.

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #9 on: July 08, 2013, 04:45:55 PM »
I would recommend resetting your preferences (Settings->Reset...).  Games really shouldn't have any noticeable latency, even on a slow device.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #10 on: July 08, 2013, 05:33:14 PM »
Did a settings reset, but there's still noticeable delay :(

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #11 on: July 08, 2013, 05:54:29 PM »
Strange.  There's no delay on my OUYA, retail model.  I'll just start throwing out ideas because I can't figure this one out.  Is your OUYA firmware up to date?  Try reinstalling?  Try removing a usb drive if you're using one?  Make sure the OUYA isn't trying to connect some bluetooth device sitting nearby?  ....   ???
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline x3ro

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #12 on: July 08, 2013, 05:58:44 PM »
I'll give those things a try tomorrow, if I can make some time, otherwise the day after. Thanks for the suggestions! I'll report back soon :P

Offline Tomi Stallion

  • bit
  • Posts: 4
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #13 on: July 21, 2013, 03:16:29 AM »
Hello All,

I've read the above and am having the same described issue on my i9300 (Samsung GS3). Have always had it and I have been using Mupen for over six months.

Again, no stuttering or issues other than the delay of half a second. If you wish me to try anything on my device to try and fix the issue, I can do my best but I'm no developer... just a simple gamer.  ;)

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3499
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #14 on: July 21, 2013, 07:41:41 AM »
@Tomi, as you can see in github issue #147 I referenced above, several devices are known to have audio latency.  What was unusual about this thread is that it was reported for the OUYA, a device that I also own and for which I have not noticed anywhere near 1 second audio latency.

Could I get you guys to check if this problem is only the audio, or if it also involves input?  On other words, when you press A, does it take some time for Mario to jump, or does he jump immediately and it takes some time to make the sound?
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted