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 { ...@@ -50,6 +50,7 @@ typedef struct _snd_pcm_oss_runtime {
unsigned int maxfrags; unsigned int maxfrags;
unsigned int subdivision; /* requested subdivision */ unsigned int subdivision; /* requested subdivision */
size_t period_bytes; /* requested period size */ size_t period_bytes; /* requested period size */
size_t period_ptr; /* actual write pointer to period */
unsigned int periods; unsigned int periods;
size_t buffer_bytes; /* requested buffer size */ size_t buffer_bytes; /* requested buffer size */
size_t bytes; /* total # bytes processed */ size_t bytes; /* total # bytes processed */
......
...@@ -554,6 +554,7 @@ static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream) ...@@ -554,6 +554,7 @@ static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream)
} }
runtime->oss.prepare = 0; runtime->oss.prepare = 0;
runtime->oss.prev_hw_ptr_interrupt = 0; runtime->oss.prev_hw_ptr_interrupt = 0;
runtime->oss.period_ptr = 0;
return 0; return 0;
} }
...@@ -818,6 +819,8 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char *bu ...@@ -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; return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp; runtime->oss.bytes += tmp;
runtime->oss.buffer_used = 0; runtime->oss.buffer_used = 0;
runtime->oss.period_ptr += tmp;
runtime->oss.period_ptr %= runtime->oss.period_bytes;
} }
} 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);
...@@ -974,6 +977,8 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file) ...@@ -974,6 +977,8 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file)
unsigned int saved_f_flags; unsigned int saved_f_flags;
snd_pcm_substream_t *substream; snd_pcm_substream_t *substream;
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
snd_pcm_format_t format;
unsigned long width;
size_t size; size_t size;
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 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) ...@@ -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) if ((err = snd_pcm_oss_make_ready(substream)) < 0)
return err; return err;
runtime = substream->runtime; 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) { 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, 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); err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
if (err < 0) if (err < 0)
return err; 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; size = runtime->oss.period_bytes;
if (size > 0) { size1 = frames_to_bytes(runtime, runtime->period_size);
size = runtime->period_size - size; while (size < size1) {
size *= runtime->channels; snd_pcm_format_set_silence(format,
snd_pcm_format_set_silence(runtime->format,
runtime->oss.buffer, runtime->oss.buffer,
size); (8 * runtime->oss.period_size + 7) / width);
err = snd_pcm_oss_sync1(substream, samples_to_bytes(runtime, size)); err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
if (err < 0) if (err < 0)
return err; return err;
size += runtime->oss.period_bytes;
} }
saved_f_flags = substream->ffile->f_flags; saved_f_flags = substream->ffile->f_flags;
substream->ffile->f_flags &= ~O_NONBLOCK; 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