mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
chore: remove source comments and unused code, translate every missing string (#1965)
* chore(i18n): translate every missing string in all locales Adds the 87 strings the bottom-screen Dashboard and in-game stats pages introduced to all 32 locales, plus the 51 older settings strings Japanese and the 50 Chinese locales were still missing. Every locale now has all 3456 translatable strings with the same placeholders as English. Also translates 36 entries that were still English where the language does not use the English word, and makes es-419 touch_app_id use the same %1$s placeholder as English. * chore(patches): drop comments from the lines downstream patches add Removes comment lines and trailing comments from lines our patches add, with hunk headers recounted. Lines that a later patch uses as context and the upstream backport 0123 are left as they are. The gamescope, FEX, proot and xodus series still apply to their pinned sources, and the patched trees differ only in those comments. test_hud_frames now finds the HUD writer by its first declaration. * docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix These were credited only in source headers and NOTICE files. * chore: remove source comments and unused functions Removes explanatory comments from first-party Kotlin, Java, C, C++, Rust, TypeScript, Python, shell, Gradle, CMake and workflow files. License and attribution headers stay, and vendored third-party trees, generated files and license files are untouched. A shellcheck directive is kept, and udevmon's fallthrough comments became fallthrough attributes. Syntax trees and token streams match the previous sources apart from the comments and Python docstrings. Module docstrings that argparse prints are kept, and device-smoke.sh prints the same --help text from a heredoc. Also removes 37 functions and 4 fields that nothing referenced. * chore: remove comments from the Syncthing integration and the latest main sources * docs: credit Syncthing and the syncthing-android fork * chore(i18n): translate the Syncthing strings in all locales The 107 strings the Syncthing integration added are now in all 32 locales. sync_web_path_locked names the Syncthing tab by its label. * docs: credit @xXJSONDeruloXx for the HUD metric readers The CPU, GPU load, thermal and battery readers come from their PerformanceHudView pull requests #777, #877, #991, #1406 and #1573. The FusionHUD credit line is unchanged. * docs: credit the HUD metric readers to @xXJSONDeruloXx's work
This commit is contained in:
1 parent
d730f0fa8b
commit
c5577478ca
511 files changed
+6813
-4068
No files matched your search
@@ -1,49 +1,10 @@
|
||||
/* DirectAudio relay - the contract between the driver and the relay helper.
|
||||
*
|
||||
/*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* WHY THIS EXISTS. The driver's whole premise is an in-process AAudio client:
|
||||
* the guest's WASAPI buffers are mixed and handed to Android's audio server
|
||||
* from inside the game, no daemon in the path. That is only possible when the
|
||||
* game process is a bionic process. Under a glibc runtime (the Linux Steam
|
||||
* client, where the game runs inside a proot'd Arch rootfs on Valve's own
|
||||
* ARM64 Proton) libaaudio cannot be loaded at all: it is a bionic library and
|
||||
* the rootfs's dynamic linker does not know how to bring it into a glibc
|
||||
* process. The game side therefore has to stop at a boundary it CAN cross, and
|
||||
* the only thing both worlds agree on is the kernel: a unix socket, a memfd and
|
||||
* a futex word.
|
||||
*
|
||||
* SHAPE. One helper process (directaudio-relay, bionic, links libaaudio) runs
|
||||
* on the Android side and listens on a unix socket. Each game process that
|
||||
* needs audio connects once, sends its launch config (the same knobs the
|
||||
* in-process build reads from BANNER_AUDIO_DIRECT_*), and gets back one or two
|
||||
* shared rings (memfds passed with SCM_RIGHTS):
|
||||
*
|
||||
* render ring game (producer) -> helper (consumer) -> AAudio OUTPUT
|
||||
* capture ring helper (producer, AAudio INPUT) -> game (consumer)
|
||||
*
|
||||
* The driver keeps its mixer and its per-voice WASAPI rings exactly as in the
|
||||
* in-process build; what used to be the AAudio data callback is now a pump
|
||||
* thread that keeps the render ring topped up, and the capture callback is a
|
||||
* pump that drains the capture ring into the capture voices. Everything that
|
||||
* needs an AAudioStream (open, adaptive buffer growth and decay, route-change
|
||||
* reopen, the stalled-callback watchdog, the live-config mailbox) moves to the
|
||||
* helper unchanged in spirit.
|
||||
*
|
||||
* COST. One extra hand-off: the ring. The helper's callback pulls a burst from
|
||||
* the ring, so the ring must hold at least one burst at every callback; the
|
||||
* driver keeps DA_RING_TARGET_BURSTS bursts queued and the helper raises that
|
||||
* target when a callback finds the ring short. Everything else - the AAudio
|
||||
* buffer, AudioFlinger's own latency - is what the in-process build pays too.
|
||||
*
|
||||
* WIRE FORMAT. Fixed-width, native-endian, same-machine only. The two sides are
|
||||
* different libcs but the same CPU, so no marshalling beyond fixed-size structs.
|
||||
* Bump DA_RELAY_VERSION on any layout change; the helper refuses a mismatch.
|
||||
*/
|
||||
#ifndef DA_RELAY_PROTO_H
|
||||
#define DA_RELAY_PROTO_H
|
||||
@@ -52,34 +13,20 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#define DA_RELAY_VERSION 1
|
||||
#define DA_RING_MAGIC 0x44415247u /* 'DARG' */
|
||||
#define DA_HELLO_MAGIC 0x44414831u /* 'DAH1' */
|
||||
#define DA_ACK_MAGIC 0x44414131u /* 'DAA1' */
|
||||
#define DA_RING_MAGIC 0x44415247u
|
||||
#define DA_HELLO_MAGIC 0x44414831u
|
||||
#define DA_ACK_MAGIC 0x44414131u
|
||||
|
||||
/* Socket path. The driver reads BANNER_AUDIO_DIRECT_RELAY; when unset it falls
|
||||
* back to $XDG_RUNTIME_DIR/DA_RELAY_DEFAULT_NAME, which a host that already
|
||||
* hands its runtime dir into the session gets for free. */
|
||||
#define DA_RELAY_ENV "BANNER_AUDIO_DIRECT_RELAY"
|
||||
#define DA_RELAY_DEFAULT_NAME "directaudio-relay"
|
||||
|
||||
/* Both rings carry float32 interleaved stereo. The render ring is always
|
||||
* 48 kHz (the mixer's output rate); the capture ring runs at whatever rate the
|
||||
* input stream was granted, published in da_ring.rate, and the driver resamples
|
||||
* per voice as the in-process build already does. */
|
||||
#define DA_RING_RATE 48000
|
||||
#define DA_RING_CHANNELS 2
|
||||
|
||||
/* Render ring sizing. Capacity is the ceiling adaptive growth can reach; the
|
||||
* initial target is what the driver keeps queued. Two bursts: the helper's
|
||||
* callback consumes one burst and wakes the pump, which then has a full burst
|
||||
* period to refill before the next callback. */
|
||||
#define DA_RING_CAP_MS 250
|
||||
#define DA_RING_TARGET_BURSTS 2
|
||||
#define DA_RING_MAX_TARGET_MS 100
|
||||
|
||||
/* Capture ring: 200 ms is far more than a game ever leaves queued; on overrun
|
||||
* the helper drops the newest block, matching the in-process "guest is not
|
||||
* draining" behaviour of dropping data rather than blocking the mic thread. */
|
||||
#define DA_CAPTURE_RING_MS 200
|
||||
|
||||
enum da_ring_state
|
||||
@@ -93,35 +40,27 @@ struct da_ring
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint32_t cap_frames; /* ring capacity in frames */
|
||||
uint32_t rate; /* frames per second of the data in this ring */
|
||||
uint32_t channels; /* DA_RING_CHANNELS */
|
||||
uint32_t cap_frames;
|
||||
uint32_t rate;
|
||||
uint32_t channels;
|
||||
uint32_t _pad0;
|
||||
|
||||
/* Single producer, single consumer; monotonic frame totals, wrap-safe with
|
||||
* unsigned arithmetic. Producer writes widx with RELEASE after the data;
|
||||
* consumer writes ridx with RELEASE after it has copied the data out. */
|
||||
volatile uint32_t widx;
|
||||
volatile uint32_t ridx;
|
||||
|
||||
/* Futex word the CONSUMER of a render ring / PRODUCER of a capture ring
|
||||
* bumps after each block, so the other side can sleep on it instead of
|
||||
* polling. Waiters always use a timeout, so a missed wake only costs one
|
||||
* period. */
|
||||
volatile uint32_t wake;
|
||||
|
||||
volatile uint32_t quit; /* either side: tear down */
|
||||
volatile uint32_t state; /* enum da_ring_state, helper-owned */
|
||||
volatile uint32_t quit;
|
||||
volatile uint32_t state;
|
||||
|
||||
/* Render ring only, helper-owned, read by the driver: */
|
||||
volatile int32_t target_frames; /* keep at least this many queued */
|
||||
volatile int32_t hw_buf_frames; /* AAudio buffer size right now (get_latency) */
|
||||
volatile int32_t hw_burst; /* frames per burst of the output stream */
|
||||
volatile uint32_t underruns; /* callbacks that found fewer than they needed */
|
||||
volatile uint32_t cb_count; /* data callbacks so far (liveness) */
|
||||
volatile int32_t target_frames;
|
||||
volatile int32_t hw_buf_frames;
|
||||
volatile int32_t hw_burst;
|
||||
volatile uint32_t underruns;
|
||||
volatile uint32_t cb_count;
|
||||
uint32_t _pad1[3];
|
||||
|
||||
float data[]; /* cap_frames * channels */
|
||||
float data[];
|
||||
};
|
||||
|
||||
static inline size_t da_ring_bytes(uint32_t cap_frames)
|
||||
@@ -141,62 +80,52 @@ static inline uint32_t da_ring_space(const struct da_ring *r)
|
||||
return r->cap_frames - da_ring_avail(r);
|
||||
}
|
||||
|
||||
/* ---- wire messages ------------------------------------------------------- */
|
||||
|
||||
#define DA_HELLO_MIC 0x01u /* also open an INPUT stream + capture ring */
|
||||
#define DA_HELLO_EXCLUSIVE 0x02u /* AAUDIO_SHARING_MODE_EXCLUSIVE requested */
|
||||
#define DA_HELLO_MIC 0x01u
|
||||
#define DA_HELLO_EXCLUSIVE 0x02u
|
||||
#define DA_HELLO_ADAPTIVE 0x04u
|
||||
#define DA_HELLO_DECAY 0x08u
|
||||
#define DA_HELLO_WATCHDOG 0x10u
|
||||
|
||||
/* First message on a fresh connection, driver -> helper. Mirrors the launch
|
||||
* config the in-process build derives from BANNER_AUDIO_DIRECT_* so a preset
|
||||
* means the same thing under both runtimes. */
|
||||
struct da_hello
|
||||
{
|
||||
uint32_t magic; /* DA_HELLO_MAGIC */
|
||||
uint32_t version; /* DA_RELAY_VERSION */
|
||||
uint32_t flags; /* DA_HELLO_* */
|
||||
int32_t perf; /* 0 NONE, 1 LOW_LATENCY, 2 POWER_SAVING (host convention) */
|
||||
int32_t target_ms; /* AAudio buffer, ms; 0 = use target_frames or the default */
|
||||
int32_t max_ms; /* adaptive ceiling, ms; 0 = max_frames or the default */
|
||||
int32_t target_frames; /* frame forms, used only when the ms forms are 0 */
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint32_t flags;
|
||||
int32_t perf;
|
||||
int32_t target_ms;
|
||||
int32_t max_ms;
|
||||
int32_t target_frames;
|
||||
int32_t max_frames;
|
||||
uint32_t stall_ms; /* watchdog: callback silent this long => rebuild */
|
||||
uint32_t quiet_ms; /* decay pacing, see the driver */
|
||||
uint32_t stall_ms;
|
||||
uint32_t quiet_ms;
|
||||
uint32_t punish_ms;
|
||||
uint32_t max_backoff;
|
||||
int32_t pid; /* the game process, for the log */
|
||||
uint32_t log; /* BANNER_AUDIO_DIRECT_LOG */
|
||||
char runtime_path[256]; /* BANNER_AUDIO_DIRECT_RUNTIME mailbox, "" = none */
|
||||
char name[64]; /* process name, for the log */
|
||||
int32_t pid;
|
||||
uint32_t log;
|
||||
char runtime_path[256];
|
||||
char name[64];
|
||||
};
|
||||
|
||||
#define DA_ACK_MIC_FAILED 0x01u /* mic asked for, input stream would not open */
|
||||
#define DA_ACK_MIC_FAILED 0x01u
|
||||
|
||||
/* Reply, helper -> driver, followed by SCM_RIGHTS carrying the ring fds:
|
||||
* fd[0] = render ring, fd[1] = capture ring (present iff in_cap_frames > 0). */
|
||||
struct da_ack
|
||||
{
|
||||
uint32_t magic; /* DA_ACK_MAGIC */
|
||||
int32_t status; /* 0 = ok, else an AAudio error code (negative) */
|
||||
int32_t rate; /* output stream rate (48000) */
|
||||
int32_t burst; /* output frames per burst */
|
||||
int32_t buf_frames; /* output buffer size as opened */
|
||||
int32_t out_cap_frames; /* render ring capacity */
|
||||
int32_t in_cap_frames; /* capture ring capacity, 0 = no capture ring */
|
||||
int32_t in_rate; /* rate of the capture ring's data */
|
||||
uint32_t flags; /* DA_ACK_* */
|
||||
uint32_t magic;
|
||||
int32_t status;
|
||||
int32_t rate;
|
||||
int32_t burst;
|
||||
int32_t buf_frames;
|
||||
int32_t out_cap_frames;
|
||||
int32_t in_cap_frames;
|
||||
int32_t in_rate;
|
||||
uint32_t flags;
|
||||
uint32_t _pad;
|
||||
};
|
||||
|
||||
/* Subsequent messages, driver -> helper, on the same socket. The helper never
|
||||
* writes after the ack; everything it has to say is in the ring header. EOF on
|
||||
* the socket is how the helper learns the game is gone. */
|
||||
enum da_msg_type
|
||||
{
|
||||
DA_MSG_MIC_START = 1, /* first capture voice started: make the mic hot */
|
||||
DA_MSG_MIC_STOP = 2, /* last capture voice gone: stop (keep open) */
|
||||
DA_MSG_MIC_START = 1,
|
||||
DA_MSG_MIC_STOP = 2,
|
||||
DA_MSG_PING = 3,
|
||||
};
|
||||
|
||||
@@ -206,4 +135,4 @@ struct da_msg
|
||||
int32_t arg;
|
||||
};
|
||||
|
||||
#endif /* DA_RELAY_PROTO_H */
|
||||
#endif
|
||||
@@ -1,24 +1,5 @@
|
||||
/*
|
||||
* module-directaudio-native-sink: a PulseAudio 13 sink that is DirectAudio's AAudio engine,
|
||||
* in-process. For the native Linux Steam client on Android (DroidDeck, Bannerlator's Linux
|
||||
* session), whose sound can only ever reach a PulseAudio daemon: this module is where that
|
||||
* daemon's mixed output meets Android, one step away from AudioFlinger, with the same engine the
|
||||
* game driver has - adaptive device buffer that grows a burst on every xrun, optional decay with a
|
||||
* remembered floor, a primed ring with fades instead of clicks, route-change / error reopen on a
|
||||
* fresh stream, and a stall watchdog.
|
||||
*
|
||||
* It is the relay helper's per-client OUTPUT engine (directaudio-relay.c) with the socket and the
|
||||
* shared-memory ring replaced by a ring in this process, fed by the sink's IO thread exactly as
|
||||
* module-directaudio-sink feeds the relay. Compared with that module there is no second process
|
||||
* and no 40 ms proot safety margin: the ring here only has to cover the IO thread's own
|
||||
* scheduling jitter, so it starts at two bursts and grows only if a callback finds it short.
|
||||
*
|
||||
* The daemon must run on the Android side (the host app's process), not inside proot, for AAudio
|
||||
* to be reachable at all - which is where both host apps already run it.
|
||||
*
|
||||
* Field fixes carried from the relay (MaxsTechReview, Droid-Deck/DroidDeck#338): prime before
|
||||
* playing, fade on an underrun, one consumer per ring across a reopen, a device buffer of at
|
||||
* least two bursts.
|
||||
* Derived from the AAudio engine of DirectAudio's relay helper (directaudio-relay.c) by The412Banner.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
@@ -52,7 +33,7 @@
|
||||
#include <pulsecore/thread-mq.h>
|
||||
#include <pulsecore/thread.h>
|
||||
|
||||
#include "da_relay_proto.h" /* struct da_ring + the ring helpers; nothing of the socket protocol */
|
||||
#include "da_relay_proto.h"
|
||||
|
||||
PA_MODULE_AUTHOR("The412Banner");
|
||||
PA_MODULE_DESCRIPTION("Android audio output: DirectAudio's AAudio engine, in-process");
|
||||
@@ -77,7 +58,6 @@ PA_MODULE_USAGE(
|
||||
#define WATCHDOG_TICK_USEC (1 * PA_USEC_PER_SEC)
|
||||
#define AUDIO_NICE (-16)
|
||||
|
||||
/* ---- tunables: the in-process driver's, same defaults ----------------------- */
|
||||
#define DA_KNEE 0.75f
|
||||
#define DA_DEFAULT_MS 12
|
||||
#define DA_DEFAULT_MAX_MS 100
|
||||
@@ -112,17 +92,14 @@ struct userdata {
|
||||
pa_sample_spec ss;
|
||||
size_t frame_size;
|
||||
|
||||
/* configuration */
|
||||
aaudio_performance_mode_t perf;
|
||||
int32_t target_ms, max_ms, ring_ms;
|
||||
bool adaptive, decay, limiter, watchdog_on;
|
||||
|
||||
/* the ring: this process's, same layout as the relay's so the engine is shared */
|
||||
struct da_ring *ring;
|
||||
int32_t burst;
|
||||
int32_t ring_max_target;
|
||||
|
||||
/* the one OUTPUT stream and its adaptive state (the relay's struct client, minus the socket) */
|
||||
AAudioStream *aq;
|
||||
pthread_mutex_t lock;
|
||||
int32_t last_xrun;
|
||||
@@ -134,7 +111,6 @@ struct userdata {
|
||||
int suspended;
|
||||
volatile int dead;
|
||||
|
||||
/* what the IO thread last logged, so engine changes made on the AAudio thread get a line */
|
||||
int32_t seen_target, seen_hw_buf;
|
||||
uint32_t seen_underruns;
|
||||
pa_usec_t next_watchdog, settled_at, stats_at;
|
||||
@@ -152,8 +128,6 @@ static uint64_t now_ns(void) {
|
||||
|
||||
static void request_reopen(struct userdata *u, const char *why);
|
||||
|
||||
/* ---- the engine: the relay's out_cb / open_output / reopen / watchdog, on a local ring ---- */
|
||||
|
||||
static void fade(float *p, uint32_t frames, int in) {
|
||||
uint32_t i, ch;
|
||||
|
||||
@@ -165,8 +139,6 @@ static void fade(float *p, uint32_t frames, int in) {
|
||||
}
|
||||
}
|
||||
|
||||
/* The driver's soft-knee limiter: below DA_KNEE the signal is untouched, so ordinary material is
|
||||
* bit-identical; above it a smooth knee folds the overshoot back under full scale. */
|
||||
static void limit(float *p, uint32_t samples) {
|
||||
uint32_t i;
|
||||
|
||||
@@ -193,7 +165,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
int fade_in = 0, short_read = 0, starving = 0;
|
||||
uint64_t now;
|
||||
|
||||
/* Only the promoted stream reads the ring; an outgoing one during a reopen plays silence. */
|
||||
if ((live && aq != live) || __atomic_exchange_n(&u->consuming, 1, __ATOMIC_ACQUIRE)) {
|
||||
memset(out, 0, (size_t) frames * DA_RING_CHANNELS * sizeof(float));
|
||||
return AAUDIO_CALLBACK_RESULT_CONTINUE;
|
||||
@@ -248,8 +219,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
__atomic_add_fetch(&u->cb_count, 1, __ATOMIC_SEQ_CST);
|
||||
__atomic_store_n(&r->cb_count, u->cb_count, __ATOMIC_RELAXED);
|
||||
|
||||
/* The ring's own adaptive step: a short ring means the IO thread did not get scheduled in
|
||||
* time - an xrun one stage earlier - so keep one more burst queued. Only grows. */
|
||||
if (short_read)
|
||||
__atomic_add_fetch(&r->underruns, 1, __ATOMIC_RELAXED);
|
||||
if ((short_read || starving) && u->adaptive) {
|
||||
@@ -262,8 +231,6 @@ static aaudio_data_callback_result_t out_cb(AAudioStream *aq, void *user, void *
|
||||
__atomic_store_n(&r->target_frames, want, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
/* The device buffer: grow a burst per xrun; decay a burst after a quiet spell, never below
|
||||
* the floor a punished decay taught us. */
|
||||
if (u->adaptive) {
|
||||
int32_t xruns = AAudioStream_getXRunCount(aq);
|
||||
int32_t burst = AAudioStream_getFramesPerBurst(aq);
|
||||
@@ -312,8 +279,6 @@ static void out_error_cb(AAudioStream *aq, void *user, aaudio_result_t error) {
|
||||
|
||||
if (aq != __atomic_load_n(&u->aq, __ATOMIC_SEQ_CST)) return;
|
||||
if (__atomic_load_n(&u->suspended, __ATOMIC_SEQ_CST)) return;
|
||||
/* A disconnected stream (headphones plugged or unplugged, a Bluetooth route coming or going)
|
||||
* can never be restarted: it has to be closed and a new one opened on the current route. */
|
||||
if (error != AAUDIO_ERROR_DISCONNECTED &&
|
||||
error != AAUDIO_ERROR_INVALID_STATE &&
|
||||
error != AAUDIO_ERROR_INVALID_HANDLE &&
|
||||
@@ -322,8 +287,6 @@ static void out_error_cb(AAudioStream *aq, void *user, aaudio_result_t error) {
|
||||
request_reopen(u, "stream error");
|
||||
}
|
||||
|
||||
/* 48 kHz / float / stereo, buffer from the ms form rounded up to a burst and never below two,
|
||||
* capacity from the ceiling. The ring target floor is two bursts or ring_ms, whichever is more. */
|
||||
static aaudio_result_t open_output(struct userdata *u, AAudioStream **out) {
|
||||
AAudioStreamBuilder *builder = NULL;
|
||||
AAudioStream *aq = NULL;
|
||||
@@ -446,7 +409,6 @@ static void request_reopen(struct userdata *u, const char *why) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Ticked once a second from the IO thread: a callback silent for a second is a dead stream. */
|
||||
static void watchdog(struct userdata *u) {
|
||||
uint64_t now = now_ns(), last_cb, prev_tick;
|
||||
unsigned int cb;
|
||||
@@ -484,13 +446,10 @@ static void close_output(struct userdata *u) {
|
||||
AAudioStream_requestStop(aq);
|
||||
AAudioStream_close(aq);
|
||||
}
|
||||
/* A reopen still in flight sees u->dead and stops; give it a moment to let go of u. */
|
||||
while (__atomic_load_n(&u->reopen_running, __ATOMIC_SEQ_CST))
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
/* ---- the PulseAudio side: module-directaudio-sink's producer, on the local ring ---- */
|
||||
|
||||
static pa_usec_t frames_to_usec(const struct userdata *u, int64_t frames) {
|
||||
return (pa_usec_t) (frames * (int64_t) PA_USEC_PER_SEC / (int64_t) u->ss.rate);
|
||||
}
|
||||
@@ -528,7 +487,6 @@ static void produce(struct userdata *u, uint32_t frames) {
|
||||
__atomic_store_n(&r->widx, w + frames, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
/* Tops the ring up to the engine's target and narrates what the engine changed. */
|
||||
static void service_ring(struct userdata *u) {
|
||||
struct da_ring *r = u->ring;
|
||||
uint32_t avail, space;
|
||||
@@ -587,8 +545,6 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||
}
|
||||
|
||||
/* A started AAudio stream keeps audioserver's AudioMix wake lock held, so the device never
|
||||
* suspends while the session sleeps: stop it, and the IO thread's timer, until the sink reopens. */
|
||||
static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state, pa_suspend_cause_t new_suspend_cause) {
|
||||
struct userdata *u = s->userdata;
|
||||
aaudio_result_t res = AAUDIO_OK;
|
||||
@@ -629,9 +585,6 @@ static void thread_func(void *userdata) {
|
||||
for (;;) {
|
||||
int ret;
|
||||
|
||||
/* Half a burst between visits, never blocking on the stream: clients' audio reaches this
|
||||
* thread as messages pa_rtpoll_run handles, and a thread stuck in a write or a wait lets
|
||||
* them run dry (the crackle #338 fixed). */
|
||||
if (!u->suspended) {
|
||||
service_ring(u);
|
||||
pa_rtpoll_set_timer_relative(u->rtpoll, PA_MAX(frames_to_usec(u, u->burst) / 2, PA_USEC_PER_MSEC));
|
||||
@@ -719,7 +672,6 @@ int pa__init(pa_module *m) {
|
||||
pthread_mutex_init(&u->lock, NULL);
|
||||
pa_channel_map_init_stereo(&map);
|
||||
|
||||
/* The ring: the relay's layout in this process's memory. */
|
||||
cap_frames = DA_RING_CAP_MS_LOCAL * DA_RING_RATE / 1000;
|
||||
u->ring = pa_xmalloc0(da_ring_bytes(cap_frames));
|
||||
u->ring->magic = DA_RING_MAGIC;
|
||||
@@ -774,8 +726,6 @@ int pa__init(pa_module *m) {
|
||||
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
|
||||
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||
pa_sink_set_max_request(u->sink, (size_t) u->ring->target_frames * u->frame_size);
|
||||
/* What clients should keep queued on their side: the ring's starting target plus the device
|
||||
* buffer. Grows are reported live through GET_LATENCY. */
|
||||
pa_sink_set_fixed_latency(u->sink, frames_to_usec(u, (int64_t) u->ring->target_frames + u->base_buf_frames));
|
||||
|
||||
if (!(u->thread = pa_thread_new("directaudio-native-sink", thread_func, u))) {
|
||||
|
||||
Reference in new issue
Block a user