Commit e409cccc authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update

D:2003/09/29 19:16:18
C:ALSA<-OSS emulation
A:Jaroslav Kysela <perex@suse.cz>
F:core/oss/pcm_oss.c:1.50->1.51 
F:include/pcm_oss.h:1.7->1.8 
L:Fixed oops in oss_sync() routine.
parent 7a939ac4
......@@ -50,6 +50,7 @@ typedef struct _snd_pcm_oss_runtime {
unsigned int maxfrags;
unsigned int subdivision; /* requested subdivision */
size_t period_bytes; /* requested period size */
size_t period_ptr; /* actual write pointer to period */
unsigned int periods;
size_t buffer_bytes; /* requested buffer size */
size_t bytes; /* total # bytes processed */
......
......@@ -142,7 +142,7 @@ static int snd_pcm_oss_format_from(int format)
case AFMT_U16_LE: return SNDRV_PCM_FORMAT_U16_LE;
case AFMT_U16_BE: return SNDRV_PCM_FORMAT_U16_BE;
case AFMT_MPEG: return SNDRV_PCM_FORMAT_MPEG;
default: return SNDRV_PCM_FORMAT_U8;
default: return SNDRV_PCM_FORMAT_U8;
}
}
......@@ -554,6 +554,7 @@ static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream)
}
runtime->oss.prepare = 0;
runtime->oss.prev_hw_ptr_interrupt = 0;
runtime->oss.period_ptr = 0;
return 0;
}
......@@ -818,6 +819,8 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char *bu
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp;
runtime->oss.buffer_used = 0;
runtime->oss.period_ptr += tmp;
runtime->oss.period_ptr %= runtime->oss.period_bytes;
}
} else {
tmp = snd_pcm_oss_write2(substream, (char *)buf, runtime->oss.period_bytes, 0);
......@@ -974,6 +977,8 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file)
unsigned int saved_f_flags;
snd_pcm_substream_t *substream;
snd_pcm_runtime_t *runtime;
snd_pcm_format_t format;
unsigned long width;
size_t size;
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
......@@ -981,24 +986,35 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file)
if ((err = snd_pcm_oss_make_ready(substream)) < 0)
return err;
runtime = substream->runtime;
format = snd_pcm_oss_format_from(runtime->oss.format));
width = snd_pcm_format_physical_width(format);
if (runtime->oss.buffer_used > 0) {
snd_pcm_format_set_silence(runtime->format,
size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width;
snd_pcm_format_set_silence(format,
runtime->oss.buffer + runtime->oss.buffer_used,
bytes_to_samples(runtime, runtime->oss.period_bytes - runtime->oss.buffer_used));
size);
err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
if (err < 0)
return err;
} else if (runtime->oss.period_ptr > 0) {
size = runtime->oss.period_bytes - runtime->oss.period_ptr;
snd_pcm_format_set_silence(format,
runtime->oss.buffer,
size * 8 / width);
err = snd_pcm_oss_sync1(substream, size);
if (err < 0)
return err;
}
size = runtime->control->appl_ptr % runtime->period_size;
if (size > 0) {
size = runtime->period_size - size;
size *= runtime->channels;
snd_pcm_format_set_silence(runtime->format,
size = runtime->oss.period_bytes;
size1 = frames_to_bytes(runtime, runtime->period_size);
while (size < size1) {
snd_pcm_format_set_silence(format,
runtime->oss.buffer,
size);
err = snd_pcm_oss_sync1(substream, samples_to_bytes(runtime, size));
(8 * runtime->oss.period_size + 7) / width);
err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
if (err < 0)
return err;
size += runtime->oss.period_bytes;
}
saved_f_flags = substream->ffile->f_flags;
substream->ffile->f_flags &= ~O_NONBLOCK;
......
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