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

Offline xperia64

  • Moderator
  • double
  • *****
  • Posts: 591
    • View Profile
    • My Apps
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #30 on: August 03, 2013, 10:26:13 PM »
A SLES plugin would be really nice especially on my galaxy s2. Audio latency is very noticeable (wasn't as bad on my xperia play). But I could see Native->Java->Native sound library/device could cause some issues.

Offline vgf89

  • bit
  • Posts: 2
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #31 on: August 04, 2013, 05:27:07 AM »
Again, the fact that this is happening on more than one emulator, each of which was written by entirely different teams of developers, suggests that the issue is related to something larger than just the emulators.  Are your game ROMs for Mupen and the other emulators located on an external drive, by any chance?  I've heard some anecdotes that the OUYA stutters when running things off an external drive.  Of course that's not the same thing as latency, but I thought I'd throw it out there.

@devs - Do you think the other emulators use SDL?  Or any other common libraries?  What do they all have in common?

Just to reply  to your question, the performance and audio lag is exactly the same no matter where the ROMs are located.

Also, I just tested this on my SGSIII running CM 10.1.2 and the audio lag feels about the same as on my stock  rooted Note 10.1

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 #32 on: August 04, 2013, 12:02:07 PM »
Looks like there will be a little more work than anticipated involved in an SLES audio plugin, but I haven't run into any show-stoppers yet.  I probably won't have it in a compilable state today, but I'll still push whatever I have to github this evening, for anyone interested to follow or make suggestions.  I've been programming in Java and PHP for so long that my C/ C++ skills have gotten a little rusty, LOL.  This will be a good way to refresh them.
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 xperia64

  • Moderator
  • double
  • *****
  • Posts: 591
    • View Profile
    • My Apps
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #33 on: August 04, 2013, 06:31:56 PM »

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 #34 on: August 04, 2013, 09:32:56 PM »
Pushed initial commit of the new SLES audio plug-in.  It is buildable, but still missing key features, so not useable yet.  Still a lot of work left to do before it will be ready for testing.. just keeping everyone in the loop.
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 littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #35 on: August 05, 2013, 09:58:33 AM »
Cool...  :)
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Tsukuyomi

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #36 on: August 10, 2013, 07:37:32 PM »
I notice some latency problems on my s advance
these didn't happened on n64oid
but, its not asomething annoying (at least on my phone)

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #37 on: August 11, 2013, 10:30:20 AM »
Digging through the code, I may have found the cause of the audio latency.  If you are experiencing the issue, would you mind installing the version below, and reporting back?
https://dl.dropboxusercontent.com/u/3899306/mupen64plu-audio-latency-test1.apk

You will need to uninstall your current version first.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline xperia64

  • Moderator
  • double
  • *****
  • Posts: 591
    • View Profile
    • My Apps
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #38 on: August 11, 2013, 10:49:14 AM »
Audio lag is still noticeable, the best game to hear delay in sound is banjo-kazooie. The intro cutscene after the rare logo always has the audio slower than the video on pretty much every n64 emulator, this can be ignored for now. However, notice the sound fx in game. The jumping/attacking sound fx are always delayed.

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 #39 on: August 11, 2013, 12:34:35 PM »
Just to rule out anything specific to Banjo Kazooie, I think the definitive test whether the problem has been improved at all, would be to compare the jump sound effect on Mario 64 on devices that have experienced the reported extreme ~1 second latency.
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 littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #40 on: August 11, 2013, 01:33:05 PM »
I wonder if I have latency just never noticed it.  When I press B in Mario, Mario swings a punch then yells "yah" as he pulls his arm back to rest.  Can't remember what it was like on the original console.  Maybe I'll fire up PJ64 on my PC...

Edit: LOL I guess I've had latency this whole time and never noticed it.  On PJ64 on windows he yells as he's swinging the punch... go figure :P
« Last Edit: August 11, 2013, 01:44:45 PM by littleguy »
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

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 #41 on: August 11, 2013, 01:54:33 PM »
Yes, I've always had some latency too, it just doesn't bother me as much as some users.  It isn't anywhere close to a second, though (I'm sure that would bother me).

Everything I've read says the best way to take advantage of the smaller audio buffers in JB is to do the audio on the native side with SLES, to remove dalvik and gc from the equation.  Also, using a one-read one-write buffer strategy instead of thread locks, and using a specific format for output to avoid an extra trip through Android's resampler, and doing audio processing from a specific audio callback thread that has higher priority than other threads.  These are all things I have planned for the audio plugin I'm writing.
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 littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #42 on: August 11, 2013, 02:05:20 PM »
Sounds like you're exactly the right person for the job ;D

Just a heads-up - not sure if/how it would affect you, but the latest version of SDL creates and manages the audio thread in the native SDL library now - no longer on the Java side.  See commit 7612:
http://hg.libsdl.org/SDL/rev/627d571587d3

Edit: Of course you could bypass SDL altogether for audio (just like it's bypassed altogether for input).  I haven't looked closely, but I imagine the current audio-sdl library invokes a bunch of SDL stuff to initialize and perform its duties, which in turn call our current java-side audio implementation.
« Last Edit: August 11, 2013, 02:09:12 PM by littleguy »
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #43 on: November 23, 2013, 09:59:36 PM »
Anyone still reading this thread: enable framelimiter.  It's in the video settings in version 2.4.1.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Audio Lag, or why does my audio output have a ~1000ms delay
« Reply #44 on: November 24, 2013, 07:49:02 PM »
(ignore)
« Last Edit: December 02, 2013, 10:48:25 PM by littleguy »
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version