summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtkplaylist.c10
-rw-r--r--streamer.c17
-rw-r--r--streamer.h5
3 files changed, 25 insertions, 7 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index e649776c..c5f6486d 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -643,8 +643,9 @@ gtkps_playsong (void) {
p_unpause ();
}
else if (playlist_current_ptr) {
+ p_stop ();
printf ("restart\n");
- streamer_set_nextsong (ps_get_idx_of (playlist_current_ptr));
+ streamer_set_nextsong (ps_get_idx_of (playlist_current_ptr), 1);
#if 0
ps_start_current ();
GtkWidget *widget = lookup_widget (mainwin, "playlist");
@@ -653,7 +654,7 @@ gtkps_playsong (void) {
}
else if (playlist_row != -1) {
printf ("start under cursor\n");
- streamer_set_nextsong (playlist_row);
+ streamer_set_nextsong (playlist_row, 1);
#if 0
playItem_t *it = ps_get_for_idx (playlist_row);
if (it) {
@@ -665,7 +666,7 @@ gtkps_playsong (void) {
}
else {
printf ("play 1st in list\n");
- streamer_set_nextsong (0);
+ streamer_set_nextsong (0, 1);
#if 0
ps_set_current (playlist_head);
if (playlist_current_ptr) {
@@ -765,7 +766,8 @@ gtkps_pausesong (void) {
void
gtkps_playsongnum (int idx) {
- streamer_set_nextsong (idx);
+ p_stop ();
+ streamer_set_nextsong (idx, 1);
#if 0
playItem_t *it = ps_get_for_idx (playlist_row);
if (it) {
diff --git a/streamer.c b/streamer.c
index 4df07e91..a2941eee 100644
--- a/streamer.c
+++ b/streamer.c
@@ -24,10 +24,12 @@ static int streambuffer_fill;
static char streambuffer[STREAM_BUFFER_SIZE+1000];
static uintptr_t mutex;
static int nextsong = -1;
+static int nextsong_pstate = -1;
void
-streamer_set_nextsong (int song) {
+streamer_set_nextsong (int song, int pstate) {
nextsong = song;
+ nextsong_pstate = pstate;
}
static int
@@ -40,6 +42,7 @@ streamer_thread (uintptr_t ctx) {
while (!streaming_terminate) {
if (nextsong >= 0) {
int sng = nextsong;
+ int pstate = nextsong_pstate;
nextsong = -1;
codec_lock ();
//streambuffer_fill = 0;
@@ -50,7 +53,17 @@ streamer_thread (uintptr_t ctx) {
usleep (3000);
}
}
- p_play ();
+ if (pstate >= 0) {
+ if (pstate == 0) {
+ p_stop ();
+ }
+ else if (pstate == 1) {
+ p_play ();
+ }
+ else if (pstate == 2) {
+ p_pause ();
+ }
+ }
}
streamer_lock ();
if (streambuffer_fill < STREAM_BUFFER_SIZE) {
diff --git a/streamer.h b/streamer.h
index 2607c292..10071865 100644
--- a/streamer.h
+++ b/streamer.h
@@ -19,7 +19,10 @@ streamer_lock (void);
void
streamer_unlock (void);
+// pstate indicates what to do with playback
+// -1 means "don't do anything"
+// otherwise "set state to this value"
void
-streamer_set_nextsong (int song);
+streamer_set_nextsong (int song, int pstate);
#endif // __STREAMER_H