Skip to content

Commit

Permalink
renamed pause event to togglepause;
Browse files Browse the repository at this point in the history
added new pause event, including command line option;
slightly changed/shortened M_* constant names
  • Loading branch information
Oleksiy-Yakovenko committed Dec 31, 2010
1 parent 74df8d5 commit e06308f
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 76 deletions.
19 changes: 10 additions & 9 deletions deadbeef.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,18 @@ enum pl_column_t {
// message ids for communicating with player
enum {
M_SONGFINISHED,
M_NEXTSONG,
M_PREVSONG,
M_PLAYSONG,
M_PLAYSONGNUM,
M_STOPSONG,
M_PAUSESONG,
M_PLAYRANDOM,
M_NEXT,
M_PREV,
M_PLAY_CURRENT,
M_PLAY_NUM,
M_STOP,
M_PAUSE,
M_PLAY_RANDOM,
M_TERMINATE, // must be sent to player thread to terminate
M_PLAYLISTREFRESH,
M_PLAYLIST_REFRESH, // means
M_REINIT_SOUND,
M_CONFIGCHANGED, // no arguments
M_CONFIG_CHANGED, // no arguments
M_TOGGLE_PAUSE,
};

// typecasting macros
Expand Down
45 changes: 28 additions & 17 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ client_exec_command_line (const char *cmdline, int len) {
fprintf (stdout, _(" --play Start playback\n"));
fprintf (stdout, _(" --stop Stop playback\n"));
fprintf (stdout, _(" --pause Pause playback\n"));
fprintf (stdout, _(" --toggle-pause Toggle pause\n"));
fprintf (stdout, _(" --next Next song in playlist\n"));
fprintf (stdout, _(" --prev Previous song in playlist\n"));
fprintf (stdout, _(" --random Random song in playlist\n"));
Expand Down Expand Up @@ -179,27 +180,31 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
}
}
else if (!strcmp (parg, "--next")) {
messagepump_push (M_NEXTSONG, 0, 0, 0);
messagepump_push (M_NEXT, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--prev")) {
messagepump_push (M_PREVSONG, 0, 0, 0);
messagepump_push (M_PREV, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--play")) {
messagepump_push (M_PLAYSONG, 0, 0, 0);
messagepump_push (M_PLAY_CURRENT, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--stop")) {
messagepump_push (M_STOPSONG, 0, 0, 0);
messagepump_push (M_STOP, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--pause")) {
messagepump_push (M_PAUSESONG, 0, 0, 0);
messagepump_push (M_PAUSE, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--toggle-pause")) {
messagepump_push (M_TOGGLE_PAUSE, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--random")) {
messagepump_push (M_PLAYRANDOM, 0, 0, 0);
messagepump_push (M_PLAY_RANDOM, 0, 0, 0);
return 0;
}
else if (!strcmp (parg, "--queue")) {
Expand Down Expand Up @@ -251,9 +256,9 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
parg++;
}
deadbeef->pl_add_files_end ();
messagepump_push (M_PLAYLISTREFRESH, 0, 0, 0);
messagepump_push (M_PLAYLIST_REFRESH, 0, 0, 0);
if (!queue) {
messagepump_push (M_PLAYSONG, 0, 1, 0);
messagepump_push (M_PLAY_CURRENT, 0, 1, 0);
return 2; // don't reload playlist at startup
}
}
Expand Down Expand Up @@ -375,7 +380,7 @@ player_mainloop (void) {
break;
case M_TERMINATE:
return;
case M_PLAYSONG:
case M_PLAY_CURRENT:
if (p1) {
output->stop ();
pl_playqueue_clear ();
Expand All @@ -385,23 +390,29 @@ player_mainloop (void) {
streamer_play_current_track ();
}
break;
case M_PLAYSONGNUM:
case M_PLAY_NUM:
output->stop ();
pl_playqueue_clear ();
streamer_set_nextsong (p1, 1);
break;
case M_STOPSONG:
case M_STOP:
streamer_set_nextsong (-2, 0);
break;
case M_NEXTSONG:
case M_NEXT:
output->stop ();
streamer_move_to_nextsong (1);
break;
case M_PREVSONG:
case M_PREV:
output->stop ();
streamer_move_to_prevsong ();
break;
case M_PAUSESONG:
case M_PAUSE:
if (output->state () != OUTPUT_STATE_PAUSED) {
output->pause ();
plug_trigger_event_paused (1);
}
break;
case M_TOGGLE_PAUSE:
if (output->state () == OUTPUT_STATE_PAUSED) {
output->unpause ();
plug_trigger_event_paused (0);
Expand All @@ -411,15 +422,15 @@ player_mainloop (void) {
plug_trigger_event_paused (1);
}
break;
case M_PLAYRANDOM:
case M_PLAY_RANDOM:
output->stop ();
streamer_move_to_randomsong ();
break;
case M_PLAYLISTREFRESH:
case M_PLAYLIST_REFRESH:
pl_save_current ();
plug_trigger_event_playlistchanged ();
break;
case M_CONFIGCHANGED:
case M_CONFIG_CHANGED:
conf_save ();
streamer_configchanged ();
plug_trigger_event (DB_EV_CONFIGCHANGED, 0);
Expand Down
12 changes: 6 additions & 6 deletions plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,32 +404,32 @@ plug_ev_unsubscribe (DB_plugin_t *plugin, int ev, DB_callback_t callback, uintpt

void
plug_playback_next (void) {
messagepump_push (M_NEXTSONG, 0, 0, 0);
messagepump_push (M_NEXT, 0, 0, 0);
}

void
plug_playback_prev (void) {
messagepump_push (M_PREVSONG, 0, 0, 0);
messagepump_push (M_PREV, 0, 0, 0);
}

void
plug_playback_pause (void) {
messagepump_push (M_PAUSESONG, 0, 0, 0);
messagepump_push (M_TOGGLE_PAUSE, 0, 0, 0);
}

void
plug_playback_stop (void) {
messagepump_push (M_STOPSONG, 0, 0, 0);
messagepump_push (M_STOP, 0, 0, 0);
}

void
plug_playback_play (void) {
messagepump_push (M_PLAYSONG, 0, 0, 0);
messagepump_push (M_PLAY_CURRENT, 0, 0, 0);
}

void
plug_playback_random (void) {
messagepump_push (M_PLAYRANDOM, 0, 0, 0);
messagepump_push (M_PLAY_RANDOM, 0, 0, 0);
}

float
Expand Down
2 changes: 1 addition & 1 deletion plugins/artwork/artwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ artwork_on_configchanged (DB_event_t *ev, uintptr_t data) {
strcpy (artwork_filemask, new_artwork_filemask);
deadbeef->conf_set_int64 ("artwork.cache_reset_time", artwork_reset_time);
artwork_reset (0);
deadbeef->sendmessage (M_PLAYLISTREFRESH, 0, 0, 0);
deadbeef->sendmessage (M_PLAYLIST_REFRESH, 0, 0, 0);
}

return 0;
Expand Down
22 changes: 11 additions & 11 deletions plugins/gtkui/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,47 +274,47 @@ void
on_stopbtn_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_STOPSONG, 0, 0, 0);
deadbeef->sendmessage (M_STOP, 0, 0, 0);
}


void
on_playbtn_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_PLAYSONG, 0, 0, 0);
deadbeef->sendmessage (M_PLAY_CURRENT, 0, 0, 0);
}


void
on_pausebtn_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_PAUSESONG, 0, 0, 0);
deadbeef->sendmessage (M_TOGGLE_PAUSE, 0, 0, 0);
}


void
on_prevbtn_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_PREVSONG, 0, 0, 0);
deadbeef->sendmessage (M_PREV, 0, 0, 0);
}


void
on_nextbtn_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_NEXTSONG, 0, 0, 0);
deadbeef->sendmessage (M_NEXT, 0, 0, 0);
}


