callbacks: Add callbacks for playqueue size modifications
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
ea687408aa
commit
42d57567e0
|
@ -5,13 +5,19 @@
|
|||
#define OCARINA_CALLBACK_H
|
||||
|
||||
#include <library.h>
|
||||
#include <playqueue.h>
|
||||
|
||||
|
||||
struct Callbacks {
|
||||
/* Library callbacks */
|
||||
void (*on_library_add)(unsigned int, library :: Library *);
|
||||
void (*on_library_update)(unsigned int, library :: Library *);
|
||||
void (*on_library_track_add)(unsigned int);
|
||||
void (*on_library_track_del)(unsigned int);
|
||||
|
||||
/* Playqueue callbacks */
|
||||
void (*on_queue_track_add)(Playqueue *);
|
||||
void (*on_queue_track_del)(Playqueue *);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
static void no_op(unsigned int) {}
|
||||
static void no_op(unsigned int id, library :: Library *path) {}
|
||||
static void no_op(Playqueue *) {}
|
||||
|
||||
|
||||
static struct Callbacks callbacks = {
|
||||
|
@ -13,6 +14,9 @@ static struct Callbacks callbacks = {
|
|||
.on_library_update = no_op,
|
||||
.on_library_track_add = no_op,
|
||||
.on_library_track_del = no_op,
|
||||
|
||||
.on_queue_track_add = no_op,
|
||||
.on_queue_track_del = no_op,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <callback.h>
|
||||
#include <library.h>
|
||||
#include <playqueue.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -62,6 +63,7 @@ unsigned int Playqueue :: add(unsigned int track_id)
|
|||
|
||||
library :: lookup(track_id, &song);
|
||||
length += song.track->length;
|
||||
get_callbacks()->on_queue_track_add(this);
|
||||
return tracks.size() - 1;
|
||||
}
|
||||
|
||||
|
@ -72,6 +74,7 @@ unsigned int Playqueue :: add_front(unsigned int track_id)
|
|||
|
||||
library :: lookup(track_id, &song);
|
||||
length += song.track->length;
|
||||
get_callbacks()->on_queue_track_add(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -83,6 +86,7 @@ void Playqueue :: del(unsigned int plist_id)
|
|||
tracks.erase(tracks.begin() + plist_id);
|
||||
library :: lookup(track_id, &song);
|
||||
length -= song.track->length;
|
||||
get_callbacks()->on_queue_track_del(this);
|
||||
}
|
||||
|
||||
void Playqueue :: del_track(unsigned int track_id)
|
||||
|
@ -94,6 +98,7 @@ void Playqueue :: del_track(unsigned int track_id)
|
|||
else
|
||||
i++;
|
||||
}
|
||||
get_callbacks()->on_queue_track_del(this);
|
||||
}
|
||||
|
||||
unsigned int Playqueue :: size()
|
||||
|
|
Loading…
Reference in New Issue
Block a user