]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Remove PCM xfer_align
authorTakashi Iwai <tiwai@suse.de>
Tue, 8 Jan 2008 17:35:29 +0000 (18:35 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 8 Jan 2008 17:35:29 +0000 (18:35 +0100)
The PCM xfer_align is a removed feature from the kernel.
This patch cleans up the corresponding part in alsa-lib.

12 files changed:
include/pcm.h
src/pcm/pcm.c
src/pcm/pcm_direct.c
src/pcm/pcm_direct.h
src/pcm/pcm_hw.c
src/pcm/pcm_local.h
src/pcm/pcm_mmap_emul.c
src/pcm/pcm_params.c
src/pcm/pcm_rate.c
src/pcm/pcm_simple.c
test/latency.c
test/pcm.c

index f72b39cbcea845d0589d864ef47cabaa00d8d960..d2d8bf6ea8b1f539a717a2f40462d45f0f4af226 100644 (file)
@@ -713,8 +713,6 @@ int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params,
 int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val);
 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
-int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
-int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
 int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
@@ -1103,6 +1101,8 @@ int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params
 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
 int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) __attribute__((deprecated));
 snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
+int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) __attribute__((deprecated));
+int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
 
 /** \} */
 
index 2e36cc18e161f43c9aedc9de2b76dc1c35a41837..52714afafe9f26b425b2b1ca19b7ee6fbb7b0717 100644 (file)
@@ -872,10 +872,6 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
                SNDMSG("params->avail_min is 0");
                return -EINVAL;
        }
-       if (! params->xfer_align) {
-               SNDMSG("params->xfer_align is 0");
-               return -EINVAL;
-       }
 #if 0
        /* disable the check below - it looks too restrictive
         * (start_threshold is basically independent from avail_min)
@@ -886,11 +882,6 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
                return -EINVAL;
        }
 #endif
-       if (params->start_threshold <= pcm->buffer_size &&
-           params->start_threshold > (pcm->buffer_size / params->xfer_align) * params->xfer_align) {
-               SNDMSG("params->xfer_align problem for start_threshold");
-               return -EINVAL;
-       }
        err = pcm->ops->sw_params(pcm->op_arg, params);
        if (err < 0)
                return err;
@@ -898,7 +889,6 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
        pcm->period_step = params->period_step;
        pcm->sleep_min = params->sleep_min;
        pcm->avail_min = params->avail_min;
-       pcm->xfer_align = params->xfer_align;
        pcm->start_threshold = params->start_threshold;
        pcm->stop_threshold = params->stop_threshold;
        pcm->silence_threshold = params->silence_threshold;
@@ -1811,7 +1801,6 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)
        snd_output_printf(out, "  period_step  : %d\n", pcm->period_step);
        snd_output_printf(out, "  sleep_min    : %d\n", pcm->sleep_min);
        snd_output_printf(out, "  avail_min    : %ld\n", pcm->avail_min);
-       snd_output_printf(out, "  xfer_align   : %ld\n", pcm->xfer_align);
        snd_output_printf(out, "  start_threshold  : %ld\n", pcm->start_threshold);
        snd_output_printf(out, "  stop_threshold   : %ld\n", pcm->stop_threshold);
        snd_output_printf(out, "  silence_threshold: %ld\n", pcm->silence_threshold);
@@ -5303,7 +5292,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
        params->period_step = pcm->period_step;
        params->sleep_min = pcm->sleep_min;
        params->avail_min = pcm->avail_min;
-       params->xfer_align = pcm->xfer_align;
+       params->xfer_align = 1;
        params->start_threshold = pcm->start_threshold;
        params->stop_threshold = pcm->stop_threshold;
        params->silence_threshold = pcm->silence_threshold;
@@ -5326,7 +5315,6 @@ int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out)
        snd_output_printf(out, "period_step: %u\n", params->period_step);
        snd_output_printf(out, "sleep_min: %u\n", params->sleep_min);
        snd_output_printf(out, "avail_min: %lu\n", params->avail_min);
-       snd_output_printf(out, "xfer_align: %lu\n", params->xfer_align);
        snd_output_printf(out, "silence_threshold: %lu\n", params->silence_threshold);
        snd_output_printf(out, "silence_size: %lu\n", params->silence_size);
        snd_output_printf(out, "boundary: %lu\n", params->boundary);
@@ -5607,45 +5595,37 @@ int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_u
 
 
 /**
- * \brief Set xfer align inside a software configuration container
+ * \brief (DEPRECATED) Set xfer align inside a software configuration container
  * \param pcm PCM handle
  * \param params Software configuration container
  * \param val Chunk size (frames are attempted to be transferred in chunks)
  * \return 0 otherwise a negative error code
  */
 #ifndef DOXYGEN
