Skip to content

pipewire full features #20483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/alsa-lib/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TERMUX_PKG_HOMEPAGE=https://www.alsa-project.org
TERMUX_PKG_DESCRIPTION="The Advanced Linux Sound Architecture (ALSA) - library"
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.2.11"
TERMUX_PKG_SRCURL="https://github.com/alsa-project/alsa-lib/archive/refs/tags/v$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=12216f0730d6dde3ded6a2a5388bc0009ad07f5c65972bd89aac9a76f8f085a4
TERMUX_PKG_DEPENDS="libandroid-sysv-semaphore, libandroid-shmem"
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-static
--with-versioned=no
"

termux_step_pre_configure() {
# -landroid-shmem is for packages depending on alsa-lib
LDFLAGS+=" -landroid-sysv-semaphore -landroid-shmem"
autoreconf -fi
}
22 changes: 22 additions & 0 deletions packages/alsa-utils/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
TERMUX_PKG_HOMEPAGE=https://www.alsa-project.org
TERMUX_PKG_DESCRIPTION="The Advanced Linux Sound Architecture (ALSA) - utils"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.2.11"
TERMUX_PKG_SRCURL="https://github.com/alsa-project/alsa-utils/archive/refs/tags/v$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=978961153fa8ca4c783c93767e7054d0dc1fb42ef6f1008040ca71363d0f4d35
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_DEPENDS="ncurses"
TERMUX_PKG_BUILD_DEPENDS="alsa-lib"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--with-udev-rules-dir=$TERMUX_PREFIX/lib/udev/rules.d
--with-asound-state-dir=$TERMUX_PREFIX/var/lib/alsa
--disable-bat
--disable-rst2man
"

termux_step_pre_configure() {
LDFLAGS+=" -llog"
export ACLOCAL_PATH="${TERMUX_PREFIX}/share/aclocal"
autoreconf -fi
}
227 changes: 227 additions & 0 deletions packages/jack/0001-pthread_cancel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
diff --git a/drivers/alsa/hammerfall.c b/drivers/alsa/hammerfall.c
index 531d73a..91eaf17 100644
--- a/drivers/alsa/hammerfall.c
+++ b/drivers/alsa/hammerfall.c
@@ -200,7 +200,10 @@ hammerfall_release (jack_hardware_t *hw)
return;
}

+// not patched properly because thread is never created
+#ifndef __ANDROID__
pthread_cancel (h->monitor_thread);
+#endif
pthread_join (h->monitor_thread, &status);

free (h);
@@ -215,7 +218,10 @@ hammerfall_monitor_controls (void *arg)
snd_ctl_elem_id_t *switch_id[3];
snd_ctl_elem_value_t *sw[3];

+// not patched properly because thread is never created
+#ifndef __ANDROID__
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif

snd_ctl_elem_id_malloc (&switch_id[0]);
snd_ctl_elem_id_malloc (&switch_id[1]);
diff --git a/drivers/freebob/freebob_driver.c b/drivers/freebob/freebob_driver.c
index d26e6dd..8f09a48 100644
--- a/drivers/freebob/freebob_driver.c
+++ b/drivers/freebob/freebob_driver.c
@@ -795,6 +795,12 @@ freebob_driver_delete (freebob_driver_t *driver)
*/

// the thread that will queue the midi events from the seq to the stream buffers
+#ifdef __ANDROID__
+static void ThreadSignalHandler(int signum)
+{
+ pthread_exit(0);
+}
+#endif

