Skip to content
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

Example 3 crashes #83

Open
vale-max opened this issue Jun 10, 2022 · 13 comments
Open

Example 3 crashes #83

vale-max opened this issue Jun 10, 2022 · 13 comments

Comments

@vale-max
Copy link
Contributor

Hello Jvan,
dab-example-3, compiled from my fork of your repo, is randomly crashing at startup:
Command used is:
/dab-rtlsdr-3 -S 5241 -C 12A >/dev/null

we try to start program Virgin Radio
protection handler is eep_protection
we have now DAB+
        startaddress    = 690
        length          = 36
        subChId         = 19
        protection      = 2
        bitrate         = 48
terminate called without an active exception
Aborted (core dumped)

most of the times it works, sometimes crashes.
The stack backtrace is:

#0  __pthread_kill_implementation (threadid=547914510496, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x0000007f9e2327e4 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x0000007f9e1eb6fc in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x0000007f9e1d78b0 in __GI_abort () at abort.c:79
#4  0x0000007f9e4f32d4 in __gnu_cxx::__verbose_terminate_handler () at /usr/src/debug/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#5  0x0000007f9e4f065c in __cxxabiv1::__terminate (handler=<optimized out>) at /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#6  0x0000007f9e4f06e0 in std::terminate () at /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#7  0x0000005577c551d8 in std::__terminate () at /usr/include/c++/12.1.0/aarch64-unknown-linux-gnu/bits/c++config.h:312
#8  std::thread::operator= (__t=..., this=<optimized out>) at /usr/include/c++/12.1.0/bits/std_thread.h:164
#9  streamer::restart (this=0x7f9c20c010) at /root/dab-cmdline/example-3/streamer.cpp:58
#10 0x0000005577c54080 in pcmHandler (buffer=0x7f9be54100, size=3840, rate=<optimized out>, isStereo=<optimized out>, ctx=<optimized out>)
    at /root/dab-cmdline/example-3/main.cpp:200
#11 0x0000005577c7ca6c in faadDecoder::output (rate=48000, isStereo=<optimized out>, size=3840, buffer=<optimized out>, this=0x7f988027a0)
    at /root/dab-cmdline/example-3/../library/includes/backend/audio/faad-decoder.h:56
#12 faadDecoder::MP42PCM (this=this@entry=0x7f988027a0, sp=sp@entry=0x7f923fdc60,
    buffer=buffer@entry=0x7f923fdde0 "\200)\030I\233\363\034\236\254i\237\321\262\365,Y!\376nD\221O8\321\035\333v<:", bufferLength=bufferLength@entry=203)
    at /root/dab-cmdline/example-3/../library/includes/backend/audio/faad-decoder.h:169
#13 0x0000005577c7a0ec in mp4Processor::processSuperframe (this=this@entry=0x7f98802480, frameBytes=<optimized out>, base=<optimized out>)
    at /root/dab-cmdline/library/src/backend/audio/mp4processor.cpp:333
#14 0x0000005577c7af10 in mp4Processor::addtoFrame (this=0x7f98802480, V=<optimized out>) at /root/dab-cmdline/library/src/backend/audio/mp4processor.cpp:177
#15 0x0000005577c75f8c in audioBackend::processSegment (this=this@entry=0x7f9a802a80, Data=<optimized out>) at /root/dab-cmdline/library/src/backend/audio-backend.cpp:162
#16 0x0000005577c761f8 in audioBackend::run (this=0x7f9a802a80) at /root/dab-cmdline/library/src/backend/audio-backend.cpp:171
#17 0x0000007f9e5278ac in std::execute_native_thread_routine (__p=0x7f9c20ea70) at /usr/src/debug/gcc/libstdc++-v3/src/c++11/thread.cc:82
#18 0x0000007f9e230aec in start_thread (arg=0x7fd0e21bdf) at pthread_create.c:442
#19 0x0000007f9e29a5dc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 10, 2022 via email

@vale-max
Copy link
Contributor Author

I'm not sure what the streamer does, I use the code to output to a pipe that at the other end has ffmpeg processing it and spitting it out in aac and rtsp format to an rtsp server

dab-rtlsdr-3 -S $1 -C $2 > $MYPIPE &
DABPID=$!
ffmpeg -re -stream_loop -1 -ar 48000 -ac 2 -f s16le  -i $MYPIPE -vn -c:a aac -b:a 160k -metadata title="Dab radio" -f rtsp rtsp://localhost:$3/$4 >/dev/null 2>&1 &

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 11, 2022 via email

@vale-max
Copy link
Contributor Author

I tried to compile example-3 commenting out "add_definitions (-DSTREAMER_OUTPUT)" in CMakeLists.txt, I hope I understood correctly how to disable the streamer.
It didn't crash so far and the audio seems to work. I guess it would notice some difference in case of weak signals, right?

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 13, 2022 via email

@vale-max
Copy link
Contributor Author

vale-max commented Jun 14, 2022 via email

@vale-max
Copy link
Contributor Author

vale-max commented Jun 17, 2022

Another thing I noticed is that in the version compiled with the streamer the audio starts, then there's a moment of silence an then it starts playing uninterrupted (and keeps playing for hours always, no crashes once it starts)

The version compiled without the streamer starts reproducing audio without the short interruption at the beginning

When the version with streamer crashes it crashes before reproducing anything.

I did the tests piping the output to aplay:
dab-rtlsdr-3 -S 5241 -C 12A|aplay -D default:CARD=AUDIO -c 2 -f S16_LE -r 48000 -

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 17, 2022 via email

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 17, 2022 via email

@vale-max
Copy link
Contributor Author

The crash happens only when the streamer is enabled in the configuration. Happens sometimes, i.e. not always, but if it happens it is just after starting up, before ANY sound is heard.
When the streamer is in the configuration and it does not crash, when it starts it outputs a moment of audio, then a moment of silence then the audio starts and goes on playing without issues.

When the streamer is not configured at compile time the example never crashes and there is no moment of silence after sound starts.

I tried to produce an audio sample writing to file, but the sample produced by the version with the streamer is sound-silence-sound while when the output is piped to aplay or to the rtsp-simple-server the audio is ok

soundsamples.zip

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 18, 2022 via email

@vale-max
Copy link
Contributor Author

Hello Jvan,
I tried the new code with streamer enabled, started it several times and it never crashed, also if I redirect to file the audio has about 6 seconds of silence at the beginning (which I guess is the time it takes to initialize all the SDR stuff) but then it is ok, not fragmented as the previous version

@JvanKatwijk
Copy link
Owner

JvanKatwijk commented Jun 20, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants