[Alsaplayer-devel]Re: patch to loop songs.

Patrick Shirkey pshirkey@boosthardware.com
Fri, 22 Jun 2001 05:16:24 -0400


Alsaplayer can now loop the playlist but if a song is started manually
while the function is on it is turned off. To fix this we would need a
way to save the state in the preferences dialog. So I will look into
getting that up and running now too.

-----------------
diff -u -r alsaplayer-0.99.33-pre3/AUTHORS
alsa/alsaplayer-0.99.33-pre3/AUTHORS
--- alsaplayer-0.99.33-pre3/AUTHORS	Fri Apr 14 14:57:00 2000
+++ alsa/alsaplayer-0.99.33-pre3/AUTHORS	Fri Jun 22 04:35:05 2001
@@ -16,3 +16,5 @@
 Ralph Loader enhanced the Monoscope a great deal
 
 Erik Inge Bolsų wrote the NAS plugin
+
+Loop functionality is by Patrick Shirkey
\ No newline at end of file
Only in alsa/alsaplayer-0.99.33-pre3: AUTHORS~
Only in alsa/alsaplayer-0.99.33-pre3: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/app: .libs
Only in alsa/alsaplayer-0.99.33-pre3/app: AlsaNode.o
Only in alsa/alsaplayer-0.99.33-pre3/app: AlsaSubscriber.o
diff -u -r alsaplayer-0.99.33-pre3/app/CorePlayer.cpp
alsa/alsaplayer-0.99.33-pre3/app/CorePlayer.cpp
--- alsaplayer-0.99.33-pre3/app/CorePlayer.cpp	Tue Dec 28 22:59:02 1999
+++ alsa/alsaplayer-0.99.33-pre3/app/CorePlayer.cpp	Tue Jun 19 01:49:12
2001
@@ -262,7 +262,6 @@
 	if (read_buf && plugin && the_object) {
 		if (read_buf->start < 0)
 			return 0;		
-
 		int frame_size = plugin->frame_size(the_object);
 		if (frame_size) 
 			return (read_buf->start + (read_buf->buf->GetReadIndex() * 4) /
frame_size);
Only in alsa/alsaplayer-0.99.33-pre3/app: CorePlayer.cpp~
Only in alsa/alsaplayer-0.99.33-pre3/app: CorePlayer.o
Only in alsa/alsaplayer-0.99.33-pre3/app: Effects.o
Only in alsa/alsaplayer-0.99.33-pre3/app: EffectsWindow.o
Only in alsa/alsaplayer-0.99.33-pre3/app: Main.o
Only in alsa/alsaplayer-0.99.33-pre3/app: Makefile
diff -u -r alsaplayer-0.99.33-pre3/app/Playlist.cpp
alsa/alsaplayer-0.99.33-pre3/app/Playlist.cpp
--- alsaplayer-0.99.33-pre3/app/Playlist.cpp	Fri Apr 14 12:31:58 2000
+++ alsa/alsaplayer-0.99.33-pre3/app/Playlist.cpp	Fri Jun 22 04:56:58
2001
@@ -51,7 +51,12 @@
 
 	while(pl->active) {
 		if (!coreplayer->IsActive() && global_playing) {
-			pl->Next();
+		      if (global_playing == 3){
+		      coreplayer->Start(0);
+		      }	      
+		      else{
+		      pl->Next();
+		      }
 		}
 		dosleep(50000);
 	}
@@ -203,6 +208,12 @@
 			PlayFile(queue[curritem - 1]);
 		}
 	}