void * freebob_driver_midi_queue_thread (void *arg)
{
@@ -807,6 +813,14 @@ void * freebob_driver_midi_queue_thread (void *arg)
int b;
int i;

+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = ThreadSignalHandler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
printMessage ("MIDI queue thread started");

while (1) {
@@ -868,6 +882,14 @@ void *freebob_driver_midi_dequeue_thread (void *arg)

assert (m);

+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = ThreadSignalHandler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
while (1) {
// read incoming events

@@ -1084,10 +1106,20 @@ freebob_driver_midi_stop (freebob_driver_midi_handle_t *m)
{
assert (m);

+// indeed, may not necessary because pthread_testcancel() seems never called
+#ifdef __ANDROID__
+ pthread_kill( m->queue_thread_cancel, SIGUSR2 );
+#else
pthread_cancel (m->queue_thread);
+#endif
pthread_join (m->queue_thread, NULL);

+// indeed, may not necessary because pthread_testcancel() seems never called
+#ifdef __ANDROID__
+ pthread_kill( m->queue_thread_cancel, SIGUSR2 );
+#else
pthread_cancel (m->dequeue_thread);
+#endif
pthread_join (m->dequeue_thread, NULL);
return 0;

diff --git a/include/engine.h b/include/engine.h
index 5106713..ea11b66 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -105,6 +105,9 @@ struct _jack_engine {

unsigned int port_max;
pthread_t server_thread;
+#ifdef __ANDROID__
+ atomic_flag server_thread_cancel;
+#endif

int fds[2];
int cleanup_fifo[2];
diff --git a/jackd/controlapi.c b/jackd/controlapi.c
index a117e20..931b619 100644
--- a/jackd/controlapi.c
+++ b/jackd/controlapi.c
@@ -692,7 +692,9 @@ jackctl_setup_signals (

setsid ();

+#ifndef __ANDROID__
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif

/* what's this for?

diff --git a/jackd/engine.c b/jackd/engine.c
index 1235815..b7458e0 100644
--- a/jackd/engine.c
+++ b/jackd/engine.c
@@ -1623,7 +1623,11 @@ jack_server_thread (void *arg)

/* Stephane Letz: letz@grame.fr : has to be added
* otherwise pthread_cancel() does not work on MacOSX */
+#ifdef __ANDROID__
+ if ( !atomic_flag_test_and_set( &engine->server_thread_cancel ) ) { pthread_exit( NULL ); };
+#else
pthread_testcancel ();
+#endif


/* empty cleanup FIFO if necessary */
@@ -2038,6 +2042,9 @@ jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock,

(void)jack_get_fifo_fd (engine, 0);

+#ifdef __ANDROID__
+ atomic_flag_test_and_set( &engine->server_thread_cancel );
+#endif
jack_client_create_thread (NULL, &engine->server_thread, 0, FALSE,
&jack_server_thread, engine);

@@ -2594,8 +2601,12 @@ jack_engine_delete (jack_engine_t *engine)
// MacOSX pthread_cancel still not implemented correctly in Darwin
mach_port_t machThread = pthread_mach_thread_np (engine->server_thread);
thread_terminate (machThread);
+#else
+#ifdef __ANDROID__
+ atomic_flag_clear( &engine->server_thread_cancel );
#else
pthread_cancel (engine->server_thread);
+#endif
pthread_join (engine->server_thread, NULL);
#endif

diff --git a/jackd/jackd.c b/jackd/jackd.c
index b27dde2..8a808b0 100644
--- a/jackd/jackd.c
+++ b/jackd/jackd.c
@@ -253,7 +253,9 @@ jack_main (jack_driver_desc_t * driver_desc, JSList * driver_params, JSList * sl

setsid ();

+#ifndef __ANDROID__
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif

/* what's this for?

diff --git a/libjack/client.c b/libjack/client.c
index b34766a..f97579d 100644
--- a/libjack/client.c
+++ b/libjack/client.c
@@ -2109,7 +2109,11 @@ jack_client_core_wait (jack_client_t* client)
return -1;
}

+#ifdef __ANDROID__
+ if ( !atomic_flag_test_and_set( &client->thread_cancel ) ) { pthread_exit( NULL ); };
+#else
pthread_testcancel ();
+#endif

/* get an accurate timestamp on waking from poll for a
* process() cycle.
@@ -2379,6 +2383,9 @@ jack_start_thread (jack_client_t *client)
return -1;
}
#else
+#ifdef __ANDROID__
+ atomic_flag_test_and_set( &client->thread_cancel );
+#endif
if (jack_client_create_thread (client,
&client->thread,
client->engine->client_priority,
@@ -2545,7 +2552,11 @@ jack_client_close_aux (jack_client_t *client)
*/

if (client->thread_ok) {
+#ifdef __ANDROID__
+ atomic_flag_clear( &client->thread_cancel );
+#else
pthread_cancel (client->thread);
+#endif
pthread_join (client->thread, &status);
}

diff --git a/libjack/local.h b/libjack/local.h
index c90d7b0..da2e70e 100644
--- a/libjack/local.h
+++ b/libjack/local.h
@@ -26,6 +26,9 @@ struct _jack_client {
JSList *ports_ext;

pthread_t thread;
+#ifdef __ANDROID__
+ atomic_flag thread_cancel;
+#endif
char fifo_prefix[PATH_MAX + 1];
void (*on_shutdown)(void *arg);
void *on_shutdown_arg;
18 changes: 18 additions & 0 deletions packages/jack/0002-pthread_attr_setinheritsched.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/libjack/thread.c b/libjack/thread.c
index a7466cc..b10cd9d 100644
--- a/libjack/thread.c
+++ b/libjack/thread.c
@@ -175,11 +175,13 @@ jack_client_create_thread (jack_client_t* client,
#ifndef JACK_USE_MACH_THREADS

pthread_attr_init (&attr);
+#if !defined __ANDROID__ || __ANDROID_API__ >= 28
result = pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED);
if (result) {
log_result ("requesting explicit scheduling", result);
return result;
}
+#endif
result = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);
if (result) {
log_result ("requesting joinable thread creation", result);
18 changes: 18 additions & 0 deletions packages/jack/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
TERMUX_PKG_HOMEPAGE=https://jackaudio.org/
TERMUX_PKG_DESCRIPTION="jack1 (non-funcitoning)"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_LICENSE="GPL-2.0, LGPL-2.0"
TERMUX_PKG_DEPENDS="libdb, libandroid-sysv-semaphore, libandroid-shmem"
TERMUX_PKG_VERSION=0.126.0
TERMUX_PKG_GIT_BRANCH=$TERMUX_PKG_VERSION
TERMUX_PKG_SRCURL=git+https://github.com/jackaudio/jack1
TERMUX_PKG_AUTO_UPDATE=true

termux_step_pre_configure() {
cd ${TERMUX_PKG_SRCDIR}
git submodule update --init --recursive
${TERMUX_PKG_SRCDIR}/autogen.sh &&
cd ${TERMUX_PKG_SRCDIR} &&
autoupdate
LDFLAGS+=" -landroid-shmem -landroid-sysv-semaphore"
}
2 changes: 1 addition & 1 deletion packages/mpv/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TERMUX_PKG_VERSION="0.38.0"
TERMUX_PKG_SRCURL=https://github.com/mpv-player/mpv/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=86d9ef40b6058732f67b46d0bbda24a074fae860b3eaae05bab3145041303066
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_DEPENDS="ffmpeg, libandroid-glob, libandroid-support, libarchive, libass, libcaca, libiconv, liblua52, libsixel, libuchardet, openal-soft, pulseaudio, rubberband, zlib, libplacebo"
TERMUX_PKG_DEPENDS="ffmpeg, libandroid-glob, libandroid-support, libarchive, libass, libcaca, libiconv, liblua52, libsixel, libuchardet, openal-soft, pulseaudio, rubberband, zlib, libplacebo, pipewire, alsa-lib, jack"
TERMUX_PKG_RM_AFTER_INSTALL="share/icons share/applications"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dlibmpv=true
Expand Down
15 changes: 15 additions & 0 deletions packages/oboe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TERMUX_PKG_HOMEPAGE=https://github.com/google/oboe
TERMUX_PKG_DESCRIPTION="Oboe is a C++ library that makes it easy to build high-performance audio apps on Android."
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.8.1"
TERMUX_PKG_SRCURL="https://github.com/google/oboe/archive/refs/tags/$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=af80c16175aa4602e51f3f4378424a199e5d91476b1cba6cd00299bf1e21881f
TERMUX_PKG_AUTO_UPDATE=true

termux_step_post_make_install() {
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="-DBUILD_SHARED_LIBS=TRUE"
termux_step_configure
termux_step_make
termux_step_make_install
}
Loading