[Plugin] pirate audio

I think it’s broken, probably tied to the upgrade of socketio in this release.

It looks like it’s not able to establish the socketio connection.

Hello everyone.
New here but been using volumio for a while on a Zero W with a no-name DAC.
I had a Pirate Audio line out module and found out about this plugin. THANKS!
Install latest 3.695 on Pi3B with plugin version 0.1.1.
I have audio out, but the screen is stuck on “please wait” message.
Happy to help troubleshoot. I do have Pi3B, 4B and 5 available if needed

Interesting… Same here with RPi zero 2w.

@tario what do you suggest?

https://logs.volumio.org/volumio/fnGhEPU.html

I confirm the service is failing to start. Appears to be from an error in running display.py

Jun 04 17:53:18 pi3-volumio volumio[648]: File “/data/plugins/system_hardware/pirateaudio/display.py”, line 310, in
Jun 04 17:53:18 pi3-volumio volumio[648]: SOCKETIO = SocketIO(‘localhost’, 3000)
Jun 04 17:53:18 pi3-volumio volumio[648]: File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 353, in init
Jun 04 17:53:18 pi3-volumio volumio[648]: resource, hurry_interval_in_seconds, **kw)
Jun 04 17:53:18 pi3-volumio volumio[648]: File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 54, in init
Jun 04 17:53:18 pi3-volumio volumio[648]: self._transport
Jun 04 17:53:18 pi3-volumio volumio[648]: File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 62, in _transport
Jun 04 17:53:18 pi3-volumio volumio[648]: self._engineIO_session = self._get_engineIO_session()
Jun 04 17:53:18 pi3-volumio volumio[648]: File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 76, in _get_engineIO_session
Jun 04 17:53:18 pi3-volumio volumio[648]: transport.recv_packet())
Jun 04 17:53:18 pi3-volumio volumio[648]: StopIteration

manually starting service via SSH
systemctl start pirateaudio

Screen flashes back to same volumio logo with on top. Flashed 5 times and stop.

Downgraded volumio from 3.695 to 3.631. Pirate-Audio plugin works with no issues.

I don’t know enough about SocketIO but I’m wondering if with the upgrade of SocketIO to 2.3.0 in the latest upgrade of volumio, something changed on the protocol and the python library used for talking with it does no longer work properly (it was last updated in 2016).

Did some testing by directly changing display.py to use python-socketio · PyPI version 4.x (because according to the table on that library, the javascript version 2.3.0 is only supported by the older 4.x version). With this it works and the changes are relatively small and it seems to work fine.

@tario can you explain how you did that ?

I created a PR [PIRATEAUDIO] switch to use python-socketio by tarioch · Pull Request #325 · volumio/volumio-plugins-sources · GitHub if someone can test this it would be great as I’m not using the plugin as is.

@tario Sorry for the noob question but how can I test that ? Is there some command line to enter by ssh on the volumio setup ?

Probably something like this should work, ssh onto the device and then do

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/22edd204325ff0befe908dcef9111ec5882901ea/pirateaudio/display.py

@tario It worked ! :grin:

I cant get to it today or tomorrow but should be able to test this over the weekend.

@tario do I understand you modified the plugin to call for the older version of the socketio library?

I quickly looked it up and it appears this library had not been updated for a long time?? Why the change?

@SimpleSmarts I just noticed that the release notes Volumio Changelog contain this

Update socket.io to 2.3.0

And looking at the original library (socketIO-client) which was used, wasn’t upgraded since 2016, I guessed there might have been a change in the protocol. That’s how I then found the “new” library (python-socketio) which is maintained. First test didn’t work, but then I saw a table on that new library which indicated which version of the library to use with which version of the javascript part, as volumio uses 2.3.0 (don’t ask my why they use an old, outdated version of this), I used the matching version.

1 Like

Thanks very much @tario for looking into this and providing an excellent solution! This worked for me, however the patched file throws an error for me on startup every time which relates to:

    File "/data/plugins/miscellanea/pirateaudio/display.py", line 139, in connect
    SOCKETIO.emit('getState', '', on_push_state)
NameError: name 'on_push_state' is not defined

Which I think is trying to get the volumio state at pirateaudio startup. As a result, the screen is blank to start. When I subsequently press pause then play, it updates the display correctly, I’m not an expert on why on_push_state is not accessible here, is this something that is fixable?

Fixed, just get the new file from https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f667de7567e9b9ad03c72cfb3bf5411b8b387e59/pirateaudio/display.py

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f667de7567e9b9ad03c72cfb3bf5411b8b387e59/pirateaudio/display.py
1 Like

Big thanks for the explanation. I’m a harware guy, I can test and get around a bit of code so this help learning.
I just noticed now you moved to a different, maintained lib python-socketio, great.

Is the pirate-audio plugin maintained? I saw your PR on Github.

I will test this weekend.

What a star, that’s great! Cheers @tario

I’ve found some more problems in the Options-Menue (upper right button) with display.py -
patch.txt (1.2 KB)

  • choosing sources did not work
  • choosing next/previous did not work

I got that fixed by applying following patch (attached) to your file:

--- display.py.orig	2024-06-07 18:19:07.000000000 +0200
+++ display.py	2024-06-07 18:23:18.000000000 +0200
@@ -607,14 +607,14 @@
             return
         #elif NAV_ARRAY_TYPE[NAV_DICT['MARKER']] == 'prevnext':  # v.0.0.4
         if NAV_ARRAY_TYPE[NAV_DICT['MARKER']] == 'prevnext':  # v.0.0.4
-            SOCKETIO.emit('getQueue', on_push_queue)  # refresh variables of queue
+            SOCKETIO.emit('getQueue', callback=on_push_queue)  # refresh variables of queue
             VOLUMIO_DICT['MODE'] = 'prevnext'  # optimieren wg. global bzw. wird das überhaupt benötigt
             display_stuff(IMAGE_DICT['BG_DEFAULT'], [''.join([str(VOLUMIO_DICT['POSITION'] + 1), '/', str(LEN_QUEUE)]), OBJ_TRANS['DISPLAY']['PREVNEXT'], TITLE_QUEUE[VOLUMIO_DICT['POSITION']]], 1, 0, 'seek')
             return
         # only get called if no return before was executed
         #else:  # browsesource
         reset_variable('navigation')
-        SOCKETIO.emit('getBrowseSources', '', on_push_browsesources)
+        SOCKETIO.emit('getBrowseSources', callback=on_push_browsesources)
     #else:
     if mode not in ['player', 'navigation', 'menu']:
         reset_variable('player')


Thank you, updated (don’t need to have those handlers as they are already globally registered)

https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f0b67728aec403a6be8d395ee9de2b77d7a0518e/pirateaudio/display.py

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f0b67728aec403a6be8d395ee9de2b77d7a0518e/pirateaudio/display.py
1 Like