fix initial setup
This commit is contained in:
parent
81a91f2285
commit
16077c8938
2 changed files with 27 additions and 10 deletions
13
src/api.vala
13
src/api.vala
|
@ -19,7 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
errordomain SubsonicError {
|
errordomain SubsonicError {
|
||||||
ERROR
|
BAD_AUTHN,
|
||||||
|
ERROR,
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void Wavelet.SongCallback (Song song);
|
public delegate void Wavelet.SongCallback (Song song);
|
||||||
|
@ -194,6 +195,10 @@ public class Wavelet.Subsonic : Object {
|
||||||
|
|
||||||
public async void ping () throws Error {
|
public async void ping () throws Error {
|
||||||
var msg = new Soup.Message ("GET", @"$(this.url)/rest/ping?f=json&$(this.parameters)");
|
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);
|
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||||
assert (msg.get_status () == Soup.Status.OK);
|
assert (msg.get_status () == Soup.Status.OK);
|
||||||
|
|
||||||
|
@ -206,6 +211,8 @@ public class Wavelet.Subsonic : Object {
|
||||||
|
|
||||||
public async void scrobble (string id) throws Error {
|
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)");
|
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);
|
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||||
assert (msg.get_status () == Soup.Status.OK);
|
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)");
|
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);
|
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||||
assert (msg.get_status () == Soup.Status.OK);
|
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 {
|
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));
|
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);
|
var stream = yield this.session.send_async (msg, Priority.DEFAULT, cancellable);
|
||||||
assert (msg.get_status () == Soup.Status.OK);
|
assert (msg.get_status () == Soup.Status.OK);
|
||||||
return yield new Gdk.Pixbuf.from_stream_async (stream, cancellable);
|
return yield new Gdk.Pixbuf.from_stream_async (stream, cancellable);
|
||||||
|
|
|
@ -89,17 +89,23 @@ class Playbin : Object {
|
||||||
string? next_uri = null;
|
string? next_uri = null;
|
||||||
|
|
||||||
this.next_uri_lock.lock ();
|
this.next_uri_lock.lock ();
|
||||||
if (this.next_uri != (string) this.playbin.current_uri) {
|
next_uri = this.next_uri;
|
||||||
print("%s\n", this.next_uri);
|
|
||||||
print("%s\n", (string) this.playbin.current_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
|
// WHOOPS! didn't actually switch to the track the play queue wanted
|
||||||
// FIXME as it arises
|
// we can still fix this though
|
||||||
assert (false);
|
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) {
|
if (Gst.MessageType.EOS in message.type) {
|
||||||
|
|
Loading…
Reference in a new issue