void
on_playrand_clicked (GtkButton *button,
gpointer user_data)
{
deadbeef->sendmessage (M_PLAYRANDOM, 0, 0, 0);
deadbeef->sendmessage (M_PLAY_RANDOM, 0, 0, 0);
}

gboolean
Expand All @@ -325,7 +325,7 @@ on_mainwin_key_press_event (GtkWidget *widget,
uint32_t maskedstate = (event->state &~ (GDK_LOCK_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD5_MASK)) & 0xfff;
if ((maskedstate == GDK_MOD1_MASK || maskedstate == 0) && event->keyval == GDK_n) {
// button for that one is not in toolbar anymore, so handle it manually
deadbeef->sendmessage (M_PLAYRANDOM, 0, 0, 0);
deadbeef->sendmessage (M_PLAY_RANDOM, 0, 0, 0);
}
else if ((maskedstate == GDK_MOD1_MASK || maskedstate == 0) && event->keyval >= GDK_1 && event->keyval <= GDK_9) {
int pl = event->keyval - GDK_1;
Expand All @@ -346,7 +346,7 @@ on_order_linear_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->conf_set_int ("playback.order", PLAYBACK_ORDER_LINEAR);
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}


Expand All @@ -355,23 +355,23 @@ on_order_shuffle_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->conf_set_int ("playback.order", PLAYBACK_ORDER_SHUFFLE_TRACKS);
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}

