Open GioF71 opened 6 months ago
I've prepared a docker image and a sample configuration here. Maybe it could be useful for other users. Cheers
@GioF71 Very cool. I'd like to add it as a recommendation to the mopidy-tidal readme, if you don't mind.
This will come in handy, as I have an ancient python version 3.8 on my laptop at work, making it difficult to install mopidy without workarounds.
Of course! It's a pleasure
I just noticed that I this morning I forgot to trigger the pipeline that pushes the images to docker hub. It's running now, so these will include the latest version 0.3.6
Great, it worked with some smaller hiccups.
docker-compose is apparently deprecated so I needed to use docker compose instead.
Needed to use AUDIO_OUTPUT=autoaudiosink
(or alsasink device=hw:3,0
for SMSL M300SE) instead of =default
, otherwise gstreamer would complain: Failed to create audio output "default": gst_parse_error: no element "default
Needed to setup pulseaudio slightly differently, otherwise I got errors when starting playback, as listed below:
alsasink device=hw:3,0
Could not open audio device for playback. Device is being used by another application.
For the above error, I just needed to make sure the host system was not using the DAC.
autoaudiosink
Failed to create secure directory (//.config/pulse): No such file or directory
Failed to create secure directory (//.config/pulse): No such file or directory
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
To fix the above error, I added the following env and volume parameters, as per https://comp0016-team-24.github.io/dev/problem-solving/2020/10/30/passing-audio-into-docker.html.
For alsasink device=hw:3,0
, the above fix does not appear necessary. I also tried using the DAC through autoaudiosink and it worked but only at the default bitrate, hence the need to set device=..
directly.
I have not tested, but perhaps the missing pulse parameters was also the reason setting =default did not work for me?
The resulting docker-compose.yml:
services:
mopidy:
image: ${MOPIDY_IMAGE_REPO:-docker.io}/giof71/mopidy:${MOPIDY_IMAGE_TAG:-latest}
container_name: mopidy-tidal
user: "${PUID}:${AUDIO_GID}"
devices:
- /dev/snd:/dev/snd
environment:
- AUDIO_OUTPUT=${AUDIO_OUTPUT:-default}
- TIDAL_ENABLED=${TIDAL_ENABLED:-yes}
- TIDAL_QUALITY=${TIDAL_QUALITY:-LOSSLESS}
- TIDAL_AUTH_METHOD=${TIDAL_AUTH_METHOD:-OAUTH}
- TIDAL_LOGIN_SERVER_PORT=${TIDAL_LOGIN_SERVER_PORT:-8989}
- PULSE_SERVER=unix:/run/user/${PUID}/pulse/native
ports:
- ${MOPIDY_PORT:-6680}:6680
- ${TIDAL_LOGIN_SERVER_PORT:-8989}:${TIDAL_LOGIN_SERVER_PORT:-8989}
volumes:
- ./config:/config
- ./cache:/cache
- ./data:/data
- ./dconf:/.cache/dconf
- /run/user/${PUID}/pulse/native:/run/user/${PUID}/pulse/native
- ./config/pulse/cookie:/root/.config/pulse/cookie
restart: always
Great work, nonetheless! This was very easy to setup and does not interfere with my local python installation.
Great, it worked with some smaller hiccups.
- docker-compose is apparently deprecated so I needed to use docker compose instead.
Sure! most people still have docker-compose installed from what I have observed from the issues on my repos... but yes, you are right, and this is worth at least a mention in the documentation, like "you might not have docker-compose, but you might have the compose plugin for docker" ... or something similar.
Needed to use
AUDIO_OUTPUT=autoaudiosink
(oralsasink device=hw:3,0
for SMSL M300SE) instead of =default
, otherwise gstreamer would complain:Failed to create audio output "default": gst_parse_error: no element "default
Needed to setup pulseaudio slightly differently, otherwise I got errors when starting playback, as listed below:
alsasink device=hw:3,0
Could not open audio device for playback. Device is being used by another application.
For the above error, I just needed to make sure the host system was not using the DAC.
autoaudiosink
Failed to create secure directory (//.config/pulse): No such file or directory Failed to create secure directory (//.config/pulse): No such file or directory AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
To fix the above error, I added the following env and volume parameters, as per https://comp0016-team-24.github.io/dev/problem-solving/2020/10/30/passing-audio-into-docker.html.
For
alsasink device=hw:3,0
, the above fix does not appear necessary. I also tried using the DAC through autoaudiosink and it worked but only at the default bitrate, hence the need toset device=..
directly.I have not tested, but perhaps the missing pulse parameters was also the reason setting =default did not work for me?
Unfortunately I did not test a lot of combinations with this container, which btw is only a few days old now. I also didn't try pulseaudio mode, which I usually have done for my audio containers. I need some time to complete this stuff.
- Enabled all volumes (cache, data, dconf) to allow loading tidal session at startup and reloading cached images etc.
The resulting docker-compose.yml:
services: mopidy: image: ${MOPIDY_IMAGE_REPO:-docker.io}/giof71/mopidy:${MOPIDY_IMAGE_TAG:-latest} container_name: mopidy-tidal user: "${PUID}:${AUDIO_GID}" devices: - /dev/snd:/dev/snd environment: - AUDIO_OUTPUT=${AUDIO_OUTPUT:-default} - TIDAL_ENABLED=${TIDAL_ENABLED:-yes} - TIDAL_QUALITY=${TIDAL_QUALITY:-LOSSLESS} - TIDAL_AUTH_METHOD=${TIDAL_AUTH_METHOD:-OAUTH} - TIDAL_LOGIN_SERVER_PORT=${TIDAL_LOGIN_SERVER_PORT:-8989} - PULSE_SERVER=unix:/run/user/${PUID}/pulse/native ports: - ${MOPIDY_PORT:-6680}:6680 - ${TIDAL_LOGIN_SERVER_PORT:-8989}:${TIDAL_LOGIN_SERVER_PORT:-8989} volumes: - ./config:/config - ./cache:/cache - ./data:/data - ./dconf:/.cache/dconf - /run/user/${PUID}/pulse/native:/run/user/${PUID}/pulse/native - ./config/pulse/cookie:/root/.config/pulse/cookie restart: always
Great work, nonetheless! This was very easy to setup and does not interfere with my local python installation.
Good to know about that PULSE_SERVER
variable, I didn't know about that. I will try and anyway will update the documentation.
Thank you very much for testing and giving feedback. Feel free to open issues and feature requests. For example, does spotify still work on mopidy for you? I couldn't make it work, I tried everything I found without any success. I keep getting URI issues but I didn't keep track of the error logs unfortunately, mostly because that plugin seems dead to me, but I would be happy to be corrected.
About this:
Could not open audio device for playback. Device is being used by another application.
it is expected when trying to access an alsa device when pulseaudio is running. A simple fix is telling pulseaudio to ignore the device. Look at the Xmos device (last of the list) which is "off" using PulseAudio Volume Control
A quick update, I made some changes to the docker-container to fix an issue that occurred after reboot. With the previous config, my pulseaudio server would not be able to start, resulting in no audio on the host system.
---
version: "3.3"
services:
mopidy:
image: ${MOPIDY_IMAGE_REPO:-docker.io}/giof71/mopidy:${MOPIDY_IMAGE_TAG:-latest}
container_name: mopidy-tidal
user: "${PUID}:${AUDIO_GID}"
devices:
- /dev/snd:/dev/snd
environment:
- AUDIO_OUTPUT=${AUDIO_OUTPUT:-default}
- TIDAL_ENABLED=${TIDAL_ENABLED:-yes}
- TIDAL_QUALITY=${TIDAL_QUALITY:-LOSSLESS}
- TIDAL_AUTH_METHOD=${TIDAL_AUTH_METHOD:-OAUTH}
- TIDAL_LOGIN_SERVER_PORT=${TIDAL_LOGIN_SERVER_PORT:-8989}
# set path to pulseaudio socket as specified in -v
- PULSE_SERVER=unix:/run/user/${PUID}/pulse/native
# set path to PULSE_COOKIE as specified in -v
- PULSE_COOKIE=/run/pulse/cookie
ports:
- ${MOPIDY_PORT:-6680}:6680
- ${TIDAL_LOGIN_SERVER_PORT:-8989}:${TIDAL_LOGIN_SERVER_PORT:-8989}
volumes:
- ./config:/config
- ./cache:/cache
- ./data:/data
- ./dconf:/.cache/dconf
- /run/user/${PUID}/pulse/native:/run/user/${PUID}/pulse/native
- /home/${USER}/.config/pulse/cookie:/run/pulse/cookie
restart: always
A simple fix is telling pulseaudio to ignore the device
Good tip, otherwise the USB DAC would always be set as the default audio device after reboot.
Does spotify still work on mopidy for you?
I have yet to test it, as I never use Spotify but the SO prefers it due to better(?) playlists. Anyways I will continue working on the spotify->tidal remapper when I have time, as described in this PR https://github.com/tehkillerbee/mopidy-tidal/pull/34
I can also add a MR if you would like the updated docker-compose file. It will probably need a little more testing and/or documentation so it is clear how I ended up at that configuration.
A quick update, I made some changes to the docker-container to fix an issue that occurred after reboot. With the previous config, my pulseaudio server would not be able to start, resulting in no audio on the host system.
--- version: "3.3" services: mopidy: image: ${MOPIDY_IMAGE_REPO:-docker.io}/giof71/mopidy:${MOPIDY_IMAGE_TAG:-latest} container_name: mopidy-tidal user: "${PUID}:${AUDIO_GID}" devices: - /dev/snd:/dev/snd environment: - AUDIO_OUTPUT=${AUDIO_OUTPUT:-default} - TIDAL_ENABLED=${TIDAL_ENABLED:-yes} - TIDAL_QUALITY=${TIDAL_QUALITY:-LOSSLESS} - TIDAL_AUTH_METHOD=${TIDAL_AUTH_METHOD:-OAUTH} - TIDAL_LOGIN_SERVER_PORT=${TIDAL_LOGIN_SERVER_PORT:-8989} # set path to pulseaudio socket as specified in -v - PULSE_SERVER=unix:/run/user/${PUID}/pulse/native # set path to PULSE_COOKIE as specified in -v - PULSE_COOKIE=/run/pulse/cookie ports: - ${MOPIDY_PORT:-6680}:6680 - ${TIDAL_LOGIN_SERVER_PORT:-8989}:${TIDAL_LOGIN_SERVER_PORT:-8989} volumes: - ./config:/config - ./cache:/cache - ./data:/data - ./dconf:/.cache/dconf - /run/user/${PUID}/pulse/native:/run/user/${PUID}/pulse/native - /home/${USER}/.config/pulse/cookie:/run/pulse/cookie restart: always
Ok that is something I usually do inside the startup script of some of my containers. See here So when starting the container I only need to mount /run/user/1000/pulse like here But again, this is the result of work from some time ago, and anyway it can be improved. Like my bash skills
Thank you! you're the man! :-) Who needs shady tidal-connect binaries anymore?