Hi Peter,

sorry for the delay, hopefully the attach is what you want.

-D

On 14/06/10 12:56, Peter Robinson wrote:
On Mon, Jun 14, 2010 at 12:29 PM, Derek O'Connell<d...@doconnel.f9.co.uk>  
wrote:
Hi Peter,

I don't have much experience creating patches so please let me know if the
attached is the wrong format for your purposes. Created using:

diff -cB
/home/doc/std/dev/squeak/vm/3.10-5/unix-3.10-5/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c
/home/doc/std/dev/squeak/vm/3.11.3/src/squeak-svn/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c
sqUnixSoundALSA.patch
If you could use 'diff -u origfile newfile>  output.patch' from the
root of the source tree that would be better.

Thanks,
Peter

On 14/06/10 11:58, Peter Robinson wrote:
On Mon, Jun 14, 2010 at 9:58 AM, Bert Freudenberg<b...@freudenbergs.de>
  wrote:

On 14.06.2010, at 06:24, Chris Ball wrote:


Hi Bert,


Copied ~olpc/Activities/Sratch.activity/vm-sound-ALSA plugin to
/usr/lib/squeak/3.10-5/.

After that, in Etoys playback sounds a bit worse, but it's still
okay (hard to tell actually). And no freeze after suspend,
playing just resumes. So it would be a good idea to use that ALSA
plugin for Squeak in general, me thinks.

Could we get a squeak/etoys package with a fixed alsa-plugin ASAP,
please?

Someone would need to rebuild Fedora's squeak-vm-3.10-5 package with
Derek's patched sqUnixSoundALSA.c file (attached to the forwarded msg
below). The etoys package is unaffected.

I'm happy to apply a patch to the etoys package in Fedora if someone
can provide me a patch rather than a complete new source file.

Peter



--- 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;
@@ -168,6 +171,7 @@
   if (!output_handle) return 0;
 
   snd_pcm_delay(output_handle, &delay);
+  snd_pcm_avail_update(output_handle);
   state= snd_pcm_state (output_handle);
 
   /* if underrun causes, max delay is loosened */
@@ -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);
_______________________________________________
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel

Reply via email to