miegl / PiFmAdv

Advanced Raspberry Pi FM transmitter with RDS encoding
GNU General Public License v3.0
491 stars 84 forks source link

Audio frezzes after a few seconds #22

Closed Pielke closed 6 years ago

Pielke commented 6 years ago

Hi, when I start the Audio, it just works fine. Unless I exit the Terminal Window or after a few seconds. Then it happens, that the Audio just freezes, and the whole System just seems to collide...

miegl commented 6 years ago

Well, obviously by closing your terminal the application exits too. I need better report in order to fix the issue you are having.

Pielke commented 6 years ago

I start the program like any other version of the PiFm based programs... like sudo ./pi_fm_adv --audio sound.wav -- freq 107.9 and so on. After starting the program it works only for a few seconds, then the audio stops playing but the text in the terminal stays. Then it lasts a few seconds after pressing ctrl +c to kill the process. Same thing, when entering (not closing the main terminal) an other terminal e.g. for using the ta and rt functions.

miegl commented 6 years ago

That looks like a issue with gpu and pllc... Try exiting out of gui and try again please.

Pielke commented 6 years ago

Do you mean to start the program in cmd mode of the pi?

Pielke commented 6 years ago

Same thing... Audio just crashes or stucks in an infinite loop of just a few milliseconds

miegl commented 6 years ago

Please post the output of uname -a

Pielke commented 6 years ago

output of uname -a: Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 12:19:23 GMT 2017 armv7l GNU/Linux

miegl commented 6 years ago

Hm, interesting. It's probably kernel (idk for sure) related. However, PiFmAdv (as of now) works fine under the latest Arch arm and Ubuntu server. So, if possible, try updating your distro/kernel.

Part of the code has been changed to work on latest distros though. I've commented out some parts of the code. So in order to get PiFmAdv running under your system, you can try making these changes: In pi_fm_adv.c: Remove // on lines 282, 283, 284, 285, 295, 296, 310 That should be enough to get it working for you. I don't know why some distros (or kernels) require these additional lines to get PiFmAdv working but the current version works fine under latest Raspberry Pi kernel.

Pielke commented 6 years ago

Thank you, I will try it as soon as possible...

hectorperalta96 commented 6 years ago

Hi, I have the same problem. Audio works fine for few seconds and then it stops playing. The text stays on the terminal and the carrier stays too. I don't have any GUI installed on the Pi. I tried to remove // on lines you said but still having the same problem. I'm using raspbian and the output of my uname -a is: Linux raspberrypi 4.9.79-v7+ #1086 SMP Wed Jan 31 18:03:34 GMT 2018 armv7l GNU/Linux

miegl commented 6 years ago

Well, this looks like a complicated issue. I've noticed the same problem, but I just adjusted the code everytime it broke. (I'm using Arch Linux ARM on rpi2) I think this has to do with kernel, but I'm not entirely sure. Any suggestions are welcome.

miegl commented 6 years ago

So, somehow this affected me too and the desired transmission last only for a few seconds. Then the frequency completely shifts away and creates horrible mess. It's really weird, cause it worked for me for very long time and now it suddenly doesnt...

Pielke commented 6 years ago

I would guess, that this problem is caused by audio processing. Different wav's have different playing durations before the system collapses. Can it bei the caching of the Audio/ wave-data?

miegl commented 6 years ago

So after a bit of testing I discovered that the "stops working after few seconds" problem is caused by the recent raspberry pi firmware. raspberrypi-firmware-20180111-1 (on Arch Linux ARM) works well, but raspberrypi-firmware-20180207-1 just doesn't work with PiFmAdv (and I've spent some time trying to get it to work). So yeah, I don't know how to fix the issue with recent raspberry pi firmware. For now I just recommend using the older rapsberry pi firmware.

Pielke commented 6 years ago

Thank you for your response! Where can I get the older Firmware Versions from?

miegl commented 6 years ago

But I didn't quite fix the issue. Even with the older firmware the sound is "cracking". And the gpu/pllc will still switch to a different freq after some time. The worst part about this is that it happened to my Raspberry Pi 2 randomly, not package upgrades etc. It was working fine, and now it's just not... I don't know, the PLLC method is far better quality-wise but it just doesn't work as good.

Pielke commented 6 years ago

We just need it to work for a short time Period... So this would be OK. But I don't know how to download the older Firmware Version.

TheSneakySniper commented 6 years ago

@Miegl

Hm, interesting. It's probably kernel (idk for sure) related. However, PiFmAdv (as of now) works fine under the latest Arch arm and Ubuntu server. So, if possible, try updating your distro/kernel.

What version of Ubuntu server is confirmed working with the raspberry pi?

hectorperalta96 commented 6 years ago

As far as I'm using the last rpi firmware, older versions of PiFmAdv still working for me, for example, this one: https://github.com/Miegl/PiFmAdv/tree/f2968ca362c0a3dbfea31a1484a4063bc9176717

No audio freezing.

miegl commented 6 years ago

@hectorperalta96 thats because it was using PLLD, which just isnt as problematic. I might add PLLD method back alongside PLLC.

miegl commented 6 years ago

@TheSneakySniper Ubuntu server 16.04.4 is working fine

TippyLion28 commented 6 years ago

Dunno if this is related but the SD activity light on my Pi goes out immediately once the audio stops

TippyLion28 commented 6 years ago

I might just be going insane but it seems mounting all filesystems as read-only using Alt-SysRq+U fixes everything after running the program 1-2 more times. What the hell xD

Niall7459 commented 6 years ago

you could try sudo rmmod w1-gpio That fixed the transmission stopping for me.

Is it just silent or goes static?

miegl commented 6 years ago

Should be fixed. Start a new issue if necessary.