+	//start from beginning if loop Playlist is set
+	//global_playing = 4
+
+	if (global_playing == 4 && curritem == queue.size()){
+	    curritem = 0;
+	 }
 
 	// Tell the subscribing interfaces about the change
 	if(curritem != olditem) {
Only in alsa/alsaplayer-0.99.33-pre3/app: Playlist.cpp~
Only in alsa/alsaplayer-0.99.33-pre3/app: Playlist.o
Only in alsa/alsaplayer-0.99.33-pre3/app: PlaylistWindow.o
Only in alsa/alsaplayer-0.99.33-pre3/app: SampleBuffer.o
Only in alsa/alsaplayer-0.99.33-pre3/app: ScopesWindow.o
Only in alsa/alsaplayer-0.99.33-pre3/app: alsaplayer
Only in alsa/alsaplayer-0.99.33-pre3/app: convolve.o
Only in alsa/alsaplayer-0.99.33-pre3/app: fft.o
diff -u -r alsaplayer-0.99.33-pre3/app/gladesrc.cpp
alsa/alsaplayer-0.99.33-pre3/app/gladesrc.cpp
--- alsaplayer-0.99.33-pre3/app/gladesrc.cpp	Wed Sep 29 19:39:08 1999
+++ alsa/alsaplayer-0.99.33-pre3/app/gladesrc.cpp	Sat Jun 16 15:11:20
2001
@@ -173,6 +173,7 @@
   GtkWidget *audio_control_box;
   GtkWidget *hbox34;
   GtkWidget *hbox36;
+  GtkWidget *loop_button;
   GtkWidget *pause_button;
   GtkWidget *reverse_button;
   GtkWidget *forward_button;
@@ -281,6 +282,12 @@
   gtk_object_set_data (GTK_OBJECT (main_window), "hbox36", hbox36);
   gtk_widget_show (hbox36);
   gtk_box_pack_start (GTK_BOX (hbox34), hbox36, FALSE, FALSE, 0);
+
+  loop_button = gtk_button_new ();
+  gtk_object_set_data (GTK_OBJECT (main_window), "loop_button",
loop_button);
+  gtk_widget_show (loop_button);
+  gtk_box_pack_start (GTK_BOX (hbox36), loop_button, TRUE, TRUE, 0);
+  gtk_widget_set_usize (loop_button, 22, 20);
 
   pause_button = gtk_button_new ();
   gtk_object_set_data (GTK_OBJECT (main_window), "pause_button",
pause_button);
Only in alsa/alsaplayer-0.99.33-pre3/app: gladesrc.cpp~
Only in alsa/alsaplayer-0.99.33-pre3/app: gladesrc.o
diff -u -r alsaplayer-0.99.33-pre3/app/gtk_interface.cpp
alsa/alsaplayer-0.99.33-pre3/app/gtk_interface.cpp
--- alsaplayer-0.99.33-pre3/app/gtk_interface.cpp	Sun Dec 10 20:46:36
2000
+++ alsa/alsaplayer-0.99.33-pre3/app/gtk_interface.cpp	Fri Jun 22
05:03:13 2001
@@ -39,6 +39,7 @@
 #include "pixmaps/next.xpm"
 #include "pixmaps/prev.xpm"
 #include "pixmaps/stop.xpm"
+#include "pixmaps/loop.xpm"
 #include "pixmaps/volume_icon.xpm"
 #include "pixmaps/balance_icon.xpm"
 #if 0
@@ -474,7 +475,6 @@
 #endif
 }
 
-
 void pause_cb(GtkWidget *widget, gpointer data)
 {
 	GtkAdjustment *adj;
@@ -514,11 +514,64 @@
 	if (p) {
 		global_playing = 1;
 		eject_cb(widget, data);
-	}	
+	}      	
 }
 
 
