aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-01-08 18:05:26 +0100
committerJaroslav Kysela <perex@perex.cz>2008-01-31 17:29:47 +0100
commitd948035a928400ae127c873fbf771389bee18949 (patch)
tree1f8c98f21627e0ae1747c471dfbc3148923d80dd
parentfa5717f2099aadb2083d5df4d19af8f9685fa03e (diff)
[ALSA] Remove PCM xfer_align sw params
The xfer_align sw_params parameter has never been used in a sane manner, and no one understands what this does exactly. The current implementation looks also buggy because it allows write of shorter size than xfer_align. So, if you do partial writes, the write isn't actually aligned at all. Removing this parameter will make some pcm_lib_* code more readable (and less buggy). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl1
-rw-r--r--include/sound/asound.h2
-rw-r--r--include/sound/pcm.h1
-rw-r--r--sound/core/oss/pcm_oss.c1
-rw-r--r--sound/core/pcm.c1
-rw-r--r--sound/core/pcm_lib.c18
-rw-r--r--sound/core/pcm_native.c13
7 files changed, 5 insertions, 32 deletions
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index 48e4053eda1..835e320eeb4 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -2188,7 +2188,6 @@ struct _snd_pcm_runtime {
struct timespec tstamp_mode; /* mmap timestamp is updated */
unsigned int period_step;
unsigned int sleep_min; /* min ticks to sleep */
- snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
snd_pcm_uframes_t start_threshold;
snd_pcm_uframes_t stop_threshold;
snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
diff --git a/include/sound/asound.h b/include/sound/asound.h
index ee753d782e2..069d9120e62 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -363,7 +363,7 @@ struct snd_pcm_sw_params {
unsigned int period_step;
unsigned int sleep_min; /* min ticks to sleep */
snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */
- snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
+ snd_pcm_uframes_t xfer_align; /* obsolete: xfer size need to be a multiple */
snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */
snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */
snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 65f636223d3..1270cbce776 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -287,7 +287,6 @@ struct snd_pcm_runtime {
int tstamp_mode; /* mmap timestamp is updated */
unsigned int period_step;
unsigned int sleep_min; /* min ticks to sleep */
- snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
snd_pcm_uframes_t start_threshold;
snd_pcm_uframes_t stop_threshold;
snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index d0c4ceb9f0b..be089ccd736 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -988,7 +988,6 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
sw_params->sleep_min = 0;
sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
1 : runtime->period_size;
- sw_params->xfer_align = 1;
if (atomic_read(&substream->mmap_count) ||
substream->oss.setup.nosilence) {
sw_params->silence_threshold = 0;
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index cf9b9493d41..97cb681502a 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -389,7 +389,6 @@ static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
snd_iprintf(buffer, "period_step: %u\n", runtime->period_step);
snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min);
snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min);
- snd_iprintf(buffer, "xfer_align: %lu\n", runtime->xfer_align);
snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold);
snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold);
snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold);
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index f9f9b3fe956..c1c1556105c 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1628,8 +1628,6 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
if (size == 0)
return 0;
- if (size > runtime->xfer_align)
- size -= size % runtime->xfer_align;
snd_pcm_stream_lock_irq(substream);
switch (runtime->status->state) {
@@ -1657,9 +1655,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
avail = snd_pcm_playback_avail(runtime);
if (!avail ||
(snd_pcm_running(substream) &&
- ((avail < runtime->control->avail_min && size > avail) ||
- (size >= runtime->xfer_align &&
- avail < runtime->xfer_align)))) {
+ (avail < runtime->control->avail_min && size > avail))) {
wait_queue_t wait;
enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state;
long tout;
@@ -1731,8 +1727,6 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
break;
}
}
- if (avail > runtime->xfer_align)
- avail -= avail % runtime->xfer_align;
frames = size > avail ? avail : size;
cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size;
if (frames > cont)
@@ -1900,8 +1894,6 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
if (size == 0)
return 0;
- if (size > runtime->xfer_align)
- size -= size % runtime->xfer_align;
snd_pcm_stream_lock_irq(substream);
switch (runtime->status->state) {
@@ -1936,12 +1928,12 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
__draining:
avail = snd_pcm_capture_avail(runtime);
if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
- if (avail < runtime->xfer_align) {
+ if (!avail) {
err = -EPIPE;
goto _end_unlock;
}
- } else if ((avail < runtime->control->avail_min && size > avail) ||
- (size >= runtime->xfer_align && avail < runtime->xfer_align)) {
+ } else if (avail < runtime->control->avail_min &&
+ size > avail) {
wait_queue_t wait;
enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state;
long tout;
@@ -2014,8 +2006,6 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
break;
}
}
- if (avail > runtime->xfer_align)
- avail -= avail % runtime->xfer_align;
frames = size > avail ? avail : size;
cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size;
if (frames > cont)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 3fc33deabe3..3c22d78ee8f 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -435,7 +435,6 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
runtime->period_step = 1;
runtime->sleep_min = 0;
runtime->control->avail_min = runtime->period_size;
- runtime->xfer_align = runtime->period_size;
runtime->start_threshold = 1;
runtime->stop_threshold = runtime->buffer_size;
runtime->silence_threshold = 0;
@@ -532,9 +531,6 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
return -EINVAL;
if (params->avail_min == 0)
return -EINVAL;
- if (params->xfer_align == 0 ||
- params->xfer_align % runtime->min_align != 0)
- return -EINVAL;
if (params->silence_size >= runtime->boundary) {
if (params->silence_threshold != 0)
return -EINVAL;
@@ -553,7 +549,6 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
runtime->stop_threshold = params->stop_threshold;
runtime->silence_threshold = params->silence_threshold;
runtime->silence_size = params->silence_size;
- runtime->xfer_align = params->xfer_align;
params->boundary = runtime->boundary;
if (snd_pcm_running(substream)) {
if (runtime->sleep_min)
@@ -2239,8 +2234,6 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst
}
if (frames > (snd_pcm_uframes_t)hw_avail)
frames = hw_avail;
- else
- frames -= frames % runtime->xfer_align;
appl_ptr = runtime->control->appl_ptr - frames;
if (appl_ptr < 0)
appl_ptr += runtime->boundary;
@@ -2289,8 +2282,6 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr
}
if (frames > (snd_pcm_uframes_t)hw_avail)
frames = hw_avail;
- else
- frames -= frames % runtime->xfer_align;
appl_ptr = runtime->control->appl_ptr - frames;
if (appl_ptr < 0)
appl_ptr += runtime->boundary;
@@ -2340,8 +2331,6 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs
}
if (frames > (snd_pcm_uframes_t)avail)
frames = avail;
- else
- frames -= frames % runtime->xfer_align;
appl_ptr = runtime->control->appl_ptr + frames;
if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary)
appl_ptr -= runtime->boundary;
@@ -2391,8 +2380,6 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst
}
if (frames > (snd_pcm_uframes_t)avail)
frames = avail;
- else
- frames -= frames % runtime->xfer_align;
appl_ptr = runtime->control->appl_ptr + frames;
if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary)
appl_ptr -= runtime->boundary;