Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
On 2011/04/26 12:29, Olivier Mehani wrote: > On Tue, Apr 26, 2011 at 09:52:16AM +0200, Kurt Van Dijck wrote: > > > Feel free to s/queue/insert/g* on my patch if it gets merged in! > > I believe it's better you recreate the patch (I'm not maintainer neither). > > Here we go then. This patch has the nomenclature right, and updates the > manpage. Merged, thanks. -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd ___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
How does it do an insert when random is enabled? Then it won't be the next song playing? On 04/26/2011 12:29 PM, Olivier Mehani wrote: On Tue, Apr 26, 2011 at 09:52:16AM +0200, Kurt Van Dijck wrote: Feel free to s/queue/insert/g* on my patch if it gets merged in! I believe it's better you recreate the patch (I'm not maintainer neither). Here we go then. This patch has the nomenclature right, and updates the manpage. -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd ___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
On Tue, Apr 26, 2011 at 09:52:16AM +0200, Kurt Van Dijck wrote: > > Feel free to s/queue/insert/g* on my patch if it gets merged in! > I believe it's better you recreate the patch (I'm not maintainer neither). Here we go then. This patch has the nomenclature right, and updates the manpage. -- Olivier Mehani PGP fingerprint: 4435 CF6A 7C8D DD9B E2DE F5F9 F012 A6E2 98C6 6655 From a16ee5d297be0227634b4e942ee9192931fb151b Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Mon, 25 Apr 2011 04:16:45 +1000 Subject: [PATCH] Add an 'insert' command to mpc The insert command works similarly to add (in fact, it's a wrapper around it), except it places the newly added song(s) just after the currently playing one, rather than at the end. The manpage is updated accordingly. Signed-off-by: Olivier Mehani Signed-off-by: Olivier Mehani --- doc/mpc.1 |5 + src/command.c | 19 +++ src/command.h |1 + src/main.c|1 + 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/doc/mpc.1 b/doc/mpc.1 index 7a8d5f5..3670028 100644 --- a/doc/mpc.1 +++ b/doc/mpc.1 @@ -86,6 +86,11 @@ The port to connect to; if not given, the value of the environment variable MPD_ .B add Adds a song from the music database to the playlist. Can also read input from pipes. Use "mpc ls | mpc add" to add all files to the playlist. .TP +.B insert +The insert command works similarly to +.B add +except it adds song(s) after the currently playing one, rather than at the end. +.TP .B clear Empties playlist. .TP diff --git a/src/command.c b/src/command.c index bafddb7..705b1ae 100644 --- a/src/command.c +++ b/src/command.c @@ -731,6 +731,25 @@ int cmd_load ( int argc, char ** argv, struct mpd_connection *conn ) return 0; } +int cmd_insert (int argc, char ** argv, struct mpd_connection *conn ) +{ + int ret; + struct mpd_status *status = mpd_run_status(conn); + if (status == NULL) + printErrorAndExit(conn); + + const int from = mpd_status_get_queue_length(status); + + ret = cmd_add(argc, argv, conn); + const int cur_pos = mpd_status_get_song_pos(status); + mpd_status_free(status); + if (ret != 0) { + return ret; + } + return mpd_run_move_range(conn, from, from+argc, + cur_pos+1); +} + int cmd_list ( int argc, char ** argv, struct mpd_connection *conn ) { enum mpd_tag_type type; diff --git a/src/command.h b/src/command.h index 325f0ff..63bafa5 100644 --- a/src/command.h +++ b/src/command.h @@ -45,6 +45,7 @@ int cmd_listall(int argc, char **argv, struct mpd_connection *conn); int cmd_ls(int argc, char **argv, struct mpd_connection *conn); int cmd_lsplaylists(int argc, char **argv, struct mpd_connection *conn); int cmd_load(int argc, char **argv, struct mpd_connection *conn); +int cmd_insert(int argc, char **argv, struct mpd_connection *conn); int cmd_list(int argc, char **argv, struct mpd_connection *conn); int cmd_save(int argc, char **argv, struct mpd_connection *conn); int cmd_rm(int argc, char **argv, struct mpd_connection *conn); diff --git a/src/main.c b/src/main.c index f0532f4..8aac65c 100644 --- a/src/main.c +++ b/src/main.c @@ -81,6 +81,7 @@ static struct command { {"ls", 0, -1, 2,cmd_ls, "[]", "List the contents of "}, {"lsplaylists", 0, -1, 2,cmd_lsplaylists, "", "List currently available playlists"}, {"load",0, -1, 1,cmd_load,"", "Load as a playlist"}, + {"insert", 0, -1, 1,cmd_insert, "", "Insert a song to the current playlist after the current track"}, {"save",1, 1, 0,cmd_save,"", "Save a playlist as "}, {"rm", 1, 1, 0,cmd_rm, "", "Remove a playlist"}, {"volume", 0, 1, 0,cmd_volume, "[+-]", "Set volume to or adjusts by [+-]"}, -- 1.7.3.4 pgpQLPVaXCETN.pgp Description: PGP signature -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
On Mon, Apr 25, 2011 at 03:37:16PM +1000, Olivier Mehani wrote: > On Mon, Apr 25, 2011 at 07:02:46AM +0200, Kurt Van Dijck wrote: > > > The queue command works similarly to add (in fact, it's a wrapper around > > > it), except it places the newly added song(s) just after the currently > > > playing one, rather than at the end. > > Some terminology: > > Is 'queue' the right term for that? 'insert' explains IMHO better the > > action. > > Indeed, I had a doubt about the term 'queue', as it conflicts with MPD's > internal concept. I kept with the term as it matches the one I've seen > most other music players use (that, or enqueue). > > I agree however that insert seems to be the most appropriate term. > I just didn't think of it. That can happen :-) > Feel free to s/queue/insert/g* on my patch if it gets merged in! I believe it's better you recreate the patch (I'm not maintainer neither). > > I realise I also forgot to update the manpage with respect to the new > command, but the commit message from the patch should be close to > sufficient. see above. > > (Keep CCing me on followups.) Kind regards, Kurt -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd ___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
On Mon, Apr 25, 2011 at 07:02:46AM +0200, Kurt Van Dijck wrote: > > The queue command works similarly to add (in fact, it's a wrapper around > > it), except it places the newly added song(s) just after the currently > > playing one, rather than at the end. > Some terminology: > Is 'queue' the right term for that? 'insert' explains IMHO better the action. Indeed, I had a doubt about the term 'queue', as it conflicts with MPD's internal concept. I kept with the term as it matches the one I've seen most other music players use (that, or enqueue). I agree however that insert seems to be the most appropriate term. I just didn't think of it. Feel free to s/queue/insert/g* on my patch if it gets merged in! I realise I also forgot to update the manpage with respect to the new command, but the commit message from the patch should be close to sufficient. *This RE is only given for illustration purposes, don't try it at home (; (Keep CCing me on followups.) -- Olivier Mehani PGP fingerprint: 4435 CF6A 7C8D DD9B E2DE F5F9 F012 A6E2 98C6 6655 pgpNWpx5OuO0y.pgp Description: PGP signature -- Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Re: [Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
On Mon, Apr 25, 2011 at 04:32:33AM +1000, Olivier Mehani wrote: > The queue command works similarly to add (in fact, it's a wrapper around > it), except it places the newly added song(s) just after the currently > playing one, rather than at the end. Some terminology: Is 'queue' the right term for that? 'insert' explains IMHO better the action. Kurt -- Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails ___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
[Musicpd-dev-team] [PATCH] Add a 'queue' command to mpc
The queue command works similarly to add (in fact, it's a wrapper around it), except it places the newly added song(s) just after the currently playing one, rather than at the end. Signed-off-by: Olivier Mehani (Please CC me on related discussions, as I'm not subscribed to the list.) --- src/command.c | 19 +++ src/command.h |1 + src/main.c|1 + 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/command.c b/src/command.c index bafddb7..7715049 100644 --- a/src/command.c +++ b/src/command.c @@ -731,6 +731,25 @@ int cmd_load ( int argc, char ** argv, struct mpd_connection *conn ) return 0; } +int cmd_queue (int argc, char ** argv, struct mpd_connection *conn ) +{ + int ret; + struct mpd_status *status = mpd_run_status(conn); + if (status == NULL) + printErrorAndExit(conn); + + const int from = mpd_status_get_queue_length(status); + + ret = cmd_add(argc, argv, conn); + const int cur_pos = mpd_status_get_song_pos(status); + mpd_status_free(status); + if (ret != 0) { + return ret; + } + return mpd_run_move_range(conn, from, from+argc, + cur_pos+1); +} + int cmd_list ( int argc, char ** argv, struct mpd_connection *conn ) { enum mpd_tag_type type; diff --git a/src/command.h b/src/command.h index 325f0ff..09cf384 100644 --- a/src/command.h +++ b/src/command.h @@ -45,6 +45,7 @@ int cmd_listall(int argc, char **argv, struct mpd_connection *conn); int cmd_ls(int argc, char **argv, struct mpd_connection *conn); int cmd_lsplaylists(int argc, char **argv, struct mpd_connection *conn); int cmd_load(int argc, char **argv, struct mpd_connection *conn); +int cmd_queue(int argc, char **argv, struct mpd_connection *conn); int cmd_list(int argc, char **argv, struct mpd_connection *conn); int cmd_save(int argc, char **argv, struct mpd_connection *conn); int cmd_rm(int argc, char **argv, struct mpd_connection *conn); diff --git a/src/main.c b/src/main.c index f0532f4..0c93608 100644 --- a/src/main.c +++ b/src/main.c @@ -81,6 +81,7 @@ static struct command { {"ls", 0, -1, 2,cmd_ls, "[]", "List the contents of "}, {"lsplaylists", 0, -1, 2,cmd_lsplaylists, "", "List currently available playlists"}, {"load",0, -1, 1,cmd_load,"", "Load as a playlist"}, + {"queue", 0, -1, 1,cmd_queue, "", "Add a song to the current playlist, just after the current track"}, {"save",1, 1, 0,cmd_save,"", "Save a playlist as "}, {"rm", 1, 1, 0,cmd_rm, "", "Remove a playlist"}, {"volume", 0, 1, 0,cmd_volume, "[+-]", "Set volume to or adjusts by [+-]"}, -- 1.7.3.4 -- Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails ___ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team