]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Fixed mmap_xxxx_delay() to follow kernel code
authorJaroslav Kysela <perex@perex.cz>
Wed, 9 Oct 2002 06:44:45 +0000 (06:44 +0000)
committerJaroslav Kysela <perex@perex.cz>
Wed, 9 Oct 2002 06:44:45 +0000 (06:44 +0000)
src/pcm/pcm_local.h

index ce3e6a743b8ab888e1c56095ef9c8d85fd432528..247b32abf0a67ccb9cf0c88370c9711fe07be5a7 100644 (file)
@@ -321,8 +321,34 @@ static inline snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm)
        return *pcm->hw.ptr % pcm->buffer_size;
 }
 
-#define snd_pcm_mmap_playback_delay snd_pcm_mmap_playback_hw_avail
-#define snd_pcm_mmap_capture_delay snd_pcm_mmap_capture_avail
+static inline snd_pcm_uframes_t snd_pcm_mmap_playback_delay(snd_pcm_t *pcm)
+{
+       snd_pcm_state_t state = snd_pcm_state(pcm);
+       
+       switch (state) {
+       case SND_PCM_STATE_RUNNING:
+       case SND_PCM_STATE_DRAINING:
+               return snd_pcm_mmap_playback_hw_avail(pcm);
+       case SND_PCM_STATE_XRUN:
+               return -EPIPE;
+       default:
+               return -EBADFD;
+       }
+}
+
+static inline snd_pcm_uframes_t snd_pcm_mmap_capture_delay(snd_pcm_t *pcm)
+{
+       snd_pcm_state_t state = snd_pcm_state(pcm);
+       
+       switch (state) {
+       case SND_PCM_STATE_RUNNING:
+               return snd_pcm_mmap_capture_hw_avail(pcm);
+       case SND_PCM_STATE_XRUN:
+               return -EPIPE;
+       default:
+               return -EBADFD;
+       }
+}
 
 static inline snd_pcm_sframes_t snd_pcm_mmap_delay(snd_pcm_t *pcm)
 {