rpms/squeak-vm/F-12 alsa-suspend-resume.patch, NONE, 1.1 squeak-vm.spec, 1.5, 1.6

Daniel Drake dsd at fedoraproject.org
Mon Jun 21 22:15:28 UTC 2010


Author: dsd

Update of /cvs/pkgs/rpms/squeak-vm/F-12
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv12775

Modified Files:
	squeak-vm.spec 
Added Files:
	alsa-suspend-resume.patch 
Log Message:
fix ALSA vs suspend/resume

alsa-suspend-resume.patch:
 sqUnixSoundALSA-100614.c |   94 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 64 insertions(+), 30 deletions(-)

--- NEW FILE alsa-suspend-resume.patch ---
Fix bug: sound is lost after a suspend/resume cycle.

http://dev.laptop.org/ticket/10168
Patch comes from squeak upstream

--- Squeak-3.10-5/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c	2008-04-21 22:48:26.000000000 +0100
+++ Squeak-3.10-5/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA-100614.c	2010-06-14 12:22:13.000000000 +0100
@@ -77,6 +77,7 @@
 static snd_pcm_uframes_t	 output_buffer_size= 0;
 static double			 max_delay_frames= 0;
 
+
 static void output_callback(snd_async_handler_t *handler)
 {
   signalSemaphoreWithIndex(output_semaphore);
@@ -135,7 +136,8 @@
   if ((err= snd_pcm_start(output_handle)) < 0)
     {
       if (err != -EPIPE)
-	{
+/*      if ((err != -EPIPE) & (err != -ESTRPIPE))
+*/	{
 	  fprintf(stderr, "snd_pcm_start(1): %s\n", snd_strerror(err));
 	  success(false);
 	  return 0;
@@ -148,7 +150,8 @@
   if ((err= snd_pcm_start(output_handle)) < 0)
     {
       if (err != -EPIPE)
-	{
+/*      if ((err != -EPIPE) & (err != -ESTRPIPE))
+*/	{
 	  fprintf(stderr, "snd_pcm_start(2): %s\n", snd_strerror(err));
 	  success(false);
 	  return 0;
@@ -199,28 +203,44 @@
 
 static sqInt  sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt arrayIndex, sqInt startIndex)
 {
-  if (output_handle)
-    {
-      void *samples= (void *)arrayIndex + startIndex * output_channels * 2;
-      int   count=   snd_pcm_writei(output_handle, samples, frameCount);
-      if (count < frameCount / 2)
-	{
-	  output_buffer_frames_available= 0;
-	}
-      if (count < 0)
-	{
-	  if (count == -EPIPE)    /* underrun */
-	    {
-	      int err;
-	      snd(pcm_prepare(output_handle), "sound_PlaySamples: snd_pcm_prepare");
-	      return 0;
-	    }
-	  fprintf(stderr, "snd_pcm_writei returned %i\n", count);
-	  return 0;
-	}
-      return count;
+  if (!output_handle) 
+  {
+    success(false);
+    return 0;
+  }
+
+  void *samples= (void *)arrayIndex + startIndex * output_channels * 2;
+  int   count=   snd_pcm_writei(output_handle, samples, frameCount);
+  if (count < frameCount / 2)
+    output_buffer_frames_available= 0;
+
+  if (count >= 0)
+    return count;
+
+  if (count != -EPIPE & count != -ESTRPIPE)
+  {
+    fprintf(stderr, "snd_pcm_writei returned %i\n", count);
+    return 0;
+  }
+
+  int err;
+  if (count == -EPIPE) {          /* under-run */
+    err = snd_pcm_prepare (output_handle);
+    if (err < 0)
+	  printf("Can't recovery from underrun, prepare failed: %s", snd_strerror (err));
+    return 0;
+  } else if (count == -ESTRPIPE) {
+    while ((err = snd_pcm_resume (output_handle)) == -EAGAIN)
+      sleep(1);           /* wait until the suspend flag is released */
+
+    if (err < 0) {
+      err = snd_pcm_prepare (output_handle);
+      if (err < 0)
+		printf("Can't recovery from suspend, prepare failed: %s", snd_strerror (err));
     }
-  success(false);
+    return 0;
+  }
+  
   return 0;
 }
 
@@ -306,13 +326,28 @@
       int   frameCount= ((bufferSizeInBytes / 2) - startSliceIndex) / input_channels;
       int   count=      snd_pcm_readi(input_handle, samples, frameCount);
       if (count < 0)
-	{    
-	  if (count == -EPIPE)
-	    snd_pcm_prepare(input_handle);
-	  else if (count != -EAGAIN)
-	    fprintf(stderr, "snd_pcm_readi returned %i\n", count);
-	  return 0;
-	}
+	  {
+		int err;
+		if (count == -EPIPE) {          /* under-run */
+		  err = snd_pcm_prepare (input_handle);
+		  if (err < 0)
+			printf("Can't recovery from underrun, prepare failed: %s", snd_strerror (err));
+		  return 0;
+		} else if (count == -ESTRPIPE) {
+		  while ((err = snd_pcm_resume (input_handle)) == -EAGAIN)
+			sleep(1);           /* wait until the suspend flag is released */
+
+		  if (err < 0) {
+			err = snd_pcm_prepare (input_handle);
+			if (err < 0)
+			  printf("Can't recovery from suspend, prepare failed: %s", snd_strerror (err));
+		  }
+		  return 0;
+		}
+
+		return 0;
+	  }
+	  
       return count * input_channels;
     }
   success(false);


Index: squeak-vm.spec
===================================================================
RCS file: /cvs/pkgs/rpms/squeak-vm/F-12/squeak-vm.spec,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -r1.5 -r1.6
--- squeak-vm.spec	28 Dec 2009 11:45:23 -0000	1.5
+++ squeak-vm.spec	21 Jun 2010 22:15:28 -0000	1.6
@@ -5,7 +5,7 @@
 
 Name:           squeak-vm
 Version:        %{major}.%{minor}
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        The Squeak virtual machine
 
 Group:          Development/Languages
@@ -19,6 +19,7 @@ Patch2:         squeak-vm-imgdir.patch
 Patch3:         squeak-vm-tail-options.patch
 Patch4:         squeak-vm-dprintf.patch
 Patch5:         alsa-scratchy-sound.patch
+Patch6:         alsa-suspend-resume.patch
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
 Requires(post): shared-mime-info
@@ -89,6 +90,7 @@ find platforms -name '*.[ch]' -exec chmo
 %patch3 -p1 -b .tail-options
 %patch4 -p1 -b .dprintf
 %patch5 -p1 -b .alsa-scratchy
+%patch6 -p1 -b .alsa-suspend
 
 %build
 mkdir -p bld
@@ -220,6 +222,9 @@ update-desktop-database &> /dev/null || 
 %endif
 
 %changelog
+* Mon Jun 21 2010 Daniel Drake <dsd at laptop.org> - 3.10.5-5
+- Add upstream patch to fix sound loss during suspend/resume
+
 * Mon Dec 28 2009 Daniel Drake <dsd at laptop.org> - 3.10.5-3
 - Add (already upstream) patch to fix crackly sound output
 



More information about the scm-commits mailing list