aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-01-08 12:05:26 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:47 -0500
commitd948035a928400ae127c873fbf771389bee18949 (patch)
tree1f8c98f21627e0ae1747c471dfbc3148923d80dd /sound/core
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>
Diffstat (limited to 'sound/core')
-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
4 files changed, 4 insertions, 29 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index d0c4ceb9f0b4..be089ccd736d 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)
988 sw_params->sleep_min = 0; 988 sw_params->sleep_min = 0;
989 sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 989 sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
990 1 : runtime->period_size; 990 1 : runtime->period_size;
991 sw_params->xfer_align = 1;
992 if (atomic_read(&substream->mmap_count) || 991 if (atomic_read(&substream->mmap_count) ||
993 substream->oss.setup.nosilence) { 992 substream->oss.setup.nosilence) {
994 sw_params->silence_threshold = 0; 993 sw_params->silence_threshold = 0;
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index cf9b9493d41d..97cb681502a3 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,
389 snd_iprintf(buffer, "period_step: %u\n", runtime->period_step); 389 snd_iprintf(buffer, "period_step: %u\n", runtime->period_step);
390 snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min); 390 snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min);
391 snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min); 391 snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min);
392 snd_iprintf(buffer, "xfer_align: %lu\n", runtime->xfer_align);
393 snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold); 392 snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold);
394 snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold); 393 snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold);
395 snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold); 394 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 f9f9b3fe956e..c1c1556105c0 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,
1628 1628
1629 if (size == 0) 1629 if (size == 0)
1630 return 0; 1630 return 0;
1631 if (size > runtime->xfer_align)
1632 size -= size % runtime->xfer_align;
1633 1631
1634 snd_pcm_stream_lock_irq(substream); 1632 snd_pcm_stream_lock_irq(substream);
1635 switch (runtime->status->state) { 1633 switch (runtime->status->state) {
@@ -1657,9 +1655,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
1657 avail = snd_pcm_playback_avail(runtime); 1655 avail = snd_pcm_playback_avail(runtime);
1658 if (!avail || 1656 if (!avail ||
1659 (snd_pcm_running(substream) && 1657 (snd_pcm_running(substream) &&
1660 ((avail < runtime->control->avail_min && size > avail) || 1658 (avail < runtime->control->avail_min && size > avail))) {
1661 (size >= runtime->xfer_align &&
1662 avail < runtime->xfer_align)))) {
1663 wait_queue_t wait; 1659 wait_queue_t wait;
1664 enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state; 1660 enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state;
1665 long tout; 1661 long tout;
@@ -1731,8 +1727,6 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
1731 break; 1727 break;
1732 } 1728 }
1733 } 1729 }
1734 if (avail > runtime->xfer_align)
1735 avail -= avail % runtime->xfer_align;
1736 frames = size > avail ? avail : size; 1730 frames = size > avail ? avail : size;
1737 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; 1731 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size;
1738 if (frames > cont) 1732 if (frames > cont)
@@ -1900,8 +1894,6 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
1900 1894
1901 if (size == 0) 1895 if (size == 0)
1902 return 0; 1896 return 0;
1903 if (size > runtime->xfer_align)
1904 size -= size % runtime->xfer_align;
1905 1897
1906 snd_pcm_stream_lock_irq(substream); 1898 snd_pcm_stream_lock_irq(substream);
1907 switch (runtime->status->state) { 1899 switch (runtime->status->state) {
@@ -1936,12 +1928,12 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
1936 __draining: 1928 __draining:
1937 avail = snd_pcm_capture_avail(runtime); 1929 avail = snd_pcm_capture_avail(runtime);
1938 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { 1930 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
1939 if (avail < runtime->xfer_align) { 1931 if (!avail) {
1940 err = -EPIPE; 1932 err = -EPIPE;
1941 goto _end_unlock; 1933 goto _end_unlock;
1942 } 1934 }
1943 } else if ((avail < runtime->control->avail_min && size > avail) || 1935 } else if (avail < runtime->control->avail_min &&
1944 (size >= runtime->xfer_align && avail < runtime->xfer_align)) { 1936 size > avail) {
1945 wait_queue_t wait; 1937 wait_queue_t wait;
1946 enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state; 1938 enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state;
1947 long tout; 1939 long tout;
@@ -2014,8 +2006,6 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream,
2014 break; 2006 break;
2015 } 2007 }
2016 } 2008 }
2017 if (avail > runtime->xfer_align)
2018 avail -= avail % runtime->xfer_align;
2019 frames = size > avail ? avail : size; 2009 frames = size > avail ? avail : size;
2020 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; 2010 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size;
2021 if (frames > cont) 2011 if (frames > cont)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 3fc33deabe35..3c22d78ee8f4 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,
435 runtime->period_step = 1; 435 runtime->period_step = 1;
436 runtime->sleep_min = 0; 436 runtime->sleep_min = 0;
437 runtime->control->avail_min = runtime->period_size; 437 runtime->control->avail_min = runtime->period_size;
438 runtime->xfer_align = runtime->period_size;
439 runtime->start_threshold = 1; 438 runtime->start_threshold = 1;
440 runtime->stop_threshold = runtime->buffer_size; 439 runtime->stop_threshold = runtime->buffer_size;
441 runtime->silence_threshold = 0; 440 runtime->silence_threshold = 0;
@@ -532,9 +531,6 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
532 return -EINVAL; 531 return -EINVAL;
533 if (params->avail_min == 0) 532 if (params->avail_min == 0)
534 return -EINVAL; 533 return -EINVAL;
535 if (params->xfer_align == 0 ||
536 params->xfer_align % runtime->min_align != 0)
537 return -EINVAL;
538 if (params->silence_size >= runtime->boundary) { 534 if (params->silence_size >= runtime->boundary) {
539 if (params->silence_threshold != 0) 535 if (params->silence_threshold != 0)
540 return -EINVAL; 536 return -EINVAL;
@@ -553,7 +549,6 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
553 runtime->stop_threshold = params->stop_threshold; 549 runtime->stop_threshold = params->stop_threshold;
554 runtime->silence_threshold = params->silence_threshold; 550 runtime->silence_threshold = params->silence_threshold;
555 runtime->silence_size = params->silence_size; 551 runtime->silence_size = params->silence_size;
556 runtime->xfer_align = params->xfer_align;
557 params->boundary = runtime->boundary; 552 params->boundary = runtime->boundary;
558 if (snd_pcm_running(substream)) { 553 if (snd_pcm_running(substream)) {
559 if (runtime->sleep_min) 554 if (runtime->sleep_min)
@@ -2239,8 +2234,6 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst
2239 } 2234 }
2240 if (frames > (snd_pcm_uframes_t)hw_avail) 2235 if (frames > (snd_pcm_uframes_t)hw_avail)
2241 frames = hw_avail; 2236 frames = hw_avail;
2242 else
2243 frames -= frames % runtime->xfer_align;
2244 appl_ptr = runtime->control->appl_ptr - frames; 2237 appl_ptr = runtime->control->appl_ptr - frames;
2245 if (appl_ptr < 0) 2238 if (appl_ptr < 0)
2246 appl_ptr += runtime->boundary; 2239 appl_ptr += runtime->boundary;
@@ -2289,8 +2282,6 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr
2289 } 2282 }
2290 if (frames > (snd_pcm_uframes_t)hw_avail) 2283 if (frames > (snd_pcm_uframes_t)hw_avail)
2291 frames = hw_avail; 2284 frames = hw_avail;
2292 else
2293 frames -= frames % runtime->xfer_align;
2294 appl_ptr = runtime->control->appl_ptr - frames; 2285 appl_ptr = runtime->control->appl_ptr - frames;
2295 if (appl_ptr < 0) 2286 if (appl_ptr < 0)
2296 appl_ptr += runtime->boundary; 2287 appl_ptr += runtime->boundary;
@@ -2340,8 +2331,6 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs
2340 } 2331 }
2341 if (frames > (snd_pcm_uframes_t)avail) 2332 if (frames > (snd_pcm_uframes_t)avail)
2342 frames = avail; 2333 frames = avail;
2343 else
2344 frames -= frames % runtime->xfer_align;
2345 appl_ptr = runtime->control->appl_ptr + frames; 2334 appl_ptr = runtime->control->appl_ptr + frames;
2346 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) 2335 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary)
2347 appl_ptr -= runtime->boundary; 2336 appl_ptr -= runtime->boundary;
@@ -2391,8 +2380,6 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst
2391 } 2380 }
2392 if (frames > (snd_pcm_uframes_t)avail) 2381 if (frames > (snd_pcm_uframes_t)avail)
2393 frames = avail; 2382 frames = avail;
2394 else
2395 frames -= frames % runtime->xfer_align;
2396 appl_ptr = runtime->control->appl_ptr + frames; 2383 appl_ptr = runtime->control->appl_ptr + frames;
2397 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) 2384 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary)
2398 appl_ptr -= runtime->boundary; 2385 appl_ptr -= runtime->boundary;