这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@twaik
Copy link
Member

@twaik twaik commented Oct 15, 2024

Fixes #18790
Fixes #10412
Fixes #21545
Fixes #20570
Fixes #19679
Fixes #5422

Audacity starts, can open wav and mp3 files, play and record sound (with RECORD_AUDIO permission granted to Termux:API). Some review needed.

@twaik twaik added the help wanted Help is wanted in order to solve the issue label Oct 15, 2024
@twaik twaik force-pushed the audacity-3.6.4 branch 4 times, most recently from f8dc076 to 091d05f Compare October 15, 2024 20:54
@twaik twaik requested a review from TomJo2000 October 15, 2024 23:34
@Biswa96
Copy link
Member

Biswa96 commented Oct 16, 2024

I have tested the aarch64 CI artifact in my phone but got an error.

CANNOT LINK EXECUTABLE "audacity": library "lib-theme-resources.so" not found: needed by main executable

After exporting the variables like this file https://github.com/audacity/audacity/blob/master/au3/linux/audacity.sh

$ LD_LIBRARY_PATH=$PREFIX/lib/audacity AUDACITY_MODULES_PATH=$PREFIX/lib/audacity/modules audacity
Bad system call

audacity fails with semget syscall.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Ok, so I removed usage of semget/semctl/semop and also shmget and managed to make it work without them. Also I added -Wl,-rpath to make it work without LD_LIBRARY_PATH. Should work now.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

By should work I meant the patch worked fine with audacity built for regular linux, I did not check it on my own device.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Ok, I checked it on device and it starts and shows GUI, no LD_LIBRARY_PATH or AUDACITY_MODULES_PATH needed. My patch for maintaining single instance also works. But I have no idea how to check if it actually works with sound files or something, need some testing before merging.

@twaik twaik marked this pull request as ready for review October 16, 2024 15:31
@twaik twaik requested a review from Biswa96 October 16, 2024 15:33
@Biswa96
Copy link
Member

Biswa96 commented Oct 16, 2024

Now audacity opens but it does not play any audio file. Try to import a mp3 file and click on the play button.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

I tried to open m4a file and it refused to open it too. Probably it can not pick ffmpeg.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Interesting. The same happens to old audacity, probably portaudio related.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

portaudio.tar.gz (uncomment two commented lines in build.sh)
Fun. I managed to make portaudio with opensles using some old sources, so output works, but no input.
And this portaudio crashes after a finishing playing my sample sound, probably some bug in portaudio or in opensles hostapi backend, something with pthread_join.

