Apps

What is Android NDK (C++ inside an app)

What it is

Tools for writing part of an Android app in C++. They are needed where timing and precision matter: audio, video, work with hardware.

How we use it

In OshaPlay the audio stream to a USB DAC with a ring buffer and our own resampler with distortion below −130 dB are written in C++ through the NDK.

Where it helps a business

  • An app works with hardware directly, and millisecond delays ruin the result.
  • Signal processing needs a precision that is hard to achieve in ordinary app code.

How we use it

In OshaPlay the audio stream to a USB DAC with a ring buffer and our own polyphase resampler, with distortion below −130 dB for 88.2 and 176.4 kHz, are written in C++ through the NDK. Audio goes out in isochronous transfers through the USB Host API, and the sample rate follows the track. The interface and app logic remain in Kotlin.

Common problems

  • Testing on real hardware. Direct output was tested in the emulator only for the "no DAC" case; work with a real dongle is visible through reports from the phone.
  • Not everything is supported. Direct output handles UAC2 DACs with adaptive or synchronous transfer; asynchronous DACs and UAC1 devices still play through the system.

When you do not need it

An ordinary app (a catalogue, a form, a customer account) needs no C++: Kotlin handles it and is easier to maintain.

← All terms

Need a website, a bot or automation?

Terms explained — now let's get to work: tell us about the task and we'll turn it into a clear work plan.