Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4610876
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:11:32+00:00 2026-05-22T01:11:32+00:00

I’m writing an application (on android) that uses both java code, and native code.

  • 0

I’m writing an application (on android) that uses both java code, and native code. Every so often, a sound will need to be played. Unfortunately, the native code doesn’t have APIs (or at least stable/official ones) for audio, but only it knows when a sound needs to be played. I thought up two ways to do it:

  1. Have a function that keeps track (in a queue or whatnot), of the sounds that need to be played. When called, it will return a string giving the name of the sound that needs to be played. This way, the java code could call this function until it gets an empty string, where it plays the sound.

  2. Return an array of strings of the sounds that need to be played, or an empty array if none.

But then I realised that JNI calls are expensive. And these would still require the java code to call the function every iteration or so to make sure that it’s playing the right thing. And especially bad for #1, as it would have to call for every sound left to play, although not too much worse I would imagine.

So, are the JNI calls too expensive to make this not feasible? Should the native code somehow inform the java code that sounds need to be played without the java code asking first (thus making less JNI calls). I did notice though that the draw code in the android opengl es 2 ndk example went through the JNI a lot, and it seemed okay, but then again, it only drew a triangle and a background.

I’m not sure how I would go about profiling this, other than making both and looking to see what works better, so I would greatly appreciate your input. Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:11:33+00:00Added an answer on May 22, 2026 at 1:11 am

    Please take a look at NDK sample from Tegra Resources.

    Android SDK & NDK sample applications and documentation (NV_EVENT, accelerometer, audio, JNI performance, OpenGL ES 2.0 and multitouch)

    It includes JNI Audio sample what you want to implement. OpenGL ES 2.0 sample and JNI Performance testcode are also included.

    (Besides, OpenSL ES audio API for NDK is available since Android 2.3.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.