-void eject_cb(GtkWidget *wdiget, gpointer data)
+void loop_cb(GtkWidget *widget, gpointer data)
+{
+      stream_info info;
+      CorePlayer *p = (CorePlayer *)data;
+      int g;
+
+      // Stops CorePlayer from searching for
+      // a plugin if not playing
+
+       	if (!p->IsPlaying()) {
+	  global_playing = 0; 
+       	} 
+
+	// Sets global_playing to 3 if not already set
+	// Playlist_looper uses this to decide what to do
+
+	if (p && global_playing != 3) {
+		g = 3;	  
+	} else {
+	        g = 1;
+	}
+            global_playing = g;
+
+	    // 	while (g == 3){
+	//	sprintf(info.loop,  "Loop" );
+       	//	draw_loop(info.loop, "Loop" );
+	    //	}
+}
+
+void loop_Playlist_cb(GtkWidget *widget, gpointer data)
+{
+      CorePlayer *p = (CorePlayer *)data;
+      int g;
+
+      // Stops CorePlayer from searching for
+      // a plugin if not playing
+
+       	if (!p->IsPlaying()) {
+	  global_playing = 0; 
+       	} 
+
+	// Sets global_playing to 4 if not already set
+	// Playlist_looper uses this to decide what to do
+
+	if (p && global_playing != 4) {
+		g = 4;	  
+	} else {
+	  g = 1;
+	}
+            global_playing = g;
+
+}
+
+void eject_cb(GtkWidget *widget, gpointer data)
 {
 	CorePlayer *p = (CorePlayer *)data;
 	if (p) {
@@ -956,7 +1009,7 @@
 
 void init_main_window(CorePlayer *p)
 {
-	GtkWidget *root_menu;
+	GtkWidget *root_menu; 
 	GtkWidget *menu_item;
 	GtkWidget *main_window;
 	GtkWidget *effects_window;
@@ -1048,6 +1101,15 @@
 	gtk_button_set_relief(GTK_BUTTON(working), 
 						  global_rb ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL);
 
+	working = get_widget(main_window, "loop_button");
+	pix = xpm_label_box(loop_xpm, main_window);
+	gtk_widget_show(pix);
+	gtk_container_add(GTK_CONTAINER(working), pix);
+	gtk_signal_connect(GTK_OBJECT(working), "clicked",
+					   GTK_SIGNAL_FUNC(loop_cb), p);
+	gtk_button_set_relief(GTK_BUTTON(working), 
+						  global_rb ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL);
+
 	working = get_widget(main_window, "pause_button");
 	pix = xpm_label_box(pause_xpm, main_window);
 	gtk_widget_show(pix);
@@ -1234,6 +1296,23 @@
 	gtk_widget_show(menu_item);
 	gtk_widget_set_sensitive(menu_item, false);
 
+	// Separator
+	menu_item = gtk_menu_item_new();
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_widget_show(menu_item);
+
+	// loop song
+	menu_item = gtk_menu_item_new_with_label("Loop song");
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
+					   GTK_SIGNAL_FUNC(loop_cb), p);
+	gtk_widget_show(menu_item);
+	// loop playlist
+	menu_item = gtk_menu_item_new_with_label("Loop playlist");
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
+					   GTK_SIGNAL_FUNC(loop_Playlist_cb), p);
+	gtk_widget_show(menu_item);
 #if 1	
 	// Separator
 	menu_item = gtk_menu_item_new();
@@ -1256,7 +1335,6 @@
 					   GTK_SIGNAL_FUNC(cd_cb), p);
 #endif
 
-
 	// Separator
 	menu_item = gtk_menu_item_new();
 	gtk_menu_append(GTK_MENU(root_menu), menu_item);
@@ -1267,6 +1345,7 @@
 	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
 					   GTK_SIGNAL_FUNC(exit_cb), NULL);
 	gtk_widget_show(menu_item);
+
 #if 0	
 	// Connect popup menu
 	working = get_widget(main_window, "scope_button");
@@ -1281,6 +1360,7 @@
 	gtk_menu_append(GTK_MENU(cd_menu), menu_item);
 	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
 					   GTK_SIGNAL_FUNC(cd_cb), p);
