Giter Site home page Giter Site logo

Comments (4)

gen2brain avatar gen2brain commented on August 16, 2024

I cannot reproduce this, It works for me with both ALSA and PulseAudio. It would maybe help if you compile with the ma_debug tag, and if you can send a gdb backtrace. And finally of course, if you can build and test the C example, both with the latest miniaudio version and with the version that is used in this repo.

from malgo.

santiagos01 avatar santiagos01 commented on August 16, 2024

Hmm, interesting... Sure, let me try to attach more info first here.


Compilation with `ma_debug`
: Failed to initialize WASAPI backend.
: Failed to initialize DirectSound backend.
: Failed to initialize WinMM backend.
: Failed to initialize Core Audio backend.
: Failed to initialize sndio backend.
: Failed to initialize audio(4) backend.
: Failed to initialize OSS backend.
: Attempting to initialize PulseAudio backend...
[miniaudio] Endian:  LE
[miniaudio] SSE2:    YES
[miniaudio] AVX2:    NO
[miniaudio] AVX512F: NO
[miniaudio] NEON:    NO
Recording...
[PulseAudio] Capture attr: maxlength=5760, tlength=1920, prebuf=-1, minreq=-1, fragsize=1920; periodSizeInFrames=480
[PulseAudio] Capture actual attr: maxlength=5760, tlength=1920, prebuf=-1, minreq=-1, fragsize=1920; periodSizeInFrames=480
[PulseAudio] Playback attr: maxlength=5292, tlength=1764, prebuf=-1, minreq=-1, fragsize=1764; periodSizeInFrames=441
[PulseAudio] Playback actual attr: maxlength=5292, tlength=1324, prebuf=888, minreq=440, fragsize=1764; internalPeriodSizeInFrames=0
INFO: [PulseAudio]
INFO:   USB Camera Digital Stereo (IEC958) (Capture)
INFO:     Format:      16-bit Signed Integer -> 16-bit Signed Integer
INFO:     Channels:    2 -> 1
INFO:     Sample Rate: 48000 -> 44100
INFO:     Buffer Size: 480*3 (1440)
INFO:     Conversion:
INFO:       Pre Format Conversion:    NO
INFO:       Post Format Conversion:   NO
INFO:       Channel Routing:          YES
INFO:       Resampling:               YES
INFO:       Passthrough:              NO
INFO:   Built-in Audio Analog Stereo (Playback)
INFO:     Format:      16-bit Signed Integer -> 16-bit Signed Integer
INFO:     Channels:    1 -> 2
INFO:     Sample Rate: 44100 -> 44100
INFO:     Buffer Size: 441*3 (1323)
INFO:     Conversion:
INFO:       Pre Format Conversion:    NO
INFO:       Post Format Conversion:   NO
INFO:       Channel Routing:          YES
INFO:       Resampling:               NO
INFO:       Passthrough:              NO
Press Enter to stop recording...

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f079bfff910 pc=0x7f08034dac99]

runtime stack:
runtime.throw({0x507017?, 0x1b7bba0?})
        /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x7ffc9b16ed28 sp=0x7ffc9b16ecf8 pc=0x43d59d
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:819 +0x369 fp=0x7ffc9b16ed78 sp=0x7ffc9b16ed28 pc=0x451709

goroutine 1 [syscall]:
runtime.cgocall(0x4a0500, 0xc00007bc08)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc00007bbe0 sp=0xc00007bba8 pc=0x40e03c
github.com/gen2brain/malgo._Cfunc_ma_device_uninit(0x1b7bb40)
        _cgo_gotypes.go:1595 +0x45 fp=0xc00007bc08 sp=0xc00007bbe0 pc=0x49bdc5
github.com/gen2brain/malgo.(*Device).Uninit.func1(0x4ef0a0?)
gdb backtrace
[Thread 0x7fff8fffe640 (LWP 208040) exited]