10-16 21:25:30.702 24591 24591 F libc    : invalid pthread_t 0x781d701d00 passed to pthread_join
10-16 21:25:30.702 24591 24591 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24591 (audacity), pid 24591 (audacity)
10-16 21:25:30.780 24637 24637 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
10-16 21:25:30.783 24637 24637 I crash_dump64: performing dump of process 24591 (target tid = 24591)
10-16 21:25:30.914 24637 24637 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-16 21:25:30.914 24637 24637 F DEBUG   : Build fingerprint: 'samsung/r8sxx/r8s:13/TP1A.220624.014/G780FXXSJFXI2:user/release-keys'
10-16 21:25:30.914 24637 24637 F DEBUG   : Revision: '5'
10-16 21:25:30.914 24637 24637 F DEBUG   : ABI: 'arm64'
10-16 21:25:30.914 24637 24637 F DEBUG   : Processor: '4'
10-16 21:25:30.914 24637 24637 F DEBUG   : Timestamp: 2024-10-16 21:25:30.797687496+0300
10-16 21:25:30.914 24637 24637 F DEBUG   : Process uptime: 29s
10-16 21:25:30.914 24637 24637 F DEBUG   : Cmdline: audacity
10-16 21:25:30.914 24637 24637 F DEBUG   : pid: 24591, tid: 24591, name: audacity  >>> audacity <<<
10-16 21:25:30.914 24637 24637 F DEBUG   : uid: 10674
10-16 21:25:30.914 24637 24637 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
10-16 21:25:30.914 24637 24637 F DEBUG   : Abort message: 'invalid pthread_t 0x781d701d00 passed to pthread_join'
10-16 21:25:30.915 24637 24637 F DEBUG   :     x0  0000000000000000  x1  000000000000600f  x2  0000000000000006  x3  0000007fe9640340
10-16 21:25:30.915 24637 24637 F DEBUG   :     x4  0000000000808080  x5  0000000000808080  x6  0000000000808080  x7  8080800000000000
10-16 21:25:30.915 24637 24637 F DEBUG   :     x8  00000000000000f0  x9  00000078c8869b70  x10 0000000000000001  x11 00000078c88db004
10-16 21:25:30.915 24637 24637 F DEBUG   :     x12 0101010101010101  x13 000000006710051a  x14 0029ccfb9c4235f6  x15 0000000000000070
10-16 21:25:30.915 24637 24637 F DEBUG   :     x16 00000078c8942a48  x17 00000078c891cf30  x18 00000078fbb4e000  x19 000000000000600f
10-16 21:25:30.915 24637 24637 F DEBUG   :     x20 000000000000600f  x21 00000000ffffffff  x22 00000078fadd3010  x23 00000078fadd3010
10-16 21:25:30.915 24637 24637 F DEBUG   :     x24 00000078fadd3010  x25 0000007820644218  x26 0000007820644200  x27 00000062d897df30
10-16 21:25:30.915 24637 24637 F DEBUG   :     x28 00000078df378d90  x29 0000007fe96403c0
10-16 21:25:30.915 24637 24637 F DEBUG   :     lr  00000078c88ccbbc  sp  0000007fe9640320  pc  00000078c88ccbe8  pst 0000000000000000
10-16 21:25:30.915 24637 24637 F DEBUG   : backtrace:
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE: Function names and BuildId information is missing for some frames due
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE: found under the lib/ directory are readable.
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE: On this device, run setenforce 0 to make the libraries readable.
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE: Unreadable libraries:
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/bin/audacity
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/audacity/lib-audio-io.so
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/libglib-2.0.so
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/libgtk-3.so
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/libportaudio.so.2.0.0
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :   NOTE:   /data/data/com.termux/files/usr/lib/libwx_gtk3u_core-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #00 pc 000000000008abe8  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ae97b4676db8ce3f620ba6bf7932eba6)
10-16 21:25:30.915 24637 24637 F DEBUG   :       #01 pc 00000000000efbf0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_internal_find(long, char const*)+192) (BuildId: ae97b4676db8ce3f620ba6bf7932eba6)
10-16 21:25:30.915 24637 24637 F DEBUG   :       #02 pc 00000000000efeac  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_join+100) (BuildId: ae97b4676db8ce3f620ba6bf7932eba6)
10-16 21:25:30.915 24637 24637 F DEBUG   :       #03 pc 000000000000ef7c  /data/data/com.termux/files/usr/lib/libportaudio.so.2.0.0
10-16 21:25:30.915 24637 24637 F DEBUG   :       #04 pc 000000000000e20c  /data/data/com.termux/files/usr/lib/libportaudio.so.2.0.0
10-16 21:25:30.915 24637 24637 F DEBUG   :       #05 pc 000000000000a1c0  /data/data/com.termux/files/usr/lib/libportaudio.so.2.0.0 (Pa_CloseStream+128)
10-16 21:25:30.915 24637 24637 F DEBUG   :       #06 pc 00000000000213b4  /data/data/com.termux/files/usr/lib/audacity/lib-audio-io.so
10-16 21:25:30.915 24637 24637 F DEBUG   :       #07 pc 0000000000823ee4  /data/data/com.termux/files/usr/bin/audacity
10-16 21:25:30.915 24637 24637 F DEBUG   :       #08 pc 00000000008a6eec  /data/data/com.termux/files/usr/bin/audacity
10-16 21:25:30.915 24637 24637 F DEBUG   :       #09 pc 00000000001b7c7c  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #10 pc 00000000001b7b68  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #11 pc 00000000001b8984  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #12 pc 00000000001b8894  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #13 pc 00000000001b87a8  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #14 pc 00000000001b862c  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #15 pc 000000000010a6e4  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #16 pc 00000000004582d4  /data/data/com.termux/files/usr/lib/libwx_gtk3u_core-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #17 pc 00000000004590c8  /data/data/com.termux/files/usr/lib/libwx_gtk3u_core-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #18 pc 00000000000dd314  /data/data/com.termux/files/usr/lib/libglib-2.0.so
10-16 21:25:30.915 24637 24637 F DEBUG   :       #19 pc 00000000000dd598  /data/data/com.termux/files/usr/lib/libglib-2.0.so
10-16 21:25:30.915 24637 24637 F DEBUG   :       #20 pc 00000000000dd7dc  /data/data/com.termux/files/usr/lib/libglib-2.0.so
10-16 21:25:30.915 24637 24637 F DEBUG   :       #21 pc 00000000005830e8  /data/data/com.termux/files/usr/lib/libgtk-3.so
10-16 21:25:30.915 24637 24637 F DEBUG   :       #22 pc 0000000000468c18  /data/data/com.termux/files/usr/lib/libwx_gtk3u_core-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #23 pc 000000000012eb18  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #24 pc 000000000010a150  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #25 pc 0000000000765f4c  /data/data/com.termux/files/usr/bin/audacity
10-16 21:25:30.915 24637 24637 F DEBUG   :       #26 pc 000000000014d7b0  /data/data/com.termux/files/usr/lib/libwx_baseu-3.2.so.0.2.1
10-16 21:25:30.915 24637 24637 F DEBUG   :       #27 pc 000000000075def4  /data/data/com.termux/files/usr/bin/audacity
10-16 21:25:30.915 24637 24637 F DEBUG   :       #28 pc 0000000000083198  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: ae97b4676db8ce3f620ba6bf7932eba6)
10-16 21:25:30.931 24637 24637 E crash_dump64: AM data write failed: Broken pipe
10-16 21:25:30.964 24045 24045 I shmem   : int libandroid_shmdt(const void *): unmapped addr 0x76a5ec2000 for FD 30 ID 4 shmid 600f0003
10-16 21:25:30.964 24045 24045 I shmem   : int libandroid_shmdt(const void *): deleting shmid 600f0003
10-16 21:25:30.969 24045 24045 I shmem   : int libandroid_shmdt(const void *): unmapped addr 0x76a4ec2000 for FD 31 ID 4 shmid 600f0004
10-16 21:25:30.969 24045 24045 I shmem   : int libandroid_shmdt(const void *): deleting shmid 600f0004

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Sample to enumerate portaudio devices.

