Maintain current playlist ID in the player state

cur_plid is 0 if not playing a playlist and takes the playlist ID otherwise.
This commit is contained in:
Julien BLACHE 2010-07-31 12:30:51 +02:00
parent 94b4cd2459
commit 98aaa7c5fa
2 changed files with 42 additions and 0 deletions

View File

@ -170,6 +170,7 @@ static struct player_source *source_head;
static struct player_source *shuffle_head;
static struct player_source *cur_playing;
static struct player_source *cur_streaming;
static uint32_t cur_plid;
static struct evbuffer *audio_buf;
@ -1490,6 +1491,8 @@ get_status(void *arg)
status->volume = volume;
status->plid = cur_plid;
switch (player_state)
{
case PLAY_STOPPED:
@ -2412,6 +2415,9 @@ queue_add(void *arg)
shuffle_head = ps_shuffle;
}
if (cur_plid != 0)
cur_plid = 0;
return 0;
}
@ -2433,6 +2439,23 @@ queue_clear(void *arg)
source_free(ps);
}
cur_plid = 0;
return 0;
}
static int
queue_plid(void *arg)
{
uint32_t *plid;
if (!source_head)
return 0;
plid = (uint32_t *)arg;
cur_plid = *plid;
return 0;
}
@ -2797,6 +2820,20 @@ player_queue_clear(void)
pthread_mutex_unlock(&cmd_lck);
}
void
player_queue_plid(uint32_t plid)
{
pthread_mutex_lock(&cmd_lck);
cmd.func = queue_plid;
cmd.func_bh = NULL;
cmd.arg = &plid;
sync_command();
pthread_mutex_unlock(&cmd_lck);
}
/* Thread: main (mdns) */
static void
@ -3126,6 +3163,7 @@ player_init(void)
shuffle_head = NULL;
cur_playing = NULL;
cur_streaming = NULL;
cur_plid = 0;
player_state = PLAY_STOPPED;
repeat = REPEAT_OFF;

View File

@ -39,6 +39,7 @@ struct player_status {
int volume;
uint32_t plid;
uint32_t id;
uint32_t pos_ms;
int pos_pl;
@ -106,6 +107,9 @@ player_queue_add(struct player_source *ps);
void
player_queue_clear(void);
void
player_queue_plid(uint32_t plid);
void
player_set_updatefd(int fd);