Commit 999be1eb authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] Fix the OSS PCM emulation - O_NONBLOCK write

ALSA<-OSS emulation
This patch fixes the OSS PCM write() in O_NONBLOCK mode.
The previous code had not returned partial written bytes.
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent d801facf
...@@ -834,9 +834,14 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u ...@@ -834,9 +834,14 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u
if (tmp <= 0) if (tmp <= 0)
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp; runtime->oss.bytes += tmp;
runtime->oss.buffer_used = 0;
runtime->oss.period_ptr += tmp; runtime->oss.period_ptr += tmp;
runtime->oss.period_ptr %= runtime->oss.period_bytes; runtime->oss.period_ptr %= runtime->oss.period_bytes;
if ((substream->ffile->f_flags & O_NONBLOCK) != 0 &&
tmp != runtime->oss.buffer_used) {
runtime->oss.buffer_used = 0;
break;
}
runtime->oss.buffer_used = 0;
} }
} else { } else {
tmp = snd_pcm_oss_write2(substream, (char *)buf, runtime->oss.period_bytes, 0); tmp = snd_pcm_oss_write2(substream, (char *)buf, runtime->oss.period_bytes, 0);
...@@ -846,6 +851,9 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u ...@@ -846,6 +851,9 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u
buf += tmp; buf += tmp;
bytes -= tmp; bytes -= tmp;
xfer += tmp; xfer += tmp;
if ((substream->ffile->f_flags & O_NONBLOCK) != 0 &&
tmp != runtime->oss.period_bytes)
break;
} }
} }
return xfer; return xfer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment