rpms/mikmod/F-8 libmikmod-esd.patch,1.4,1.5 mikmod.spec,1.35,1.36

Hans de Goede (jwrdegoede) fedora-extras-commits at redhat.com
Mon Feb 18 16:10:19 UTC 2008


Author: jwrdegoede

Update of /cvs/extras/rpms/mikmod/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv28873

Modified Files:
	libmikmod-esd.patch mikmod.spec 
Log Message:
* Mon Feb 18 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 3.2.2-4
- Add BuildRequires esound-devel, so that the esd output driver gets build
- Replace completely braindead (hint to author, drink coffee first, then code)
  esd non blocking patch with one that actually works. This fixes using mikmod
  with pulseaudio (bz 247865)
- Note: this makes the 2 supported output devices oss and esd (and pulseaudio's
  esd emulation) alsa is not supported, this requires a rewrite of the mikmod
  alsa code which was written for alsa-0.5 and never updated for the new alsa
  0.9/1.0 api


libmikmod-esd.patch:

Index: libmikmod-esd.patch
===================================================================
RCS file: /cvs/extras/rpms/mikmod/F-8/libmikmod-esd.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- libmikmod-esd.patch	21 Apr 2007 20:42:49 -0000	1.4
+++ libmikmod-esd.patch	18 Feb 2008 16:10:09 -0000	1.5
@@ -1,6 +1,98 @@
---- mikmod-3.1.6/libmikmod-3.1.11/drivers/drv_esd.c.esd	2004-08-04 05:04:58.990630968 +0200
-+++ mikmod-3.1.6/libmikmod-3.1.11/drivers/drv_esd.c	2004-08-04 05:05:32.940469808 +0200
-@@ -127,20 +127,19 @@
+--- libmikmod-3.2.0-beta2/libmikmod-3.1.11/drivers/drv_esd.c	2004-01-31 23:39:40.000000000 +0100
++++ libmikmod-3.2.0-beta2.new/libmikmod-3.1.11/drivers/drv_esd.c	2008-02-18 12:09:07.000000000 +0100
+@@ -81,7 +81,6 @@
+ 
+ static	int sndfd=-1;
+ static	esd_format_t format;
+-static	SBYTE *audiobuffer=NULL;
+ static	CHAR *espeaker=NULL;
+ 
+ #ifdef MIKMOD_DYNAMIC
+@@ -100,7 +99,7 @@
+ 	if (libesd) return 0;
+ 
+ 	/* load libesd.so */
+-	libesd=dlopen("libesd.so",RTLD_LAZY|RTLD_GLOBAL);
++	libesd=dlopen("libesd.so.0",RTLD_LAZY|RTLD_GLOBAL);
+ 	if (!libesd) return 1;
+ 
+ 	/* resolve function references */
+@@ -124,23 +123,88 @@
+ }
+ #endif
+ 
++/* A simple chunk fifo buffer, as we cannot query to ask how much free space
++   there is with esd, we keep a fifo filled and try to write the entire fifo
++   non blocking, stopping when we get -EAGAIN */
++
++#define AUDIO_BUF_SIZE (ESD_BUF_SIZE * 4)
++
++static SBYTE audiobuffer[AUDIO_BUF_SIZE];
++static int audiobuffer_start, audiobuffer_end, audiobuffer_empty;
++
++static void audiobuffer_init(void)
++{
++	audiobuffer_empty = 1;
++	audiobuffer_start = audiobuffer_end = 0;
++}
++
++/* Get a free chunk of the fifo, the caller is expected to use all of it, so
++   all of it gets marked filled */
++static SBYTE *audiobuffer_get_free_chunk(int *size)
++{
++	int end = audiobuffer_end;
++
++	if (audiobuffer_empty)
++	{
++		audiobuffer_empty = 0;
++		*size = AUDIO_BUF_SIZE;
++	}
++	else if (audiobuffer_end > audiobuffer_start)
++	{
++		*size = AUDIO_BUF_SIZE - audiobuffer_end;
++		audiobuffer_end = 0;
++	}
++	else
++	{
++		*size = audiobuffer_start - audiobuffer_end;
++		audiobuffer_end = audiobuffer_start;
++	}
++
++	return audiobuffer + end;
++}
++
++/* Get a filled chunk from the fifo, the caller must call audiobuffer_mark_free
++   to tell the fifo how much of the chunk it has consumed */
++static SBYTE *audiobuffer_get_filled_chunk(int *size)
++{
++	if (audiobuffer_empty)
++	{
++		*size = 0;
++	}
++	else if (audiobuffer_end > audiobuffer_start)
++	{
++		*size = audiobuffer_end - audiobuffer_start;
++	}
++	else
++	{
++		*size = AUDIO_BUF_SIZE - audiobuffer_start;
++	}
++
++	return audiobuffer + audiobuffer_start;
++}
++
++/* Tell the fifo to mark size bytes as free starting from the current head of
++   the fifo */
++static void audiobuffer_mark_free(int size)
++{
++	audiobuffer_start = (audiobuffer_start + size) % AUDIO_BUF_SIZE;
++	if (audiobuffer_start == audiobuffer_end)
++	{
++		audiobuffer_empty = 1;
++		audiobuffer_start = audiobuffer_end = 0;
++	}
++}
++
  /* I hope to have this function integrated into libesd someday...*/
  static ssize_t esd_writebuf(int fd,const void *buffer,size_t count)
  {
@@ -9,15 +101,9 @@
  
 -	while (start<count) {
 -		ssize_t res;
-+	res=write(fd,(char*)buffer,count);
-+	if (res<0)
-+		switch (errno) {
-+			case EAGAIN:
-+				return 0;
-+			case EPIPE:
-+				/* connection lost */
-+				return -1-res;
-+		}
++	res = write(fd, (char*)buffer, count);
++	if (res < 0 && errno == EAGAIN)
++		return 0;
  
 -		res=write(fd,(char*)buffer+start,count-start);
 -		if (res<0) {
@@ -32,7 +118,7 @@
  }
  
  static void ESD_CommandLine(CHAR *cmdline)
-@@ -193,6 +192,7 @@
+@@ -193,13 +257,14 @@
  			_mm_errno=MMERR_OPENING_AUDIO;
  			return 1;
  		}
@@ -40,62 +126,113 @@
  	} else {
  		_mm_errno=MMERR_OUT_OF_MEMORY;
  		return 1;
-@@ -234,19 +234,22 @@
+ 	}
+-
+-	if (!(audiobuffer=(SBYTE*)_mm_malloc(ESD_BUF_SIZE*sizeof(char))))
+-		return 1;
++	
++	/* Initialize the audiobuffer */
++	audiobuffer_init();
+ 
+ 	return VC_Init();
+ }
+@@ -218,7 +283,6 @@
+ static void ESD_Exit_internal(void)
+ {
+ 	VC_Exit();
+-	_mm_free(audiobuffer);
+ 	if (sndfd>=0) {
+ 		esd_closestream(sndfd);
+ 		sndfd=-1;
+@@ -234,19 +298,50 @@
  #endif
  }
  
 -static void ESD_Update_internal(int count)
-+static void ESD_Update(void)
++typedef ULONG (*VC_WriteBytesFunc)(SBYTE*, ULONG);
++
++static void ESD_Update_internal(VC_WriteBytesFunc WriteBytes)
  {
  	static time_t losttime;
-+	int done;
  
  	if (sndfd>=0) {
 -		if (esd_writebuf(sndfd,audiobuffer,count)<0) {
-+		done=esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+		if (done<0) {
- 			/* if we lost our connection with esd, clean up and work as the
- 			   nosound driver until we can reconnect */
- 			esd_closestream(sndfd);
- 			sndfd=-1;
- 			signal(SIGPIPE,SIG_DFL);
- 			losttime=time(NULL);
--		}
-+		} else
-+			VC_WriteBytes(audiobuffer,done);
+-			/* if we lost our connection with esd, clean up and work as the
+-			   nosound driver until we can reconnect */
+-			esd_closestream(sndfd);
+-			sndfd=-1;
+-			signal(SIGPIPE,SIG_DFL);
+-			losttime=time(NULL);
++		SBYTE *chunk;
++		int size;
++		ssize_t written;
++		
++		/* Fill fifo */
++		chunk = audiobuffer_get_free_chunk(&size);
++		while (size)
++		{
++			WriteBytes(chunk, size);
++			chunk = audiobuffer_get_free_chunk(&size);
+ 		}
++
++		/* And write untill fifo empty, or we would block */
++		chunk = audiobuffer_get_filled_chunk(&size);
++		while (size)
++		{
++			written = esd_writebuf(sndfd, chunk, size);
++			if (written < 0)
++			{
++				/* if we lost our connection with esd, clean up
++				   and work as the nosound driver until we can
++				   reconnect */
++				esd_closestream(sndfd);
++				sndfd = -1;
++				signal(SIGPIPE, SIG_DFL);
++				losttime = time(NULL);
++				break;
++			}
++			
++			/* Stop if the buffer is full */
++			if (written == 0)
++				break;
++
++			audiobuffer_mark_free(written);
++
++			chunk = audiobuffer_get_filled_chunk(&size);
++		}		
  	} else {
  		/* an alarm would be better, but then the library user could not use
  		   alarm(2) himself... */
-@@ -255,31 +258,32 @@
+@@ -255,8 +350,11 @@
  			/* Attempt to reconnect every 5 seconds */
  			if (!(SETENV))
  				if ((sndfd=esd_playstream(format,md_mixfreq,espeaker,"libmikmod"))>=0) {
 -					VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
 -					esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
++					/* reconnected, clear fifo (contains old sound) and recurse
++					   to play sound */
++					audiobuffer_init();
 +					fcntl(sndfd, F_SETFL, fcntl(sndfd, F_GETFL) | O_NONBLOCK);
-+					done=esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+					if(done>0)
-+						VC_SilenceBytes(audiobuffer,done);
++					ESD_Update_internal(WriteBytes);
  				}
  		}
  	}
- }
+@@ -264,22 +362,24 @@
  