Thread 1 "capture" received signal SIGSEGV, Segmentation fault.
0x00007ffff7d2ac99 in ___pthread_detach (th=140735609300544) at ./nptl/pthread_detach.c:29
29      ./nptl/pthread_detach.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7d2ac99 in ___pthread_detach (th=140735609300544) at ./nptl/pthread_detach.c:29
#1  0x00000000004c103b in ma_thread_wait__posix (pThread=0x60acb8) at [REDACTED]/malgo/miniaudio.h:10482
#2  ma_thread_wait (pThread=0x60acb8) at [REDACTED]/malgo/miniaudio.h:10659
#3  ma_device_uninit (pDevice=0x60ab40) at [REDACTED]/malgo/miniaudio.h:33497
#4  ma_device_uninit (pDevice=0x60ab40) at [REDACTED]/malgo/miniaudio.h:33480
#5  0x0000000000468fe4 in runtime.asmcgocall () at /usr/local/go/src/runtime/asm_amd64.s:844
#6  0x000000c000030500 in ?? ()
#7  0x00007fffffffd9b8 in ?? ()
#8  0x0000000000447ef8 in runtime.exitsyscallfast.func1 () at /usr/local/go/src/runtime/proc.go:3869
#9  0x0000000000467169 in runtime.systemstack () at /usr/local/go/src/runtime/asm_amd64.s:492
#10 0x000000000046b8c5 in runtime.newproc (fn=0x1) at <autogenerated>:1
#11 0x00000000005b8ec0 in runtime[scavenger] ()
#12 0x0000000000000001 in ?? ()
#13 0x0000000000467065 in runtime.mstart () at /usr/local/go/src/runtime/asm_amd64.s:390
#14 0x0000000000466fef in runtime.rt0_go () at /usr/local/go/src/runtime/asm_amd64.s:354
#15 0x00007fff00000001 in ?? ()
#16 0x00007fffffffdb38 in ?? ()
#17 0x0000000000001000 in ?? ()
#18 0x0000000000000001 in ?? ()
#19 0x00007fffffffdb38 in ?? ()
#20 0x00007ffff7cbed90 in __libc_start_call_main (main=0x466ea0 <main>, main@entry=0x0, argc=1, argc@entry=494544, argv=0x7fffffffdb38, argv@entry=0x0) at ../sysdeps/nptl/libc_start_call_main.h:58
#21 0x00007ffff7cbee40 in __libc_start_main_impl (main=0x0, argc=494544, argv=0x0, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdb28)
    at ../csu/libc-start.c:392
#22 0x000000000040b575 in _start ()

Early hypothesis based on the gdb backtrace:

Noticed that the ma_thread_wait__posix in the version being used in this repo (v0.10.35) is as follows:

static void ma_thread_wait__posix(ma_thread* pThread)
{
    pthread_join(*pThread, NULL);
    pthread_detach(*pThread);
}

Meanwhile, in the current latest version (v0.11.9), it is slightly different (i.e., no detach call, which caused SIGSEGV for me):

static void ma_thread_wait__posix(ma_thread* pThread)
{
    pthread_join((pthread_t)*pThread, NULL);
}

Sorry I haven't had the chance to build and test with the latest miniaudio version at the moment since I think it requires quite some adjustments (I encountered some compile errors when I simply tried to update the miniaudio.h). Maybe I can try to dig into that later.

from malgo.

gen2brain avatar gen2brain commented on August 16, 2024

Thanks, it looks like it is related to some bug fixed in newer versions. There were some changes in callbacks in newer versions so not sure when will I have time to update. To confirm that this is the problem, you can pick the capture example from https://github.com/mackron/miniaudio/tree/199d6a7875b4288af6a7b615367c8fdc2019b03c. It is not exactly the same as in Go, but they both call device Uninit().

from malgo.

santiagos01 avatar santiagos01 commented on August 16, 2024

Sorry for the late response -- had been occupied with other things in the past two weeks.

And yes, I managed to confirm that it was indeed the problem. Just created a PR to bump the miniaudio.h version.
It seems to have resolved the issue in my local. Could you help to take a look? Thanks!

from malgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.