aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-04-28 09:13:41 -0400
committerJaroslav Kysela <perex@suse.cz>2006-06-22 15:33:13 -0400
commit0df63e44c3e315ec0fe427ae62558231864108bd (patch)
tree3cff6f5d5fdb7ad047a61c591d891e3ca1bc669e /sound/core/oss
parentf001c3acf64b8ca18fe40af592629abb261b321e (diff)
[ALSA] Add O_APPEND flag support to PCM
Added O_APPEND flag support to PCM to enable shared substreams among multiple processes. This mechanism is used by dmix and dsnoop plugins. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/oss')
-rw-r--r--sound/core/oss/pcm_oss.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index d8b7416ee00..9803a6ce3d4 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1331,7 +1331,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
1331 if (runtime->oss.period_ptr == 0 || 1331 if (runtime->oss.period_ptr == 0 ||
1332 runtime->oss.period_ptr == runtime->oss.buffer_used) 1332 runtime->oss.period_ptr == runtime->oss.buffer_used)
1333 runtime->oss.buffer_used = 0; 1333 runtime->oss.buffer_used = 0;
1334 else if ((substream->ffile->f_flags & O_NONBLOCK) != 0) 1334 else if ((substream->f_flags & O_NONBLOCK) != 0)
1335 return xfer > 0 ? xfer : -EAGAIN; 1335 return xfer > 0 ? xfer : -EAGAIN;
1336 } 1336 }
1337 } else { 1337 } else {
@@ -1344,7 +1344,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
1344 buf += tmp; 1344 buf += tmp;
1345 bytes -= tmp; 1345 bytes -= tmp;
1346 xfer += tmp; 1346 xfer += tmp;
1347 if ((substream->ffile->f_flags & O_NONBLOCK) != 0 && 1347 if ((substream->f_flags & O_NONBLOCK) != 0 &&
1348 tmp != runtime->oss.period_bytes) 1348 tmp != runtime->oss.period_bytes)
1349 break; 1349 break;
1350 } 1350 }
@@ -1582,10 +1582,10 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
1582 * finish sync: drain the buffer 1582 * finish sync: drain the buffer
1583 */ 1583 */
1584 __direct: 1584 __direct:
1585 saved_f_flags = substream->ffile->f_flags; 1585 saved_f_flags = substream->f_flags;
1586 substream->ffile->f_flags &= ~O_NONBLOCK; 1586 substream->f_flags &= ~O_NONBLOCK;
1587 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); 1587 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1588 substream->ffile->f_flags = saved_f_flags; 1588 substream->f_flags = saved_f_flags;
1589 if (err < 0) 1589 if (err < 0)
1590 return err; 1590 return err;
1591 runtime->oss.prepare = 1; 1591 runtime->oss.prepare = 1;
@@ -2164,9 +2164,9 @@ static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
2164 substream->oss.oss = 1; 2164 substream->oss.oss = 1;
2165 substream->oss.setup = *setup; 2165 substream->oss.setup = *setup;
2166 if (setup->nonblock) 2166 if (setup->nonblock)
2167 substream->ffile->f_flags |= O_NONBLOCK; 2167 substream->f_flags |= O_NONBLOCK;
2168 else if (setup->block) 2168 else if (setup->block)
2169 substream->ffile->f_flags &= ~O_NONBLOCK; 2169 substream->f_flags &= ~O_NONBLOCK;
2170 runtime = substream->runtime; 2170 runtime = substream->runtime;
2171 runtime->oss.params = 1; 2171 runtime->oss.params = 1;
2172 runtime->oss.trigger = 1; 2172 runtime->oss.trigger = 1;
@@ -2223,6 +2223,7 @@ static int snd_pcm_oss_open_file(struct file *file,
2223 (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX)) 2223 (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX))
2224 f_mode = FMODE_WRITE; 2224 f_mode = FMODE_WRITE;
2225 2225
2226 file->f_flags &= ~O_APPEND;
2226 for (idx = 0; idx < 2; idx++) { 2227 for (idx = 0; idx < 2; idx++) {
2227 if (setup[idx].disable) 2228 if (setup[idx].disable)
2228 continue; 2229 continue;
@@ -2540,6 +2541,7 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t coun
2540 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; 2541 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2541 if (substream == NULL) 2542 if (substream == NULL)
2542 return -ENXIO; 2543 return -ENXIO;
2544 substream->f_flags = file->f_flags & O_NONBLOCK;
2543#ifndef OSS_DEBUG 2545#ifndef OSS_DEBUG
2544 return snd_pcm_oss_read1(substream, buf, count); 2546 return snd_pcm_oss_read1(substream, buf, count);
2545#else 2547#else
@@ -2561,6 +2563,7 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size
2561 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 2563 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2562 if (substream == NULL) 2564 if (substream == NULL)
2563 return -ENXIO; 2565 return -ENXIO;
2566 substream->f_flags = file->f_flags & O_NONBLOCK;
2564 result = snd_pcm_oss_write1(substream, buf, count); 2567 result = snd_pcm_oss_write1(substream, buf, count);
2565#ifdef OSS_DEBUG 2568#ifdef OSS_DEBUG
2566 printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result); 2569 printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result);