Update of /cvsroot/alsa/alsa-lib/src/pcm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3952/src/pcm

Modified Files:
        pcm.c pcm_hw.c pcm_local.h 
Log Message:
fixed the handling of EINTR in read/write.
EINTR can be returned during ACPI suspend/resume.


Index: pcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm.c,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -r1.282 -r1.283
--- pcm.c       5 Apr 2004 17:59:34 -0000       1.282
+++ pcm.c       15 Apr 2004 12:22:26 -0000      1.283
@@ -6066,7 +6066,7 @@
                xfer += frames;
        }
  _end:
-       return xfer > 0 ? (snd_pcm_sframes_t) xfer : err;
+       return xfer > 0 ? (snd_pcm_sframes_t) xfer : snd_pcm_check_error(pcm, err);
 }
 
 snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t 
*areas,
@@ -6149,7 +6149,7 @@
                }
        }
  _end:
-       return xfer > 0 ? (snd_pcm_sframes_t) xfer : err;
+       return xfer > 0 ? (snd_pcm_sframes_t) xfer : snd_pcm_check_error(pcm, err);
 }
 
 snd_pcm_uframes_t _snd_pcm_mmap_hw_ptr(snd_pcm_t *pcm)

Index: pcm_hw.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_hw.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- pcm_hw.c    17 Mar 2004 11:48:15 -0000      1.124
+++ pcm_hw.c    15 Apr 2004 12:22:26 -0000      1.125
@@ -612,7 +612,7 @@
        fprintf(stderr, "hw_writei: frames = %li, result = %i, result = %li\n", size, 
result, xferi.result);
 #endif
        if (result < 0)
-               return err;
+               return snd_pcm_check_error(pcm, err);
        return xferi.result;
 }
 
@@ -630,7 +630,7 @@
        fprintf(stderr, "hw_writen: frames = %li, result = %i, result = %li\n", size, 
result, xfern.result);
 #endif
        if (result < 0)
-               return err;
+               return snd_pcm_check_error(pcm, err);
        return xfern.result;
 }
 
@@ -648,7 +648,7 @@
        fprintf(stderr, "hw_readi: frames = %li, result = %i, result = %li\n", size, 
result, xferi.result);
 #endif
        if (result < 0)
-               return err;
+               return snd_pcm_check_error(pcm, err);
        UPDATE_SHADOW_PTR(hw);
        return xferi.result;
 }
@@ -667,7 +667,7 @@
        fprintf(stderr, "hw_readn: frames = %li, result = %i, result = %li\n", size, 
result, xfern.result);
 #endif
        if (result < 0)
-               return err;
+               return snd_pcm_check_error(pcm, err);
        UPDATE_SHADOW_PTR(hw);
        return xfern.result;
 }

Index: pcm_local.h
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_local.h,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- pcm_local.h 17 Mar 2004 11:48:15 -0000      1.133
+++ pcm_local.h 15 Apr 2004 12:22:27 -0000      1.134
@@ -265,6 +265,22 @@
 int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
 int _snd_pcm_poll_descriptor(snd_pcm_t *pcm);
 
+/* handle special error cases */
+static inline int snd_pcm_check_error(snd_pcm_t *pcm, int err)
+{
+       if (err == -EINTR) {
+               switch (snd_pcm_state(pcm)) {
+               case SND_PCM_STATE_XRUN:
+                       return -EPIPE;
+               case SND_PCM_STATE_SUSPENDED:
+                       return -ESTRPIPE;
+               case SND_PCM_STATE_DISCONNECTED:
+                       return -ENOTTY;
+               }
+       }
+       return err;
+}
+
 static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
 {
        snd_pcm_sframes_t avail;



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to