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

Fix Mopidy correctly and remove resampling #6

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions home-manager/_mixins/services/mopidy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
# 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
# If you set this too low, Mopidy will get hopelessly lost when switching between tracks and become unresponsive.
# The lowest I could get this without causing Mopidy to crash was 35ms.
buffer_time = 35; # Must be greater than 0, default from GStreamer is 1000ms
mixer = "software";
mixer_volume = 50;
# 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\"";
output = "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 Down
25 changes: 25 additions & 0 deletions overlays/0001-Use-playbin3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 1c42b4fc92f2a20dd98cbb2fc297a935e64c2ec4 Mon Sep 17 00:00:00 2001
From: Jordan Williams <[email protected]>
Date: Sat, 23 Nov 2024 14:14:54 -0600
Subject: [PATCH 1/2] Use playbin3

---
src/mopidy/audio/actor.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mopidy/audio/actor.py b/src/mopidy/audio/actor.py
index 84062f6b..444239bd 100644
--- a/src/mopidy/audio/actor.py
+++ b/src/mopidy/audio/actor.py
@@ -432,7 +432,7 @@ class Audio(pykka.ThreadingActor):
jacksink.set_rank(Gst.Rank.SECONDARY)

def _setup_playbin(self) -> None:
- playbin = Gst.ElementFactory.make("playbin")
+ playbin = Gst.ElementFactory.make("playbin3")
if playbin is None:
raise exceptions.AudioException("Failed to create GStreamer playbin.")
playbin.set_property("flags", _GST_PLAY_FLAGS_AUDIO)
--
2.47.0

25 changes: 25 additions & 0 deletions overlays/0002-Use-decodebin3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From ae424ab984f9bf98ff9be9937ceac345b80db729 Mon Sep 17 00:00:00 2001
From: Jordan Williams <[email protected]>
Date: Sat, 23 Nov 2024 14:54:23 -0600
Subject: [PATCH 2/2] Use decodebin3

---
src/mopidy/audio/scan.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mopidy/audio/scan.py b/src/mopidy/audio/scan.py
index d38cc895..e387dc1d 100644
--- a/src/mopidy/audio/scan.py
+++ b/src/mopidy/audio/scan.py
@@ -130,7 +130,7 @@ def _setup_decodebin(element, pad, pipeline, signals):
if typefind is None:
raise exceptions.AudioException("Failed to create GStreamer typefind element.")

- decodebin = Gst.ElementFactory.make("decodebin")
+ decodebin = Gst.ElementFactory.make("decodebin3")
if decodebin is None:
raise exceptions.AudioException("Failed to create GStreamer decodebin element.")

--
2.47.0

44 changes: 36 additions & 8 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,37 @@
# todo Make it possible to disable graphviz support in libcamera.
graphviz = prev.graphviz.override { withXorg = false; };
gst_all_1 = prev.gst_all_1 // {
gst-plugins-base = prev.gst_all_1.gst-plugins-base.override {
enableX11 = false;
enableWayland = false;
};
gst-plugins-good = prev.gst_all_1.gst-plugins-good.override {
enableX11 = false;
enableWayland = false;
};
gstreamer = prev.gst_all_1.gstreamer.overrideAttrs (prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-6/R7a+71CKAMhVfUwfFxPlx++bpw2sRd7tgOGCvPJg8=";
};
});
gst-plugins-base =
(prev.gst_all_1.gst-plugins-base.override {
enableX11 = false;
enableWayland = false;
}).overrideAttrs
(prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-W7O5RpB9POBN2EK2EMgRHCsGETUbJaH6Iq9e+ol4V8s=";
};
});
gst-plugins-good =
(prev.gst_all_1.gst-plugins-good.override {
enableX11 = false;
enableWayland = false;
}).overrideAttrs
(prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-iX3lC/8zfjyi+G8eqijggo2DAkFWFipQxOoK+G4peZ8=";
};
});
gst-plugins-rs = prev.gst_all_1.gst-plugins-rs.override {
withGtkPlugins = false;
};
Expand Down Expand Up @@ -117,6 +140,11 @@
hash = "sha256-+YjiAysDVfuEpohcWMU5he8yp1tr/g4aLxqrKuhrjWY=";
};

patches = [
./0001-Use-playbin3.patch
./0002-Use-decodebin3.patch
];

build-system = with prev.python3Packages; [
setuptools
setuptools-scm
Expand Down