-int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
+int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params ATTRIBUTE_UNUSED, snd_pcm_uframes_t val ATTRIBUTE_UNUSED)
 #else
 int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
 #endif
 {
-       assert(pcm && params);
-       if (CHECK_SANITY(val % pcm->min_align)) {
-               SNDMSG("xfer_align (%ld) is not aligned to min_align (%ld)", val, pcm->min_align);
-               return -EINVAL;
-       }
-       params->xfer_align = val;
        return 0;
 }
 
 /**
- * \brief Get xfer align from a software configuration container
+ * \brief (DEPRECATED) Get xfer align from a software configuration container
  * \param params Software configuration container
  * \param val returned chunk size (frames are attempted to be transferred in chunks)
  * \return 0 otherwise a negative error code
  */
 #ifndef DOXYGEN
-int INTERNAL(snd_pcm_sw_params_get_xfer_align)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
+int INTERNAL(snd_pcm_sw_params_get_xfer_align)(const snd_pcm_sw_params_t *params ATTRIBUTE_UNUSED, snd_pcm_uframes_t *val)
 #else
 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
 #endif
 {
-       assert(params && val);
-       *val = params->xfer_align;
+       *val = 1;
        return 0;
 }
 
-
 /**
  * \brief Set start threshold inside a software configuration container
  * \param pcm PCM handle
@@ -6361,8 +6341,6 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_
 
        if (size == 0)
                return 0;
-       if (size > pcm->xfer_align)
-               size -= size % pcm->xfer_align;
 
        switch (state) {
        case SND_PCM_STATE_PREPARED:
@@ -6397,9 +6375,8 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_
                        err = avail;
                        goto _end;
                }
-               if (((snd_pcm_uframes_t)avail < pcm->avail_min && size > (snd_pcm_uframes_t)avail) ||
-                   (size >= pcm->xfer_align && (snd_pcm_uframes_t)avail < pcm->xfer_align)) {
-
+               if ((snd_pcm_uframes_t)avail < pcm->avail_min &&
+                   size > (snd_pcm_uframes_t)avail) {
                        if (pcm->mode & SND_PCM_NONBLOCK) {
                                err = -EAGAIN;
                                goto _end;
@@ -6411,8 +6388,6 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_
                        goto _again;
                        
                }
-               if ((snd_pcm_uframes_t) avail > pcm->xfer_align)
-                       avail -= avail % pcm->xfer_align;
                frames = size;
                if (frames > (snd_pcm_uframes_t) avail)
                        frames = avail;
@@ -6440,8 +6415,6 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
 
        if (size == 0)
                return 0;
-       if (size > pcm->xfer_align)
-               size -= size % pcm->xfer_align;
 
        switch (state) {
        case SND_PCM_STATE_PREPARED:
@@ -6473,10 +6446,7 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
                }
                if ((state == SND_PCM_STATE_RUNNING &&
                     (snd_pcm_uframes_t)avail < pcm->avail_min &&
-                    size > (snd_pcm_uframes_t)avail) ||
-                   (size >= pcm->xfer_align &&
-                    (snd_pcm_uframes_t)avail < pcm->xfer_align)) {
-
+                    size > (snd_pcm_uframes_t)avail)) {
                        if (pcm->mode & SND_PCM_NONBLOCK) {
                                err = -EAGAIN;
                                goto _end;
@@ -6487,8 +6457,6 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
                                break;
                        goto _again;                    
                }
-               if ((snd_pcm_uframes_t) avail > pcm->xfer_align)
-                       avail -= avail % pcm->xfer_align;
                frames = size;
                if (frames > (snd_pcm_uframes_t) avail)
                        frames = avail;
@@ -7245,12 +7213,6 @@ int snd_pcm_set_params(snd_pcm_t *pcm,
                SNDERR("Unable to set avail min for %s: %s", s, snd_strerror(err));
                return err;
        }
-       /* align all transfers to 1 sample */
-       err = snd_pcm_sw_params_set_xfer_align(pcm, swparams, 1);
-       if (err < 0) {
-               SNDERR("Unable to set transfer align for %s: %s", s, snd_strerror(err));
-               return err;
-       }
        /* write the parameters to the playback device */
        err = snd_pcm_sw_params(pcm, swparams);
        if (err < 0) {
index 3f908e2651d9a747ce32a7f1da8fcb99eb0037db..b80e31a00f5d73ebb903cc7a18089f0c50176bb4 100644 (file)
@@ -826,7 +826,6 @@ static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
        COPY_SLAVE(stop_threshold);
        COPY_SLAVE(silence_threshold);
        COPY_SLAVE(silence_size);
-       COPY_SLAVE(xfer_align);
        COPY_SLAVE(boundary);
        COPY_SLAVE(info);
        COPY_SLAVE(msbits);
@@ -1180,7 +1179,6 @@ static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm)
        COPY_SLAVE(stop_threshold);
        COPY_SLAVE(silence_threshold);
        COPY_SLAVE(silence_size);