+
 #ifdef HAVE_SOCKMON
 	menu_item = gtk_menu_item_new_with_label("Monitor TCP socket
(experimental)");
 	gtk_widget_show(menu_item);
Only in alsa/alsaplayer-0.99.33-pre3/app: gtk_interface.cpp~
Only in alsa/alsaplayer-0.99.33-pre3/app: gtk_interface.o
Only in alsa/alsaplayer-0.99.33-pre3/app/gui: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/app/pixmaps: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/app/pixmaps: loop.xpm
Only in alsa/alsaplayer-0.99.33-pre3/app: reverbst.o
Only in alsa/alsaplayer-0.99.33-pre3/app: utilities.o
Only in alsa/alsaplayer-0.99.33-pre3: config.cache
Only in alsa/alsaplayer-0.99.33-pre3: config.h
Only in alsa/alsaplayer-0.99.33-pre3: config.log
Only in alsa/alsaplayer-0.99.33-pre3: config.status
Only in alsa/alsaplayer-0.99.33-pre3: core
Only in alsa/alsaplayer-0.99.33-pre3/docs: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/extra: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/include: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/audiofile: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/cdda: .libs
Only in alsa/alsaplayer-0.99.33-pre3/input/cdda: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/cdda: cdda_engine.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/cdda: cdda_engine.o
Only in alsa/alsaplayer-0.99.33-pre3/input/cdda: libcdda.la
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: .libs
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: drv_alsaplayer.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: drv_alsaplayer.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: libmod.la
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: mikmod_engine.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mikmod: mikmod_engine.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: .libs
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: common.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: common.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: dct64_i386.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: dct64_i386.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_2to1.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_2to1.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_4to1.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_4to1.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_i386.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_i386.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_i586.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_i586.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_ntom.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: decode_ntom.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: equalizer.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: equalizer.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: getbits.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: getbits.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: httpget.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: httpget.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer1.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer1.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer2.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer2.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer3.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: layer3.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: libmpg123.la
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: mpg123_engine.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: mpg123_engine.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: readers.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: readers.o
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: tabinit.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/mpg123: tabinit.o
Only in alsa/alsaplayer-0.99.33-pre3/input/vorbis: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/wav: .libs
Only in alsa/alsaplayer-0.99.33-pre3/input/wav: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/input/wav: libwav.la
Only in alsa/alsaplayer-0.99.33-pre3/input/wav: wav_engine.lo
Only in alsa/alsaplayer-0.99.33-pre3/input/wav: wav_engine.o
Only in alsa/alsaplayer-0.99.33-pre3: libtool
Only in alsa/alsaplayer-0.99.33-pre3/output: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-0.5.x: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-final: .libs
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-final: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-final: alsa.lo
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-final: alsa.o
Only in alsa/alsaplayer-0.99.33-pre3/output/alsa-final: libalsa.la
Only in alsa/alsaplayer-0.99.33-pre3/output/esound: .libs
Only in alsa/alsaplayer-0.99.33-pre3/output/esound: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/esound: esound.lo
Only in alsa/alsaplayer-0.99.33-pre3/output/esound: esound.o
Only in alsa/alsaplayer-0.99.33-pre3/output/esound: libesound.la
Only in alsa/alsaplayer-0.99.33-pre3/output/nas: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/null: .libs
Only in alsa/alsaplayer-0.99.33-pre3/output/null: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/null: libnull.la
Only in alsa/alsaplayer-0.99.33-pre3/output/null: null.lo
Only in alsa/alsaplayer-0.99.33-pre3/output/null: null.o
Only in alsa/alsaplayer-0.99.33-pre3/output/oss: .libs
Only in alsa/alsaplayer-0.99.33-pre3/output/oss: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/oss: liboss.la
Only in alsa/alsaplayer-0.99.33-pre3/output/oss: oss.lo
Only in alsa/alsaplayer-0.99.33-pre3/output/oss: oss.o
Only in alsa/alsaplayer-0.99.33-pre3/output/sgi: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/output/sparc: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/barfft: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/barfft: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/barfft: barfft.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/barfft: barfft.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/barfft: libbarfft.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/fftscope: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/fftscope: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/fftscope: fftscope.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/fftscope: fftscope.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/fftscope: libfftscope.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/levelmeter: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/levelmeter: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/levelmeter: levelmeter.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/levelmeter: levelmeter.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/levelmeter: liblevelmeter.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/logbarfft: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/logbarfft: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/logbarfft: liblogbarfft.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/logbarfft: logbarfft.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/logbarfft: logbarfft.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/monoscope: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/monoscope: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/monoscope: libmonoscope.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/monoscope: monoscope.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/monoscope: monoscope.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/spacescope: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/spacescope: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/spacescope: libspacescope.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/spacescope: spacescope.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/spacescope: spacescope.o
Only in alsa/alsaplayer-0.99.33-pre3/scopes/synaescope: .libs
Only in alsa/alsaplayer-0.99.33-pre3/scopes/synaescope: Makefile
Only in alsa/alsaplayer-0.99.33-pre3/scopes/synaescope: libsynaescope.la
Only in alsa/alsaplayer-0.99.33-pre3/scopes/synaescope: synaescope.lo
Only in alsa/alsaplayer-0.99.33-pre3/scopes/synaescope: synaescope.o
Only in alsa/alsaplayer-0.99.33-pre3: stamp-h
---------------

also: cp ~/apps/pixmaps/loop.xpm

-----------
/* XPM */
static char * loop_xpm[] = {
"12 11 3 1",
" 	c None",
".	c #050202",
"+	c #939292",
"        .   ",
"       ..   ",
"      .+.   ",
"     .++....",
"... .++++++.",
".+........+.",
".+.      .+.",
".+........+.",
".++++++++++.",
"............",
"            ",
"            "};

------------





-- 
Patrick Shirkey - Manager Boost Hardware.
Importing Korean Computer Hardware to New Zealand.

Http://www.boosthardware.com for cool toys to fufill every geeks
fantasy.