mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-03 19:45:39 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
823729df0e | ||
|
|
adc86fc7df | ||
|
|
f3fd3a2307 |
No files matched your search
@@ -6,6 +6,7 @@ on:
|
||||
push:
|
||||
paths:
|
||||
- 'tools/aaudio-sink/**'
|
||||
- 'tools/directaudio-relay/**'
|
||||
- '.github/workflows/build-aaudio-sink.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -25,6 +26,7 @@ jobs:
|
||||
set -euo pipefail
|
||||
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
|
||||
tools/aaudio-sink/build.sh "$PWD/pa13" "$PWD/out"
|
||||
tools/directaudio-relay/build.sh "$PWD/out"
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: audio-sink-modules
|
||||
|
||||
@@ -345,6 +345,11 @@ jobs:
|
||||
mv pulseaudio.tzst app/src/main/assets/pulseaudio.tzst
|
||||
tar --use-compress-program=unzstd -tf app/src/main/assets/pulseaudio.tzst | grep -c '\.so$'
|
||||
rm -rf pa-bundle sink-out
|
||||
- name: Build the DirectAudio relay
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
|
||||
tools/directaudio-relay/build.sh app/src/main/jniLibs/arm64-v8a
|
||||
|
||||
- name: Cache proot
|
||||
id: proot
|
||||
|
||||
@@ -14,6 +14,7 @@ app/src/main/assets/linuxfs/
|
||||
app/src/main/jniLibs/arm64-v8a/libproot.so
|
||||
app/src/main/jniLibs/arm64-v8a/.proot-inputs
|
||||
app/src/main/jniLibs/arm64-v8a/libproot-loader.so
|
||||
app/src/main/jniLibs/arm64-v8a/libdirectaudiorelay.so
|
||||
app/src/main/assets/droiddeck-esync/
|
||||
|
||||
# Kotlin compiler session files (build-tool state, never source).
|
||||
|
||||
@@ -154,7 +154,7 @@ class MainActivity : ComponentActivity() {
|
||||
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
|
||||
private var showPhantomGate by mutableStateOf(false)
|
||||
private var directAudio by mutableStateOf(false)
|
||||
private var clientDirectAudio by mutableStateOf(false)
|
||||
private var clientDirectAudio by mutableStateOf(true)
|
||||
private var stretch16x9 by mutableStateOf(false)
|
||||
private var launcherFullscreen by mutableStateOf(true)
|
||||
private var animationsEnabled by mutableStateOf(true)
|
||||
|
||||
@@ -143,8 +143,7 @@ public class PulseAudioComponent extends SessionPart {
|
||||
config.add("load-module module-directaudio-sink sink_name=DirectAudio socket=\"" + relaySocketPath + "\" performance_mode=1 adaptive=1 volume=1.0");
|
||||
config.add("set-default-sink DirectAudio");
|
||||
} else {
|
||||
// The classic sink: the adaptive AAudio module 0.1.5 shipped, unchanged.
|
||||
config.add("load-module module-aaudio-classic-sink sink_name=AAudioSink performance_mode=1 adaptive=1 volume=1.0");
|
||||
config.add("load-module module-aaudio-sink sink_name=AAudioSink performance_mode=1 adaptive=1 volume=1.0");
|
||||
config.add("set-default-sink AAudioSink");
|
||||
}
|
||||
if (micFifoPath != null && !micFifoPath.isEmpty()) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import java.io.File
|
||||
/**
|
||||
* What GPU this is, in the terms the driver lists are sorted by. KGSL names the model
|
||||
* ("Adreno740v2", "Adreno825"); the family decides which Turnip builds run on it at all, and the
|
||||
* support level is what the app has actually been tested on (Adreno 725 and up) - an Adreno 610
|
||||
* may start, but it is not "supported" just because it is a Qualcomm chip.
|
||||
* support level is what the app has actually been tested on (Adreno 650, 725 and newer) - an
|
||||
* Adreno 610 may start, but it is not "supported" just because it is a Qualcomm chip.
|
||||
*/
|
||||
data class GpuInfo(
|
||||
/** "Adreno 740", or the vendor's own name when this is not an Adreno. */
|
||||
@@ -41,6 +41,7 @@ data class GpuInfo(
|
||||
val support: Support
|
||||
get() = when {
|
||||
family == Family.NOT_ADRENO -> Support.UNSUPPORTED
|
||||
family == Family.A6XX && model == 650 -> Support.TESTED
|
||||
family == Family.A8XX -> Support.TESTED
|
||||
family == Family.A7XX && model >= 725 -> Support.TESTED
|
||||
else -> Support.UNTESTED
|
||||
@@ -51,7 +52,7 @@ data class GpuInfo(
|
||||
get() = when (support) {
|
||||
Support.TESTED -> "Supported"
|
||||
Support.UNTESTED -> if (family == Family.A7XX_LOW) "Experimental: its drivers are test builds"
|
||||
else "Below tested hardware (Adreno 725 and newer): it may not run"
|
||||
else "Outside tested hardware (Adreno 650, 725 and newer): it may not run"
|
||||
Support.UNSUPPORTED -> "Not supported: DroidDeck needs an Adreno (Snapdragon) GPU"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Fonts for every script Steam and the desktop may be shown in.
|
||||
*
|
||||
* The runtime ships DejaVu and Adwaita only, which have no Chinese, Japanese, Korean or Thai, so
|
||||
* Steam drew those as boxes (#118, #206, #249). Android already carries Noto for all of them in
|
||||
* /system/fonts; the guest gets that folder read-only at [GUEST_DIR], where fontconfig finds it
|
||||
* with the rest of /usr/share/fonts. Nothing is downloaded and the runtime is not changed.
|
||||
*
|
||||
* One CJK font holds Chinese, Japanese and Korean under one set of characters, and a character
|
||||
* they share is drawn the way the chosen region writes it. [preferenceConf] puts that region's
|
||||
* variant first, after DejaVu, which stays the font for Latin text.
|
||||
*/
|
||||
object GuestFonts {
|
||||
const val HOST_DIR = "/system/fonts"
|
||||
const val GUEST_DIR = "/usr/share/fonts/android"
|
||||
/** Rewritten at every session start, so it follows the device's language. */
|
||||
const val CONF = "etc/fonts/conf.d/65-droiddeck-language.conf"
|
||||
|
||||
/** The bind spec for Android's fonts, or null on a device without the folder. */
|
||||
@JvmStatic
|
||||
fun bindSpec(): String? = File(HOST_DIR).takeIf { it.isDirectory }?.let { "${it.path}:$GUEST_DIR" }
|
||||
|
||||
/** Writes the guest's font preference for the device's current language; best effort. */
|
||||
@JvmStatic
|
||||
fun prepare(context: Context, root: File) {
|
||||
val conf = File(root, CONF)
|
||||
val text = preferenceConf(context.resources.configuration.locales[0])
|
||||
try {
|
||||
if (conf.isFile && conf.readText() == text) return
|
||||
conf.parentFile?.mkdirs()
|
||||
conf.writeText(text)
|
||||
} catch (e: Exception) {
|
||||
// fontconfig still finds every font; shared characters just take its own default shape.
|
||||
}
|
||||
}
|
||||
|
||||
/** The CJK variant whose shapes match how [locale]'s readers write shared characters. */
|
||||
fun cjkRegion(locale: Locale): String {
|
||||
val script = locale.script
|
||||
return when (locale.language) {
|
||||
"ja" -> "JP"
|
||||
"ko" -> "KR"
|
||||
"zh" -> when {
|
||||
script == "Hans" -> "SC"
|
||||
locale.country == "HK" || locale.country == "MO" -> "HK"
|
||||
script == "Hant" || locale.country == "TW" -> "TC"
|
||||
else -> "SC"
|
||||
}
|
||||
else -> "SC"
|
||||
}
|
||||
}
|
||||
|
||||
fun preferenceConf(locale: Locale): String {
|
||||
val region = cjkRegion(locale)
|
||||
fun alias(generic: String, latin: String, cjk: String) =
|
||||
" <alias binding=\"same\">\n <family>$generic</family>\n <prefer>\n" +
|
||||
" <family>$latin</family>\n <family>$cjk $region</family>\n" +
|
||||
" </prefer>\n </alias>\n"
|
||||
return "<?xml version=\"1.0\"?>\n<!DOCTYPE fontconfig SYSTEM \"urn:fontconfig:fonts.dtd\">\n" +
|
||||
"<!-- Written by DroidDeck at session start for the device's language (${locale.toLanguageTag()}). -->\n" +
|
||||
"<fontconfig>\n" +
|
||||
alias("sans-serif", "DejaVu Sans", "Noto Sans CJK") +
|
||||
alias("serif", "DejaVu Serif", "Noto Serif CJK") +
|
||||
alias("monospace", "DejaVu Sans Mono", "Noto Sans Mono CJK") +
|
||||
"</fontconfig>\n"
|
||||
}
|
||||
}
|
||||
@@ -270,6 +270,12 @@ public final class LinuxRuntime {
|
||||
if (extraBinds != null) {
|
||||
for (String spec : extraBinds) bind(cmd, spec);
|
||||
}
|
||||
// Android's fonts, for the scripts the runtime's own fonts lack (GuestFonts).
|
||||
String fonts = GuestFonts.bindSpec();
|
||||
if (fonts != null) {
|
||||
bind(cmd, fonts);
|
||||
GuestFonts.prepare(context, root);
|
||||
}
|
||||
List<String> specs = new ArrayList<>();
|
||||
for (int i = 0; i + 1 < cmd.size(); i += 2) specs.add(cmd.get(i + 1));
|
||||
return specs;
|
||||
|
||||
@@ -156,10 +156,9 @@ object SessionPrefs {
|
||||
|
||||
/**
|
||||
* The Steam client's own sound through the DirectAudio relay instead of the classic AAudio
|
||||
* sink. Off by default: on an AYN Thor (Android 13, 20 ms bursts) the relay path stayed choppy
|
||||
* where the classic sink - the one 0.1.5 shipped - was fine.
|
||||
* sink. On unless the user picked Classic.
|
||||
*/
|
||||
fun clientDirectAudio(context: Context): Boolean = prefs(context).getBoolean("clientDirectAudio", false)
|
||||
fun clientDirectAudio(context: Context): Boolean = prefs(context).getBoolean("clientDirectAudio", true)
|
||||
|
||||
fun setClientDirectAudio(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("clientDirectAudio", on).apply()
|
||||
|
||||
@@ -619,6 +619,7 @@ class SessionService : Service() {
|
||||
// gamescope's realtime Vulkan queues (the session script turns this into
|
||||
// GAMESCOPE_FORCE_VULKAN_REALTIME); off unless the user turns it on.
|
||||
guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
|
||||
guest.add("BANNER_AUDIO_DIRECT_DECAY=0")
|
||||
// Anything else, for a device that cannot be reached with a debugger: Downloads/droiddeck-env
|
||||
// holds KEY=VALUE lines that go into the session's environment as written, after ours, so a
|
||||
// line here wins. Zink and Turnip tunables (ZINK_DESCRIPTORS=lazy, MESA_*), gamescope's,
|
||||
|
||||
@@ -62,7 +62,7 @@ class ModeSettings(
|
||||
/** Steam only: whether single and double Back actions are swapped. */
|
||||
val backActionsInverted: Boolean = false,
|
||||
val directAudio: Boolean?,
|
||||
val clientDirectAudio: Boolean = false,
|
||||
val clientDirectAudio: Boolean = true,
|
||||
val mic: Boolean?,
|
||||
val renderer: String?,
|
||||
val gameStorage: String? = null,
|
||||
|
||||
Binary file not shown.
@@ -27,9 +27,17 @@ class DriverPairsTest {
|
||||
|
||||
@Test
|
||||
fun onlyTestedHardwareCountsAsSupported() {
|
||||
assertEquals(GpuInfo.Support.TESTED, gpu(650).support)
|
||||
assertEquals("Supported", gpu(650).supportText)
|
||||
assertEquals(
|
||||
GpuInfo.Support.UNTESTED,
|
||||
GpuInfo("Adreno 650", 650, Family.ADRENO_UNKNOWN, "", false).support,
|
||||
)
|
||||
assertEquals(GpuInfo.Support.TESTED, gpu(740).support)
|
||||
assertEquals(GpuInfo.Support.TESTED, gpu(825).support)
|
||||
assertEquals(GpuInfo.Support.UNTESTED, gpu(610).support)
|
||||
assertEquals(GpuInfo.Support.UNTESTED, gpu(660).support)
|
||||
assertEquals("Outside tested hardware (Adreno 650, 725 and newer): it may not run", gpu(660).supportText)
|
||||
assertEquals(GpuInfo.Support.UNTESTED, gpu(720).support)
|
||||
assertEquals(GpuInfo.Support.UNSUPPORTED, gpu(0, adreno = false).support)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import java.util.Locale
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class GuestFontsTest {
|
||||
private fun region(tag: String) = GuestFonts.cjkRegion(Locale.forLanguageTag(tag))
|
||||
|
||||
@Test fun sharedCharactersTakeTheReadersRegionalShapes() {
|
||||
assertEquals("JP", region("ja"))
|
||||
assertEquals("KR", region("ko"))
|
||||
assertEquals("SC", region("zh-CN"))
|
||||
assertEquals("TC", region("zh-TW"))
|
||||
assertEquals("HK", region("zh-HK"))
|
||||
assertEquals("HK", region("zh-MO"))
|
||||
assertEquals("SC", region("zh-Hans-HK"))
|
||||
assertEquals("TC", region("zh-Hant"))
|
||||
assertEquals("SC", region("en"))
|
||||
}
|
||||
|
||||
@Test fun latinStaysOnDejaVuWithTheRegionsCjkNext() {
|
||||
val conf = GuestFonts.preferenceConf(Locale.JAPANESE)
|
||||
val sans = conf.substringAfter("<family>sans-serif</family>").substringBefore("</alias>")
|
||||
assertTrue(sans, sans.indexOf("DejaVu Sans") in 0 until sans.indexOf("Noto Sans CJK JP"))
|
||||
assertTrue(conf.contains("<family>Noto Serif CJK JP</family>"))
|
||||
assertTrue(conf.contains("<family>Noto Sans Mono CJK JP</family>"))
|
||||
assertTrue(conf.startsWith("<?xml"))
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,6 @@ PA_MODULE_USAGE(
|
||||
|
||||
/* The name the app's daemon config addresses (set-default-sink). */
|
||||
#define DEFAULT_SINK_NAME "AAudioSink"
|
||||
/* A write that blocks longer than this has lost the device underneath it. */
|
||||
#define WRITE_TIMEOUT_NS (500LL * 1000 * 1000)
|
||||
/* Underruns are polled every so many writes, not every write. */
|
||||
#define XRUN_CHECK_EVERY 8
|
||||
#define FALLBACK_BURST_FRAMES 192
|
||||
@@ -69,7 +67,7 @@ PA_MODULE_USAGE(
|
||||
* under proot, where every system call is traced, and a buffer of two bursts (8 ms) left the
|
||||
* client's menu sounds choppy on device; 30 ms is inaudible for a menu and games have their own
|
||||
* path. adaptive=1 still grows it further after real underruns. */
|
||||
#define MIN_BUFFER_BURSTS 4
|
||||
#define MIN_BUFFER_BURSTS 2
|
||||
#define MIN_BUFFER_USEC (30 * PA_USEC_PER_MSEC)
|
||||
/* Android's own audio threads run at nice -16 (THREAD_PRIORITY_AUDIO); an app may ask for it. */
|
||||
#define AUDIO_NICE (-16)
|
||||
@@ -116,6 +114,7 @@ struct userdata {
|
||||
int32_t xruns_seen;
|
||||
unsigned writes_since_xrun_check;
|
||||
int32_t chunk_frames;
|
||||
pa_memchunk pending;
|
||||
pa_usec_t stats_at;
|
||||
int32_t xruns_reported;
|
||||
};
|
||||
@@ -139,6 +138,12 @@ static void set_chunk(struct userdata *u) {
|
||||
u->chunk_bytes = (size_t) frames * u->frame_size;
|
||||
}
|
||||
|
||||
static void drop_pending(struct userdata *u) {
|
||||
if (u->pending.memblock)
|
||||
pa_memblock_unref(u->pending.memblock);
|
||||
pa_memchunk_reset(&u->pending);
|
||||
}
|
||||
|
||||
static void close_stream(struct userdata *u) {
|
||||
if (!u->stream)
|
||||
return;
|
||||
@@ -282,15 +287,28 @@ static void check_underruns(struct userdata *u) {
|
||||
|
||||
/* One burst from the sink into the device. Returns <0 when the stream is gone for good. */
|
||||
static int write_one_burst(struct userdata *u) {
|
||||
pa_memchunk chunk;
|
||||
const void *data;
|
||||
aaudio_result_t written;
|
||||
aaudio_result_t written = 0;
|
||||
|
||||
pa_sink_render_full(u->sink, u->chunk_bytes, &chunk);
|
||||
data = pa_memblock_acquire_chunk(&chunk);
|
||||
written = AAudioStream_write(u->stream, data, (int32_t) (chunk.length / u->frame_size), WRITE_TIMEOUT_NS);
|
||||
pa_memblock_release(chunk.memblock);
|
||||
pa_memblock_unref(chunk.memblock);
|
||||
for (;;) {
|
||||
if (!u->pending.memblock) {
|
||||
int64_t space = u->buffer_frames - (AAudioStream_getFramesWritten(u->stream) - AAudioStream_getFramesRead(u->stream));
|
||||
|
||||
if (space < u->burst_frames)
|
||||
break;
|
||||
pa_sink_render_full(u->sink, (size_t) PA_MIN(space, (int64_t) u->chunk_frames) * u->frame_size, &u->pending);
|
||||
}
|
||||
data = pa_memblock_acquire_chunk(&u->pending);
|
||||
written = AAudioStream_write(u->stream, data, (int32_t) (u->pending.length / u->frame_size), 0);
|
||||
pa_memblock_release(u->pending.memblock);
|
||||
if (written < 0)
|
||||
break;
|
||||
u->pending.index += (size_t) written * u->frame_size;
|
||||
u->pending.length -= (size_t) written * u->frame_size;
|
||||
if (u->pending.length > 0)
|
||||
break;
|
||||
drop_pending(u);
|
||||
}
|
||||
|
||||
if (written >= 0) {
|
||||
check_underruns(u);
|
||||
@@ -304,6 +322,7 @@ static int write_one_burst(struct userdata *u) {
|
||||
pa_sample_spec before = u->ss;
|
||||
|
||||
close_stream(u);
|
||||
u->rate_requested = true;
|
||||
if (open_stream(u) < 0)
|
||||
return -1;
|
||||
if (!pa_sample_spec_equal(&before, &u->ss)) {
|
||||
@@ -338,6 +357,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, 0);
|
||||
} else if (new_state == PA_SINK_SUSPENDED) {
|
||||
stop_stream(u);
|
||||
drop_pending(u);
|
||||
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
||||
}
|
||||
return 0;
|
||||
@@ -364,9 +384,8 @@ static void thread_func(void *userdata) {
|
||||
pa_sink_process_rewind(u->sink, 0);
|
||||
if (write_one_burst(u) < 0)
|
||||
goto fail;
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, PA_MAX(frames_to_usec(u, u->burst_frames) / 2, PA_USEC_PER_MSEC));
|
||||
}
|
||||
/* With the timer at zero this only drains the message queue; with it disabled (the sink
|
||||
* suspended) it blocks until something arrives. */
|
||||
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0)
|
||||
goto fail;
|
||||
if (ret == 0)
|
||||
@@ -524,6 +543,7 @@ void pa__done(pa_module *m) {
|
||||
pa_thread_mq_done(&u->thread_mq);
|
||||
if (u->sink)
|
||||
pa_sink_unref(u->sink);
|
||||
drop_pending(u);
|
||||
close_stream(u);
|
||||
if (u->rtpoll)
|
||||
pa_rtpoll_free(u->rtpoll);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* in here is at the mercy of that. The relay is not: it is the same helper that plays games'
|
||||
* DirectAudio, with its adaptive buffer, route-change reopen and watchdog. This module is a
|
||||
* producer for its render ring (da_relay_proto.h): float stereo at the ring's rate, kept topped
|
||||
* up to the target the relay asks for, one futex wait per burst.
|
||||
* up to the target the relay asks for.
|
||||
*
|
||||
* The relay comes up after the daemon, so the sink loads without it and connects when the socket
|
||||
* appears; until then it runs as a clocked null sink so clients are not stalled.
|
||||
@@ -18,10 +18,10 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/futex.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/un.h>
|
||||
@@ -73,6 +73,7 @@ PA_MODULE_USAGE(
|
||||
* legacy one (an AYN Thor, Android 13), and a single burst has nothing to cover a late callback.
|
||||
* 24 ms is two bursts there, Android's recommended minimum; the relay still grows it on xruns. */
|
||||
#define DEFAULT_BUFFER_MS 24
|
||||
#define AUDIO_NICE (-16)
|
||||
|
||||
static const char* const valid_modargs[] = {
|
||||
"socket", "sink_name", "sink_properties", "volume", "performance_mode", "adaptive", "buffer_ms", NULL
|
||||
@@ -242,11 +243,10 @@ static void produce(struct userdata *u, uint32_t frames) {
|
||||
__atomic_store_n(&r->widx, w + frames, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
/* Tops the ring up to the relay's target, then sleeps until the relay drains a burst. */
|
||||
/* Tops the ring up to the relay's target. */
|
||||
static int service_ring(struct userdata *u) {
|
||||
struct da_ring *r = u->ring;
|
||||
uint32_t avail, target, space, wake;
|
||||
struct timespec ts;
|
||||
uint32_t avail, target, space;
|
||||
|
||||
if (__atomic_load_n(&r->quit, __ATOMIC_ACQUIRE) || __atomic_load_n(&r->state, __ATOMIC_ACQUIRE) == DA_RING_ERROR) {
|
||||
pa_log("directaudio-sink: the relay closed the ring; reconnecting");
|
||||
@@ -275,11 +275,6 @@ static int service_ring(struct userdata *u) {
|
||||
u->underruns_reported = r->underruns;
|
||||
u->stats_at = pa_rtclock_now();
|
||||
}
|
||||
/* Sleep until the relay's callback bumps the wake word, at most one burst period. */
|
||||
wake = __atomic_load_n(&r->wake, __ATOMIC_ACQUIRE);
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = (long) (frames_to_usec(u, u->burst) * 1000);
|
||||
syscall(SYS_futex, &r->wake, FUTEX_WAIT, wake, &ts, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -299,6 +294,8 @@ static void thread_func(void *userdata) {
|
||||
|
||||
pa_log_debug("IO thread starting");
|
||||
pa_thread_mq_install(&u->thread_mq);
|
||||
if (setpriority(PRIO_PROCESS, (id_t) syscall(SYS_gettid), AUDIO_NICE) < 0)
|
||||
pa_log_debug("directaudio-sink: could not raise the IO thread's priority (%s)", strerror(errno));
|
||||
if (u->core->realtime_scheduling)
|
||||
pa_thread_make_realtime(u->core->realtime_priority);
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, 0);
|
||||
@@ -319,7 +316,7 @@ static void thread_func(void *userdata) {
|
||||
u->next_connect = pa_rtclock_now() + RECONNECT_USEC;
|
||||
u->offline_at = u->next_connect;
|
||||
}
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, 0);
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, PA_MAX(frames_to_usec(u, u->burst) / 2, PA_USEC_PER_MSEC));
|
||||
} else {
|
||||
/* No relay yet: a clocked null sink, so clients keep flowing and time keeps passing. */
|
||||
if (PA_SINK_IS_OPENED(u->sink->thread_info.state) && now >= u->offline_at) {
|
||||
|
||||
@@ -301,6 +301,7 @@ fi
|
||||
|
||||
sink_output="${staging_dir}/sink-out"
|
||||
"${repo_root}/tools/aaudio-sink/build.sh" "${pa_source}" "${sink_output}"
|
||||
"${repo_root}/tools/directaudio-relay/build.sh" "${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
# proot is rebuilt only when its sources (source.env, the patches, the build script) changed since
|
||||
# the libraries in jniLibs were built.
|
||||
proot_out="${repo_root}/app/src/main/jniLibs/arm64-v8a"
|
||||
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
OUTDIR=$1
|
||||
mkdir -p "$OUTDIR"
|
||||
: "${NDK:?set NDK to the Android NDK root}"
|
||||
API=28
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
REPO=$(cd "$HERE/../.." && pwd)
|
||||
case "$(uname -s):$(uname -m)" in
|
||||
Darwin:arm64) NDK_HOST=darwin-arm64 ;;
|
||||
Darwin:x86_64) NDK_HOST=darwin-x86_64 ;;
|
||||
Linux:x86_64) NDK_HOST=linux-x86_64 ;;
|
||||
Linux:aarch64|Linux:arm64) NDK_HOST=linux-aarch64 ;;
|
||||
*) echo "Unsupported build host: $(uname -s) $(uname -m)" >&2; exit 1 ;;
|
||||
esac
|
||||
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/$NDK_HOST/bin"
|
||||
if [[ ! -d "$TOOLCHAIN" && "$NDK_HOST" == darwin-arm64 && -d "$NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin" ]]; then
|
||||
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin"
|
||||
fi
|
||||
if [[ ! -d "$TOOLCHAIN" && "$NDK_HOST" == linux-aarch64 && -d "$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" ]]; then
|
||||
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||
fi
|
||||
CC="$TOOLCHAIN/aarch64-linux-android${API}-clang"
|
||||
if [[ ! -x "$CC" ]]; then
|
||||
echo "Android NDK toolchain not found at $TOOLCHAIN" >&2
|
||||
exit 1
|
||||
fi
|
||||
OUT="$OUTDIR/libdirectaudiorelay.so"
|
||||
"$CC" -O2 -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -fPIE -pie -Wl,-z,max-page-size=16384 \
|
||||
-I"$REPO/tools/aaudio-sink" \
|
||||
-o "$OUT" "$HERE/directaudio-relay.c" -laaudio -llog
|
||||
"$TOOLCHAIN/llvm-strip" --strip-unneeded "$OUT"
|
||||
NEEDED=$("$TOOLCHAIN/llvm-readelf" -d "$OUT" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p' | tr '\n' ' ')
|
||||
echo "$(basename "$OUT") NEEDED: $NEEDED"
|
||||
for lib in $NEEDED; do
|
||||
case $lib in libaaudio.so|liblog.so|libc.so|libm.so|libdl.so) ;;
|
||||
*) echo "ERROR: unexpected dependency $lib"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
ls -l "$OUT"
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user