From 0a62dc11a3b093c02f68d79b32d396b76497897d Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 12 Oct 2024 17:53:13 +0000 Subject: [PATCH] fix initial setup --- src/api.vala | 13 ++++++++++++- src/playbin.vala | 24 +++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/api.vala b/src/api.vala index fbfe0c7..481756c 100644 --- a/src/api.vala +++ b/src/api.vala @@ -19,7 +19,8 @@ */ errordomain SubsonicError { - ERROR + BAD_AUTHN, + ERROR, } public delegate void Wavelet.SongCallback (Song song); @@ -194,6 +195,10 @@ public class Wavelet.Subsonic : Object { public async void ping () throws Error { var msg = new Soup.Message ("GET", @"$(this.url)/rest/ping?f=json&$(this.parameters)"); + if (msg == null) { + throw new SubsonicError.BAD_AUTHN ("Bad message"); + } + var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); assert (msg.get_status () == Soup.Status.OK); @@ -206,6 +211,8 @@ public class Wavelet.Subsonic : Object { public async void scrobble (string id) throws Error { var msg = new Soup.Message ("GET", @"$(this.url)/rest/scrobble?id=$(Uri.escape_string (id))&f=json&$(this.parameters)"); + assert (msg != null); + var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); assert (msg.get_status () == Soup.Status.OK); @@ -225,6 +232,8 @@ public class Wavelet.Subsonic : Object { } var msg = new Soup.Message("GET", @"$(this.url)/rest/getRandomSongs?$(str_parameters)size=500&f=json&$(this.parameters)"); + assert (msg != null); + var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null); assert (msg.get_status () == Soup.Status.OK); @@ -256,6 +265,8 @@ public class Wavelet.Subsonic : Object { public async Gdk.Pixbuf cover_art (string id, int size, Cancellable cancellable) throws Error { var msg = new Soup.Message("GET", this.cover_art_uri (id, size)); + assert (msg != null); + var stream = yield this.session.send_async (msg, Priority.DEFAULT, cancellable); assert (msg.get_status () == Soup.Status.OK); return yield new Gdk.Pixbuf.from_stream_async (stream, cancellable); diff --git a/src/playbin.vala b/src/playbin.vala index cde33f2..858919e 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -89,17 +89,23 @@ class Playbin : Object { string? next_uri = null; this.next_uri_lock.lock (); - if (this.next_uri != (string) this.playbin.current_uri) { - print("%s\n", this.next_uri); - print("%s\n", (string) this.playbin.current_uri); + next_uri = this.next_uri; + + if (next_uri != (string) this.playbin.current_uri) { + this.next_uri_lock.unlock (); // WHOOPS! didn't actually switch to the track the play queue wanted - // FIXME as it arises - assert (false); + // we can still fix this though + assert (next_uri != null); + this.playbin.set_state (Gst.State.READY); + this.playbin.uri = next_uri; + this.playbin.set_state (Gst.State.PLAYING); + // no one will ever know + } else { + this.next_uri = null; + this.next_uri_lock.unlock (); + + this.stream_started (); } - this.next_uri = null; - this.next_uri_lock.unlock (); - - this.stream_started (); } if (Gst.MessageType.EOS in message.type) {