--static void ESD_Update(void)
--{
+ static void ESD_Update(void)
+ {
 -	ESD_Update_internal(VC_WriteBytes(audiobuffer,ESD_BUF_SIZE));
--}
--
++	ESD_Update_internal(VC_WriteBytes);
+ }
+ 
  static void ESD_Pause(void)
  {
 -	ESD_Update_internal(VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE));
-+	VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
++	ESD_Update_internal(VC_SilenceBytes);
  }
  
  static BOOL ESD_PlayStart(void)
  {
-+	int done;
-+
  	if (sndfd<0)
 -		if (!(SETENV))
 +		if (!(SETENV)) {
@@ -108,28 +245,19 @@
  	/* since the default behaviour of SIGPIPE on most Unices is to kill the
  	   program, we'll prefer handle EPIPE ourselves should the esd die - recent
  	   esdlib use a do-nothing handler, which prevents us from receiving EPIPE,
-@@ -287,18 +291,20 @@
- 	signal(SIGPIPE,SIG_IGN);
- 
+@@ -289,6 +389,7 @@
  	/* silence buffers */
--	VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
--	esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+	done=esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+	VC_SilenceBytes(audiobuffer,done);
+ 	VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
+ 	esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
++	audiobuffer_init();
  
  	return VC_PlayStart();
  }
- 
- static void ESD_PlayStop(void)
- {
-+	int done;
-+
- 	if (sndfd>=0) {
+@@ -299,6 +400,7 @@
  		/* silence buffers */
--		VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
--		esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+		done=esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
-+		VC_SilenceBytes(audiobuffer,done);
+ 		VC_SilenceBytes(audiobuffer,ESD_BUF_SIZE);
+ 		esd_writebuf(sndfd,audiobuffer,ESD_BUF_SIZE);
++		audiobuffer_init();
  
  		signal(SIGPIPE,SIG_DFL);
  	}


Index: mikmod.spec
===================================================================
RCS file: /cvs/extras/rpms/mikmod/F-8/mikmod.spec,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mikmod.spec	23 Aug 2007 06:45:52 -0000	1.35
+++ mikmod.spec	18 Feb 2008 16:10:09 -0000	1.36
@@ -3,11 +3,11 @@
 Summary: A MOD music file player
 Name: mikmod
 Version: 3.2.2
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPLv2 and LGPLv2+
 Group: Applications/Multimedia
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: ncurses-devel texinfo
+BuildRequires: ncurses-devel texinfo esound-devel
 URL: http://mikmod.raphnet.net/
 Source0: http://mikmod.raphnet.net/files/mikmod-%{version}-beta1.tar.gz
 Source1: http://mikmod.raphnet.net/files/libmikmod-%{lversion}.tar.gz
@@ -104,6 +104,16 @@
 %{_mandir}/man1/libmikmod-config*
 
 %changelog
+* Mon Feb 18 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 3.2.2-4
+- Add BuildRequires esound-devel, so that the esd output driver gets build
+- Replace completely braindead (hint to author, drink coffee first, then code)
+  esd non blocking patch with one that actually works. This fixes using mikmod
+  with pulseaudio (bz 247865)
+- Note: this makes the 2 supported output devices oss and esd (and pulseaudio's
+  esd emulation) alsa is not supported, this requires a rewrite of the mikmod
+  alsa code which was written for alsa-0.5 and never updated for the new alsa
+  0.9/1.0 api
+
 * Thu Aug 23 2007 Jindrich Novy <jnovy at redhat.com> 3.2.2-3
 - update License
 - rebuild for BuildID




More information about the fedora-extras-commits mailing list