Bettehem / ts3-musicbot

TS3 Music Bot with Spotify, YouTube, SoundCloud and Bandcamp support!
https://gitlab.com/Bettehem/ts3-musicbot
GNU General Public License v3.0
51 stars 11 forks source link

Fails to set up audio #7

Closed Zauberbutter closed 1 year ago

Zauberbutter commented 1 year ago

I successfully installed the bot on a server running Ubuntu 20.04 with the jar which was provided in https://gitlab.com/Bettehem/ts3-musicbot/-/issues/24.

I set up pulse with the tutorial from: https://askubuntu.com/questions/28176/how-do-i-run-pulseaudio-in-a-headless-server-installation

The output of pacmd list-sinks gives:

1 sink(s) available.
  * index: 0
    name: <auto_null>
    driver: <module-null-sink.c>
    flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: IDLE
    suspend cause: (none)
    priority: 1000
    volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 2136,23 ms
    max request: 344 KiB
    max rewind: 344 KiB
    monitor source: 0
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 2000,00 ms; range is 0,50 .. 2000,00 ms
    module: 10
    properties:
        device.description = "Dummy Output"
        device.class = "abstract"
        device.icon_name = "audio-card"

So I think this looks fine. But when I start the bot it restarts constantly:

…
Waiting for TeamSpeak to connect to server...
Getting server name...
Server name: TS3Server
Setting up audio.
TeamSpeak's audio is broken, restarting client.
…

Thank you for creating a TS3 Audiobot with Spotify support! I look forward to using it.

Zauberbutter commented 1 year ago

Looked into the source. The output of pactl list sink-inputs is:

Sink Input #5
    Driver: protocol-native.c
    Owner Module: 7
    Client: 9
    Sink: 0
    Sample Specification: s16le 2ch 48000Hz
    Channel Map: front-left,front-right
    Format: pcm, format.sample_format = "\"s16le\""  format.rate = "48000"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
    Corked: no
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Buffer Latency: 0 usec
    Sink Latency: 929 usec
    Resample method: n/a
    Properties:
        media.name = "ts.pa.dummy.playbackdefaultrender1"
        application.name = "TeamSpeak"
        native-protocol.peer = "UNIX socket client"
        native-protocol.version = "33"
        media.role = "phone"
        media.icon_name = "teamspeak"
        application.process.id = "1189835"
        application.process.user = "tsbot"
        application.process.host = "ferberite"
        application.process.binary = "ts3client_linux_amd64"
        application.language = "de_DE.UTF-8"
        window.x11.display = ":100"
        application.process.machine_id = "257dce953b6d4eeca01f43b5b325e900"
        module-stream-restore.id = "sink-input-by-media-role:phone"

And the function audioIsWorking is checking for application.name == "TeamSpeak3" which is missing the 3 in my case.

Bettehem commented 1 year ago

Hi, thanks for trying out the bot! It clearly still has issues when running on Ubuntu, so these issue reports are very helpful.

I haven't yet had the time to make a new release of the bot, so I'm glad you found the jar in that issue you mentioned. This seems like an issue I haven't encountered before, but I don't know if it has something to do with the way you set up pulseaudio? Pulseaudio normally runs in userspace, so I don't know if the instructions in that askubuntu page are correct. After you have pulseaudio installed, you should be able to start it by just running pulseaudio --start and no modifications should be needed in any pulseaudio's configuration files either, but with the latest jar, the bot should be able to start pulseaudio automatically too if it isn't already running.

If you could, please try running teamspeak3 manually and then check if you are able to see it in pactl output.

To run teamspeak 3 manually in headless mode, you can run a command like this: xvfb-run teamspeak3 ts3server://$SERVER_ADDRESS?port=$SERVER_PORT&nickname=$NICKNAME&password=$SERVER_PASSWORD Just replace $SERVER_ADDRESS, $SERVER_PORT, $NICKNAME and $SERVER_PASSWORD with the correct values.

Then with teamspeak running, run this pactl command and check if you can see a sink input with TeamSpeak3 as the application name: pactl list sink-inputs Or if you want, you can just grep it directly from the command's output: pactl list sink-inputs | grep 'application.name = "TeamSpeak3"' This command should output application.name = "TeamSpeak3" if it exists, and it won't output anything if it doesn't.

Bettehem commented 1 year ago

And the function audioIsWorking is checking for application.name == "TeamSpeak3" which is missing the 3 in my case.

Ohhh you were fast, great find! I'll fix that

Bettehem commented 1 year ago

Alright the bug should be fixed with the latest commit and here's the .jar file if you don't want to build it yourself: ts3-musicbot.zip

GitHub doesn't allow uploading .jar files directly, so I put it inside a .zip file

Zauberbutter commented 1 year ago

Thank you, I'll try it in the next minutes.

Zauberbutter commented 1 year ago

Looks fine! The issue is resolved.

FYI: To use a command i had to install dbus-x11. And the bot fails to start ncspot. If I have more time I'll look into that.

Thank you for providing a fix so quickly!

Bettehem commented 1 year ago

Ok, nice that it fixed your problem. I recommend creating future issues on the gitlab page instead of here, since that is the main page for this bot.

Is the command you are talking about something that you need with running the musicbot? Could you provide more details about this? If it's some dependency that is needed, I need to update the installation guide then

Zauberbutter commented 1 year ago

Is the command you are talking about something that you need with running the musicbot?

Yes, there was a error when using the commands to play music. I wonder why the dbus-interface isn't a dependency of pulse. If you want I can reproduce the error.


Did you ever take a look at https://github.com/Splamy/TS3AudioBot? It uses a virtual TS3 client so one don't have to install the TS3 client itself. Also I wonder how it plays music without pulse. Maybe its worth to look into that. In a few weeks I have more time, so if you want I can help you with some things.

Bettehem commented 1 year ago

I have seen that project but haven't really studied how it works, but I guess if it doesn't use pulseaudio it works with alsa directly. I have a WIP internal tsclient in the musicbot but it still has some issues and no audio output/input yet so for now the official client provides the best experience. And sure, help is always appreciated! :)