add events for playlist (queue), volume, speaker, options

(random/shuffle) changes
This commit is contained in:
chme 2015-05-03 08:45:38 +02:00
parent d2c7c87191
commit aa4a12cabe
3 changed files with 79 additions and 6 deletions

View File

@ -5,8 +5,12 @@
enum listener_event_type
{
LISTENER_NONE = 0,
LISTENER_DATABASE = 1,
LISTENER_PLAYER = 2,
LISTENER_DATABASE,
LISTENER_PLAYER,
LISTENER_PLAYLIST,
LISTENER_VOLUME,
LISTENER_SPEAKER,
LISTENER_OPTIONS,
};
typedef void (*notify)(enum listener_event_type type);

View File

@ -657,13 +657,29 @@ mpd_command_idle(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
for (i = 1; i < argc; i++)
{
if (0 == strcmp(argv[i], "player"))
if (0 == strcmp(argv[i], "database"))
{
client->types[i - 1] = LISTENER_DATABASE;
}
else if (0 == strcmp(argv[i], "player"))
{
client->types[i - 1] = LISTENER_PLAYER;
}
else if (0 == strcmp(argv[i], "database"))
else if (0 == strcmp(argv[i], "playlist"))
{
client->types[i - 1] = LISTENER_DATABASE;
client->types[i - 1] = LISTENER_PLAYLIST;
}
else if (0 == strcmp(argv[i], "mixer"))
{
client->types[i - 1] = LISTENER_VOLUME;
}
else if (0 == strcmp(argv[i], "output"))
{
client->types[i - 1] = LISTENER_SPEAKER;
}
else if (0 == strcmp(argv[i], "options"))
{
client->types[i - 1] = LISTENER_OPTIONS;
}
else
{
@ -3829,7 +3845,33 @@ mpd_notify_idle_client(struct idle_client *client, enum listener_event_type type
return 1;
}
evbuffer_add(client->evbuffer, "changed: player\n", 16);
switch (type)
{
case LISTENER_PLAYER:
evbuffer_add(client->evbuffer, "changed: player\n", 16);
break;
case LISTENER_PLAYLIST:
evbuffer_add(client->evbuffer, "changed: playlist\n", 18);
break;
case LISTENER_VOLUME:
evbuffer_add(client->evbuffer, "changed: mixer\n", 15);
break;
case LISTENER_SPEAKER:
evbuffer_add(client->evbuffer, "changed: output\n", 16);
break;
case LISTENER_OPTIONS:
evbuffer_add(client->evbuffer, "changed: options\n", 17);
break;
default:
DPRINTF(E_WARN, L_MPD, "Unsupported event type (%d) in notify idle clients.\n", type);
return -1;
}
evbuffer_add(client->evbuffer, "OK\n", 3);
return 0;

View File

@ -3514,6 +3514,8 @@ speaker_set(struct player_command *cmd)
}
}
listener_notify(LISTENER_SPEAKER);
if (cmd->raop_pending > 0)
return 1; /* async */
@ -3560,6 +3562,8 @@ volume_set(struct player_command *cmd)
cmd->raop_pending += raop_set_volume_one(rd->session, rd->volume, device_command_cb);
}
listener_notify(LISTENER_VOLUME);
if (cmd->raop_pending > 0)
return 1; /* async */
@ -3610,6 +3614,8 @@ volume_setrel_speaker(struct player_command *cmd)
}
}
listener_notify(LISTENER_VOLUME);
if (cmd->raop_pending > 0)
return 1; /* async */
@ -3669,6 +3675,8 @@ volume_setabs_speaker(struct player_command *cmd)
}
}
listener_notify(LISTENER_VOLUME);
if (cmd->raop_pending > 0)
return 1; /* async */
@ -3678,6 +3686,9 @@ volume_setabs_speaker(struct player_command *cmd)
static int
repeat_set(struct player_command *cmd)
{
if (cmd->arg.mode == repeat)
return 0;
switch (cmd->arg.mode)
{
case REPEAT_OFF:
@ -3691,6 +3702,8 @@ repeat_set(struct player_command *cmd)
return -1;
}
listener_notify(LISTENER_OPTIONS);
return 0;
}
@ -3712,6 +3725,8 @@ shuffle_set(struct player_command *cmd)
return -1;
}
listener_notify(LISTENER_OPTIONS);
return 0;
}
@ -3856,6 +3871,8 @@ queue_add(struct player_command *cmd)
if (cur_plid != 0)
cur_plid = 0;
listener_notify(LISTENER_PLAYLIST);
return 0;
}
@ -3897,6 +3914,8 @@ queue_add_next(struct player_command *cmd)
if (cur_plid != 0)
cur_plid = 0;
listener_notify(LISTENER_PLAYLIST);
return 0;
}
@ -3964,6 +3983,8 @@ queue_move(struct player_command *cmd)
ps_dst->pl_next = ps_src;
}
listener_notify(LISTENER_PLAYLIST);
return 0;
}
@ -4029,6 +4050,8 @@ queue_remove(struct player_command *cmd)
source_free(ps);
listener_notify(LISTENER_PLAYLIST);
return 0;
}
@ -4055,6 +4078,8 @@ queue_clear(struct player_command *cmd)
cur_plid = 0;
listener_notify(LISTENER_PLAYLIST);
return 0;
}
@ -4104,6 +4129,8 @@ queue_empty(struct player_command *cmd)
source_head->shuffle_prev = source_head;
}
listener_notify(LISTENER_PLAYLIST);
return 0;
}