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

Audio lag with Mopidy #5

Open
dhtek opened this issue Aug 17, 2018 · 9 comments
Open

Audio lag with Mopidy #5

dhtek opened this issue Aug 17, 2018 · 9 comments

Comments

@dhtek
Copy link

dhtek commented Aug 17, 2018

Hello,

First of all, thanks for your job ! It's really great what are you doing...

By the way, I got an lag when I listen to music from mopidy (tunein, soundcloud, and local media) but if I listen to using the library mpg123, it's working well !

I suppose that the problem comes the interaction between Mopidy and SlimStreamer. In the configuration of Mopidy, I redirect output audio to alsa and install alsamixer as well and changed the buffer_time to high value but still lagging; sound disappears during a few milliseconds or seconds, sound comes back.

Raspberry Pi 2, Mopidy 2.10

Mopidy configuration:

[audio]
output = alsasink
mixer_volume = 85
mixer = alsamixer
buffer_time = 100000

[alsamixer]
control = PCM
min_volume = 0
max_volume = 100
volume_scale = cubic

Thanks for your help.

@gimesketvirtadieni
Copy link
Owner

Hi
Thanks for your feedback; it's great to see people find my work relevant :)
Definitely I will try to help you out...
First, I suggest to rule out latency caused by using source from the Internet. Could you confirm that playing local music is causing a similar lag?
One more curious thing is that you are using alsamixer plugin in your PCM path (BTW alsamixer plugin spoils bit-perfect playback). Could you post your ALSA asound.conf file?
P.S. Apart from this lag, does SlimStreamer work as expected for you?

@dhtek
Copy link
Author

dhtek commented Aug 19, 2018

Yes local music is causing a similar lag.

About alsamixer, I don't know if I had to install it and used it.

Also, I remember when I compiled SlimPlexor with my raspbery PI 2, I got some warning.

image

Yes I have another problem, but I'll create another one ticket when this one will be resolved. It's about synchronisation problem between my squeezelite on my raspberry and another one on windows after the second song is started (songs are out of sync).

Thanks

@gimesketvirtadieni
Copy link
Owner

Thanks for the details. I will setup Mopidy and get back to you.
Playback synchronization 'works' only by 'accident' ;) I am still working on sync functionality so it is not an error. Coordinated playback start is almost finished and 'drift' correction is work in progress ;)

@dhtek
Copy link
Author

dhtek commented Aug 19, 2018

Cool, thanks !

@gimesketvirtadieni
Copy link
Owner

Hi
I am still experimenting with Mopidy (trying to reproduce your issue)... When I use your provided Mopidy config details, I am getting following error in Mopidy log file (default location is /var/log/mopidy/mopidy.log):

pi@raspberrypi:/etc/mopidy $ more /var/log/mopidy/mopidy.log 
2018-08-21 19:02:09,937 INFO [7027:MainThread] mopidy.__main__: Starting Mopidy 2.1.0
2018-08-21 19:02:11,252 INFO [7027:MainThread] mopidy.config: Loading config from builtin defaults
2018-08-21 19:02:11,312 INFO [7027:MainThread] mopidy.config: Loading config from /etc/mopidy/mopidy.conf
2018-08-21 19:02:11,352 INFO [7027:MainThread] mopidy.config: Loading config from command line options
2018-08-21 19:02:12,045 INFO [7027:MainThread] mopidy.__main__: Enabled extensions: mpd, http, stream, m3u, softwaremixer, file, local
2018-08-21 19:02:12,053 INFO [7027:MainThread] mopidy.__main__: Disabled extensions: none
2018-08-21 19:02:14,863 ERROR [7027:MainThread] mopidy.commands: Did not find unique mixer "alsamixer". Alternatives are: software, none

Could you past your mopidy log entries when you start mopidy service?
I will play with various mixer options to check if it is related to this issue...

Thanks in advance for the details ;)

@dhtek
Copy link
Author

dhtek commented Aug 22, 2018

I installed the following plugin https://github.com/mopidy/mopidy-alsamixer

Otherwise with software mixer, I have also the bug.

I forgot to tell you :

  • My mp3 is 320kbps or 128kbps, it's not flac.
  • I'm using a basic usb sound card

@gimesketvirtadieni
Copy link
Owner

Hi
I was playing with various scenarios to reproduce the lag you have mentioned.
Definitely delay is present, however it is ~1 sec. which is more-or-less expected. The thing is, before sending PCM data over the network, it has to be buffered on both ends to compensate network variable latency (think of these buffers as about shock absorbers used in cars).
However I did experienced sound shuttering and in some cases playback did not restore. It was mostly when I played MP3's. So there is more to explore for me and work on reliability.
Could you try playing any FLAC or WAV and check if you experience the same lag? Also I wonder how long the lag is in your case (subjectively)? Is it around 1 sec or more?
Thanks in advance ;)

@dhtek
Copy link
Author

dhtek commented Sep 9, 2018

Hi,
Sorry for the delay... I try with a flac, it's better but it's not perfect.
I uploaded on wetransfer a record when I was playing mp3 with mopidy
https://we.tl/t-IzB1DfNgdT

@gimesketvirtadieni
Copy link
Owner

Hello dhtek

I am sorry, did not have enough time to work on this issue as much I would like for a good reason - I got a son!!!. However I was able to reproduce this problem on my environment. The thing is a host running SlimPlexor and SlimStreamer is not just serving audio stream, but also transcoding its content. It works like this:

  1. Arbitrary app that plays music decode MP3, FLAC, ... or any other format to raw PCM and submit to ALSA (ALSA does not understand anything else but raw PCM)
  2. SlimPlexor captures that stream and delivers it to SlimStreamer
  3. SlimStreamer encodes raw PCM stream to FLAC (configurable via command line options) and sends to all slim clients.

Long story short, a host running SlimPlexor and SlimStreamer has to have enough capacity. Could you provide details about capacity you are using?
I do work on optimizing SlimStreamer internals, which will decrease required capacity and it will be part of the next version, so stay tuned ;)

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