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

-D




On 14/06/10 11:58, Peter Robinson wrote:
On Mon, Jun 14, 2010 at 9:58 AM, Bert Freudenberg<[email protected]>  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

*** /home/doc/std/dev/squeak/vm/3.10-5/unix-3.10-5/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c	2008-04-28 20:04:11.000000000 +0100
--- /home/doc/std/dev/squeak/vm/3.11.3/src/squeak-svn/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c	2010-06-14 12:22:13.000000000 +0100
***************
*** 135,141 ****
    if ((err= snd_pcm_start(output_handle)) < 0)
      {
        if (err != -EPIPE)
! 	{
  	  fprintf(stderr, "snd_pcm_start(1): %s\n", snd_strerror(err));
  	  success(false);
  	  return 0;
--- 136,143 ----
    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,154 ****
    if ((err= snd_pcm_start(output_handle)) < 0)
      {
        if (err != -EPIPE)
! 	{
  	  fprintf(stderr, "snd_pcm_start(2): %s\n", snd_strerror(err));
  	  success(false);
  	  return 0;
--- 150,157 ----
    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,173 ****
--- 171,177 ----
    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,226 ****
  
  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;
      }
!   success(false);
    return 0;
  }
  
--- 203,246 ----
  
  static sqInt  sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt arrayIndex, sqInt startIndex)
  {
!   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));
      }
!     return 0;
!   }
!   
    return 0;
  }
  
***************
*** 306,318 ****
        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;
! 	}
        return count * input_channels;
      }
    success(false);
--- 326,353 ----
        int   frameCount= ((bufferSizeInBytes / 2) - startSliceIndex) / input_channels;
        int   count=      snd_pcm_readi(input_handle, samples, frameCount);
        if (count < 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);
_______________________________________________
Testing mailing list
[email protected]
http://lists.laptop.org/listinfo/testing

Reply via email to