It may be added in the future, but right now there is no support for
OpenSL in the Android NDK.
- Gus
http://code.google.com/p/nativeclient-sdk/source/browse/trunk/src/examples/sine_synth/sine_synth.cc
> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>
Sad, if I found time for it, that's exactly what I would have liked to work on.
I suppose that audio things are quite critical in a phone after all...
I just wish that instead of this terrific OpenSL API, you could get some
inspiration from the Jack Audio Connection Kit, or PulseAudio (this one's in
Maemo), or PortAudio, ...
Actually, a very simple process callback would really be great, something like:
void process(short *input, short *output, int nframes);
--
Olivier
I actually thin OpenSL is overkill for most purposes. And as you
mention, there are actually multiple audio standards. The question I
have for developers out there who are supporting multiple platforms,
what audio APIs are you using, or are you targeting multiple APIs. If
it's the latter then I don't see the rush.
BTW, I still think you can do something simple as you suggest above
with a native library that communicates with a Java thread that pumps
the buffers into the audio system.
Java calling native is very fast. So if you avoid native calling up to
Java, I don't believe the latency would be significant. Is it?
Basically all you need is a way to feed AudioTrack with an array.
Allocate it in Java, pass it down to native and do a
SetShortArrayRegion and you're good to go. And if you reuse the array,
GC should be limited too. Is that what you're doing and you still see
bad latency?
>> void process(short *input, short *output, int nframes);
>
[...]
> BTW, I still think you can do something simple as you suggest above
> with a native library that communicates with a Java thread that pumps
> the buffers into the audio system.
This is what I'm doing, but it's not sufficiently reliable. Briefly, overruns
occur in many circumstances and latency has to be kept high to minimize them.
Duplex is unfeasible, because of overruns and constant noise on certain devices.
--
Olivier
> Java calling native is very fast. So if you avoid native calling up to
> Java, I don't believe the latency would be significant. Is it?
Latency is not related to how fast Java is. It comes from two things. First the
minimum buffer sizes imposed by AudioTrack and AudioRecord. Then, the fact that,
when using these minimums, overruns are frequent, and thus you need bigger buffers.
>
> Basically all you need is a way to feed AudioTrack with an array.
> Allocate it in Java, pass it down to native and do a
> SetShortArrayRegion and you're good to go. And if you reuse the array,
> GC should be limited too. Is that what you're doing and you still see
> bad latency?
GC freezing the whole audio input/output for dozens or hundreds of milliseconds.
This is exactly the werewolf that audio developers see in their worst nightmares.
Okay, you can work it around by minimizing allocations, etc..
But, from an audio developer point of view, it's wrong by design.
--
Olivier
Well, I could answer that the *maximum* is 30% of latency. With a latency of
12ms (512 frames at 44.1Khz), that would be 360 micro-seconds.
But the concept of a pause or process freeze is wrong to me. What we need is a
native API and standard Linux scheduling. No GC, no lock.
I think that this could be achieved by having clients send and receive
synchronous streams to an audio server process through lock-free ringbuffers,
using a simple native API.
--
Olivier
>> Suppose Dalvik had some sort of concurrent collector that reduced the
>> duration of the freezes. What would you consider to be the maximum
>> acceptable duration for a pause?
>
> Well, I could answer that the *maximum* is 30% of latency. With a latency of
> 12ms (512 frames at 44.1Khz), that would be 360 micro-seconds.
Humm, well, I meant 3.6ms, I'm tired.. ;)
--
Olivier
That said, how do you intend to disable GC?
Olivier