Skip to content

Commit

Permalink
Merge pull request #5 from jwillikers/fix-mopidy-crashes
Browse files Browse the repository at this point in the history
Fix mopidy crashes when switching between tracks
  • Loading branch information
jwillikers authored Nov 23, 2024
2 parents 13620ac + 7e8907c commit ea76d86
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ context.modules = [
actions = {
create-stream = {
audio.rate = 48000
audio.format = S16LE
audio.format = S32LE
audio.channels = 2
audio.position = [ FL FR ]
node.name = "Piceiver Snapcast Sink"
Expand Down
10 changes: 9 additions & 1 deletion home-manager/_mixins/services/mopidy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
mopidy-iris
mopidy-jellyfin
];
# todo Make it easier to add Env=GST_DEBUG=3 to systemd unit...
settings = {
audio = {
# I'm surprised I don't need a value larger than 1ms here.
buffer_time = 1; # Must be greater than 0, default from GStreamer is 1000ms
mixer = "software";
mixer_volume = 50;
output = "pipewiresink client-name=Mopidy target-object=snapserver";
# Mopidy gets all out of whack when switching between tracks using the default 44100 sample rate or possibly the S16LE format.
# I don't know why, but updating it to 48000 seems to make everything just work.
# Rygel uses GStreamer similarly but doesn't have problems like this, even though it uses a sample rate of 96000...
# Maybe it's something that is a problem in the pre-release version of Mopidy.
output = "audioconvert ! audioresample quality=10 ! audio/x-raw,rate=48000,channels=2,format=S32LE ! pipewiresink client-name=Mopidy target-object=snapserver stream-properties=\"props,application.id=mopidy,application.name=Mopidy,application.process.binary=mopidy,application.version=${lib.getVersion pkgs.mopidy},media.category=Playback,media.role=Music,media.type=Audio\"";
};
http = {
enabled = true;
Expand All @@ -46,6 +51,9 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
albumartistsort = false; # (Optional: will default to True if left undefined)
album_format = "{ProductionYear} - {Name}"; # (Optional: will default to "{Name}" if left undefined)
};
# logging = {
# verbosity = 2;
# };
};
};
}
2 changes: 1 addition & 1 deletion home-manager/_mixins/services/rygel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
[Playbin]
enabled=true
title=Audio playback on @PRETTY_HOSTNAME@
audio-sink=pipewiresink client-name=Rygel target-object=snapserver
audio-sink=pipewiresink client-name=Rygel target-object=snapserver stream-properties=\"props,application.id=rygel,application.name=Rygel,application.process.binary=rygel,application.version=${lib.getVersion pkgs.rygel},media.category=Playback,media.role=Music,media.type=Audio\"
[GstLaunch]
enabled=false
Expand Down
1 change: 1 addition & 0 deletions home-manager/_mixins/services/snapclient/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let
[
"--logsink system"
"--player pulse:buffer_time=10" # Minimum is 10ms, default is 100ms
# "--logfilter *:debug"
]
++ lib.optionals (role == "piceiver") [
"--host ::1"
Expand Down
2 changes: 1 addition & 1 deletion nixos/_mixins/services/snapserver/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lib.mkIf (role == "piceiver") {
enable = true;
http.docRoot = null; # pkgs.snapweb fails to cross-compile in 24.11 due to sharp / vips dependencies
openFirewall = true;
sampleFormat = "48000:16:2";
sampleFormat = "48000:32:2";
streams = {
default = {
location = "127.0.0.1:4711"; # todo Use IPv6 here when Snapcast supports it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context.modules = [
{ name = libpipewire-module-protocol-simple
args = {
audio.rate = 48000
audio.format = S16LE
audio.format = S32LE
audio.channels = 2
audio.position = [ FL FR ]
server.address = [
Expand Down

0 comments on commit ea76d86

Please sign in to comment.