[ALSA] OSS PCM emulation - The 2nd final fix for SNDCTL_DSP_GETOPTR problem
authorJaroslav Kysela <perex@suse.cz>
Tue, 31 May 2005 14:59:39 +0000 (16:59 +0200)
committerJaroslav Kysela <perex@suse.cz>
Wed, 22 Jun 2005 10:28:03 +0000 (12:28 +0200)
ALSA<-OSS emulation
The problem was negative/wrong result (info.bytes) in a specific condition at
playback startup.

Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/core/oss/pcm_oss.c

index 203470df5857b9eb6ab47cccf9f6e3ea27e6793f..cab30977e7c0887603abacd05218894857176463 100644 (file)
@@ -1537,13 +1537,13 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str
                        snd_pcm_oss_simulate_fill(substream, delay);
                info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
        } else {
-               delay = snd_pcm_oss_bytes(substream, delay) + fixup;
-               info.blocks = delay / runtime->oss.period_bytes;
+               delay = snd_pcm_oss_bytes(substream, delay);
                if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
-                       if (runtime->oss.bytes == 0)
-                               delay = 0;
+                       info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
                        info.bytes = (runtime->oss.bytes - delay) & INT_MAX;
                } else {
+                       delay += fixup;
+                       info.blocks = delay / runtime->oss.period_bytes;
                        info.bytes = (runtime->oss.bytes + delay) & INT_MAX;
                }
        }