Merge branch 'fix/pcm-jiffies-check' into topic/pcm-jiffies-check
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 May 2009 09:46:10 +0000 (11:46 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 May 2009 09:46:10 +0000 (11:46 +0200)
1  2 
sound/core/pcm_native.c

diff --combined sound/core/pcm_native.c
@@@ -587,15 -587,14 +587,15 @@@ int snd_pcm_status(struct snd_pcm_subst
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                status->avail = snd_pcm_playback_avail(runtime);
                if (runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
 -                  runtime->status->state == SNDRV_PCM_STATE_DRAINING)
 +                  runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
                        status->delay = runtime->buffer_size - status->avail;
 -              else
 +                      status->delay += runtime->delay;
 +              } else
                        status->delay = 0;
        } else {
                status->avail = snd_pcm_capture_avail(runtime);
                if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
 -                      status->delay = status->avail;
 +                      status->delay = status->avail + runtime->delay;
                else
                        status->delay = 0;
        }
@@@ -849,6 -848,7 +849,7 @@@ static void snd_pcm_post_start(struct s
  {
        struct snd_pcm_runtime *runtime = substream->runtime;
        snd_pcm_trigger_tstamp(substream);
+       runtime->hw_ptr_jiffies = jiffies;
        runtime->status->state = state;
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
            runtime->silence_size > 0)
@@@ -962,6 -962,11 +963,11 @@@ static int snd_pcm_do_pause(struct snd_
  {
        if (substream->runtime->trigger_master != substream)
                return 0;
+       /* The jiffies check in snd_pcm_update_hw_ptr*() is done by
+        * a delta betwen the current jiffies, this gives a large enough
+        * delta, effectively to skip the check once.
+        */
+       substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000;
        return substream->ops->trigger(substream,
                                       push ? SNDRV_PCM_TRIGGER_PAUSE_PUSH :
                                              SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
@@@ -2405,7 -2410,6 +2411,7 @@@ static int snd_pcm_delay(struct snd_pcm
                        n = snd_pcm_playback_hw_avail(runtime);
                else
                        n = snd_pcm_capture_avail(runtime);
 +              n += runtime->delay;
                break;
        case SNDRV_PCM_STATE_XRUN:
                err = -EPIPE;