-       COPY_SLAVE(xfer_align);
        COPY_SLAVE(boundary);
        COPY_SLAVE(info);
        COPY_SLAVE(msbits);
index b51ca85199b061086690a4ff696b416fbc3b39ce..03ce53f3e4f07b0cd113799288cef6a8f0d4c624 100644 (file)
@@ -94,7 +94,7 @@ typedef struct {
                unsigned int stop_threshold;    
                unsigned int silence_threshold;
                unsigned int silence_size;
-               unsigned int xfer_align;
+               unsigned int xfer_align; /* not used */
                unsigned long long boundary;
                unsigned int info;
                unsigned int msbits;
index 94eca84e2d487c88f8422a10288bcefeb4887288..77a5c2ba3f89e5673745824fcc07a7929058b905 100644 (file)
@@ -295,7 +295,6 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
        if ((snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode &&
            params->period_step == pcm->period_step &&
            params->sleep_min == pcm->sleep_min &&
-           params->xfer_align == pcm->xfer_align &&
            params->start_threshold == pcm->start_threshold &&
            params->stop_threshold == pcm->stop_threshold &&
            params->silence_threshold == pcm->silence_threshold &&
index b5877cd0df8537825d5dbd2efd104ab7e5586e5c..11a0940797d056571cc50202d45cdcb2fec3aeea 100644 (file)
@@ -196,7 +196,6 @@ struct _snd_pcm {
        snd_pcm_uframes_t silence_threshold;    /* Silence filling happens when
                                           noise is nearest than this */
        snd_pcm_uframes_t silence_size; /* Silence filling size */
-       snd_pcm_uframes_t xfer_align;   /* xfer size need to be a multiple */
        snd_pcm_uframes_t boundary;     /* pointers wrap point */
        unsigned int info;              /* Info for returned setup */
        unsigned int msbits;            /* used most significant bits */
@@ -825,8 +824,6 @@ int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params,
 int INTERNAL(snd_pcm_sw_params_get_sleep_min)(const snd_pcm_sw_params_t *params, unsigned int *val);
 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
 int INTERNAL(snd_pcm_sw_params_get_avail_min)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
-int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
-int INTERNAL(snd_pcm_sw_params_get_xfer_align)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
 int INTERNAL(snd_pcm_sw_params_get_start_threshold)(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
index c0181e793424d2a3cff432569d7473b564de54cc..d3fe05ef77489ff0efc680120b2e90942b5bf772 100644 (file)
@@ -260,7 +260,6 @@ sync_slave_write(snd_pcm_t *pcm)
        size = map->appl_ptr - *slave->appl.ptr;
        if (size < 0)
                size += pcm->boundary;
-       size -= size % pcm->xfer_align;
        if (!size)
                return 0;
        offset = *slave->appl.ptr % pcm->buffer_size;
@@ -279,7 +278,6 @@ sync_slave_read(snd_pcm_t *pcm)
        size = *slave->hw.ptr - map->hw_ptr;
        if (size < 0)
                size += pcm->boundary;
-       size -= size % pcm->xfer_align;
        if (!size)
                return 0;
        offset = map->hw_ptr % pcm->buffer_size;
index 63785010ed9a1a994b83c4cc1442579ba8926b54..897740336ebc7d364a0b78835b86d5bb98af6bbb 100644 (file)
@@ -2234,7 +2234,7 @@ static int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params
        params->period_step = 1;
        params->sleep_min = 0;
        params->avail_min = pcm->period_size;
-       params->xfer_align = pcm->period_size;
+       params->xfer_align = 1;
        params->start_threshold = 1;
        params->stop_threshold = pcm->buffer_size;
        params->silence_threshold = 0;
index 26d26dbb8b10ac17326d351a18ed534d4d32619c..c5bded4d8f04fddda8b49bf39f4fafc3cdc8cbdc 100644 (file)
@@ -387,15 +387,11 @@ static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
 
        recalc(pcm, &sparams->avail_min);
        rate->orig_avail_min = sparams->avail_min;
-       recalc(pcm, &sparams->xfer_align);
        recalc(pcm, &sparams->start_threshold);
        if (sparams->avail_min < 1) sparams->avail_min = 1;
-       if (sparams->xfer_align < 1) sparams->xfer_align = 1;
        if (sparams->start_threshold <= slave->buffer_size) {
                if (sparams->start_threshold > (slave->buffer_size / sparams->avail_min) * sparams->avail_min)
                        sparams->start_threshold = (slave->buffer_size / sparams->avail_min) * sparams->avail_min;
-               if (sparams->start_threshold > (slave->buffer_size / sparams->xfer_align) * sparams->xfer_align)
-                       sparams->start_threshold = (slave->buffer_size / sparams->xfer_align) * sparams->xfer_align;
        }
        if (sparams->stop_threshold >= params->boundary) {
                sparams->stop_threshold = sparams->boundary;
index 5629d06f228333db3b20e3a2a8bb7638ea76f689..975f69987b2f6e8ab84ab520b25bf155c45e1e6a 100644 (file)
@@ -132,9 +132,6 @@ static int set_sw_params(snd_pcm_t *pcm,
        default:
                return -EINVAL;
        }
-       if (err < 0)
-               return err;
-       err = snd_pcm_sw_params_set_xfer_align(pcm, sw_params, 1);
        if (err < 0)
                return err;
        err = snd_pcm_sw_params(pcm, sw_params);
index e472b4fb6b1bb4b67c77e24362b353fdec29832e..7132985f114b2b32d06112dfb30d399f6d82714b 100644 (file)
@@ -185,12 +185,6 @@ int setparams_set(snd_pcm_t *handle,
                printf("Unable to set avail min for %s: %s\n", id, snd_strerror(err));
                return err;
        }
-       val = !block ? 4 : 1;
-       err = snd_pcm_sw_params_set_xfer_align(handle, swparams, val);
-       if (err < 0) {
-               printf("Unable to set transfer align for %s: %s\n", id, snd_strerror(err));
-               return err;
-       }
        err = snd_pcm_sw_params(handle, swparams);
        if (err < 0) {
                printf("Unable to set sw params for %s: %s\n", id, snd_strerror(err));
index 17d0034f8d905f7022171dcf4e01161965bb6e94..fb38d499ce30a7c6bbac4074a13a4fd1dfec84e6 100644 (file)
@@ -177,12 +177,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams)
                printf("Unable to set avail min for playback: %s\n", snd_strerror(err));
                return err;
        }
-       /* align all transfers to 1 sample */
-       err = snd_pcm_sw_params_set_xfer_align(handle, swparams, 1);
-       if (err < 0) {
-               printf("Unable to set transfer align for playback: %s\n", snd_strerror(err));
-               return err;
-       }
        /* write the parameters to the playback device */
        err = snd_pcm_sw_params(handle, swparams);
        if (err < 0) {