void
on_order_shuffle_albums_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->conf_set_int ("playback.order", PLAYBACK_ORDER_SHUFFLE_ALBUMS);
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}

void
on_order_random_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
deadbeef->conf_set_int ("playback.order", PLAYBACK_ORDER_RANDOM);
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}


Expand Down
2 changes: 1 addition & 1 deletion plugins/gtkui/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open_files_worker (void *data) {
extern GtkWidget *mainwin;
DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
ddb_listview_set_cursor (pl, 0);
deadbeef->sendmessage (M_PLAYSONG, 0, 1, 0);
deadbeef->sendmessage (M_PLAY_CURRENT, 0, 1, 0);
}

void
Expand Down
4 changes: 2 additions & 2 deletions plugins/gtkui/gtkui.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ on_trayicon_button_press_event (GtkWidget *widget,
mainwin_toggle_visible ();
}
else if (event->button == 2) {
deadbeef->sendmessage (M_PAUSESONG, 0, 0, 0);
deadbeef->sendmessage (M_TOGGLE_PAUSE, 0, 0, 0);
}
return FALSE;
}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ gtkui_set_progress_text_idle (gpointer data) {
gboolean
gtkui_progress_hide_idle (gpointer data) {
progress_hide ();
deadbeef->sendmessage (M_PLAYLISTREFRESH, 0, 0, 0);
deadbeef->sendmessage (M_PLAYLIST_REFRESH, 0, 0, 0);
//playlist_refresh ();
return FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/gtkui/mainplaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ main_col_sort (int col, int sort_order, void *user_data) {
deadbeef->pl_sort (PL_MAIN, c->id, c->format, sort_order-1);
}
void main_handle_doubleclick (DdbListview *listview, DdbListviewIter iter, int idx) {
deadbeef->sendmessage (M_PLAYSONGNUM, 0, idx, 0);
deadbeef->sendmessage (M_PLAY_NUM, 0, idx, 0);
}

void main_selection_changed (DdbListviewIter it, int idx) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/gtkui/pluginconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ on_prop_browse_file (GtkButton *button, gpointer user_data) {
if (folder) {
deadbeef->conf_set_str ("filechooser.lastdir", folder);
g_free (folder);
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}
if (response == GTK_RESPONSE_OK) {
gchar *file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
Expand Down Expand Up @@ -181,7 +181,7 @@ static void apply_conf (GtkWidget *w, ddb_dialog_t *conf) {
break;
}
}
deadbeef->sendmessage (M_CONFIGCHANGED, 0, 0, 0);
deadbeef->sendmessage (M_CONFIG_CHANGED, 0, 0, 0);
}

static void
Expand Down
Loading

0 comments on commit e06308f

Please sign in to comment.