#include <stdio.h>
#include "portaudio.h"

int main(void)
{
    PaError err;

    /* Initialize PortAudio */
    err = Pa_Initialize();
    if (err != paNoError) {
        fprintf(stderr, "PortAudio error during initialization: %s\n", Pa_GetErrorText(err));
        return 1;
    }

    /* Get the number of audio devices */
    int numDevices = Pa_GetDeviceCount();
    if (numDevices < 0) {
        fprintf(stderr, "PortAudio error getting device count: %s\n", Pa_GetErrorText(numDevices));
        Pa_Terminate();
        return 1;
    }

    printf("Number of devices found: %d\n\n", numDevices);

    /* Iterate over each device */
    for (int i = 0; i < numDevices; i++) {
        const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(i);

        printf("Device #%d:\n", i);
        printf("  Name                        : %s\n", deviceInfo->name);
        printf("  Host API                    : %s\n", Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
        printf("  Max input channels          : %d\n", deviceInfo->maxInputChannels);
        printf("  Max output channels         : %d\n", deviceInfo->maxOutputChannels);
        printf("  Default sample rate         : %.2f\n", deviceInfo->defaultSampleRate);
        printf("  Default low input latency   : %.4f\n", deviceInfo->defaultLowInputLatency);
        printf("  Default low output latency  : %.4f\n", deviceInfo->defaultLowOutputLatency);
        printf("  Default high input latency  : %.4f\n", deviceInfo->defaultHighInputLatency);
        printf("  Default high output latency : %.4f\n", deviceInfo->defaultHighOutputLatency);
        printf("\n");
    }

    /* Terminate PortAudio */
    err = Pa_Terminate();
    if (err != paNoError) {
        fprintf(stderr, "PortAudio error during termination: %s\n", Pa_GetErrorText(err));
        return 1;
    }

    return 0;
}

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Ok, I figured out. For some reason pthread_join crashed application instead returning immediately or throwing ESRCH error. Now sound output works.

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

AFAIK microphone support is not possible without RECORD_AUDIO so it will be wontfix until @agnostic-apollo decides to add it to termux-app's application manifest.

@agnostic-apollo
Copy link
Member

You can install termux-api, will have to see about adding to termux-app itself.

https://github.com/termux/termux-api/blob/c553bc2ba7de37ad5c42df23d71e699d2785d7c5/app/src/main/AndroidManifest.xml#L27

@twaik
Copy link
Member Author

twaik commented Oct 16, 2024

Wow! So microphone works fine too! So cool!
I did not know termux:api can give permissions to tools of main termux app.

@agnostic-apollo
Copy link
Member

They share sharedUserId, so permissions are shared between all apps under the same uid regardless of who requests it.

@twaik
Copy link
Member Author

twaik commented Oct 17, 2024

I'll merge this PR in 24 hours if no one minds.

@agnostic-apollo
Copy link
Member

Oh, so you finally have the audacity to merge! huh!

@truboxl
Copy link
Contributor

truboxl commented Oct 17, 2024

Should turn off networking, update checks and crash reports

@twaik
Copy link
Member Author

twaik commented Oct 17, 2024

Done. Also I replaced xtkoba's message about not supporting audio devices with warning to grant microphone access to Termux:API. Probably we should add this message in every place where microphone is being accessed. Or we should patch these places to explicitly ask for microphone access with using Termux:API.

@twaik twaik force-pushed the audacity-3.6.4 branch 2 times, most recently from cecf0a4 to 72c8458 Compare October 17, 2024 17:15
@twaik
Copy link
Member Author

twaik commented Oct 17, 2024

Fixed a sqlite-related problem.

 $ audacity
 CANNOT LINK EXECUTABLE "audacity": cannot locate symbol "sqlite3_trace" referenced by "/system/lib64/libandroid_runtime.so"...

@twaik twaik removed the help wanted Help is wanted in order to solve the issue label Oct 18, 2024
@twaik twaik merged commit 6d7031a into master Oct 18, 2024
7 checks passed
@twaik twaik deleted the audacity-3.6.4 branch October 18, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants