]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added snd_pcm_hw_params_get_min_align; changed get_format, get_subformat and get_acce...
authorJaroslav Kysela <perex@perex.cz>
Mon, 9 Sep 2002 19:47:50 +0000 (19:47 +0000)
committerJaroslav Kysela <perex@perex.cz>
Mon, 9 Sep 2002 19:47:50 +0000 (19:47 +0000)
12 files changed:
include/pcm.h
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_hw.c
src/pcm/pcm_lfloat.c
src/pcm/pcm_linear.c
src/pcm/pcm_mulaw.c
src/pcm/pcm_params.c
src/pcm/pcm_plug.c
src/pcm/pcm_rate.c
src/pcm/pcm_route.c

index 670d7c97c4842dd567200257eb8667126f1de910..a1d0a1f42ee7bd463d332c3d3cf4a9cc14f9e93f 100644 (file)
@@ -512,14 +512,14 @@ size_t snd_pcm_hw_params_sizeof(void);
 int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr);
 void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj);
 void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src);
-int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params);
+int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params, snd_pcm_access_t *val);
 int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val);
 int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val);
 snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 snd_pcm_access_t snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
 void snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
-int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params);
+int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val);
 int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
 int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
 snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
@@ -527,7 +527,7 @@ snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_pa
 int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
 void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
 int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val);
-int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params);
+int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *val);
 int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val);
 snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
@@ -623,6 +623,7 @@ int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *
 unsigned int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir);
 unsigned int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir);
 unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir);
+snd_pcm_sframes_t snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params);
 
 /** \} */
 
index 9dc49a1aeb17e17a3c318ea4a07cd9b3743309cd..ddef2836afd2ba0f6ae2429911f0e79198701e20 100644 (file)
@@ -2719,11 +2719,19 @@ void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t
 /**
  * \brief Extract access type from a configuration space
  * \param params Configuration space
+ * \param val Returned value
  * \return access type otherwise a negative error code if not exactly one is present
  */
-int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params)
+int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params, snd_pcm_access_t *val)
 {
-       return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, NULL);
+       int err;
+       
+       assert(val);
+       err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, NULL);
+       if (err < 0)
+               return err;
+       *val = err;
+       return 0;
 }
 
 /**
@@ -2806,11 +2814,19 @@ void snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_acce
 /**
  * \brief Extract format from a configuration space
  * \param params Configuration space
+ * \param val returned format
  * \return format otherwise a negative error code if not exactly one is present
  */
-int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params)
+int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val)
 {
-       return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL);
+       int err;
+       
+       assert(val);
+       err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL);
+       if (err < 0)
+               return err;
+       *val = err;
+       return 0;
 }
 
 /**
@@ -2905,11 +2921,19 @@ int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params
 /**
  * \brief Extract subformat from a configuration space
  * \param params Configuration space
+ * \param val Returned subformat
  * \return subformat otherwise a negative error code if not exactly one is present
  */
-int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params)
+int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *val)
 {
-       return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, NULL);
+       int err;
+       
+       assert(val);
+       err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, NULL);
+       if (err < 0)
+               return err;
+       *val = (snd_pcm_subformat_t)err;
+       return 0;
 }
 
 /**
@@ -4346,6 +4370,31 @@ unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_par
        return res;
 }
 
+/**
+ * \brief Get the minimum transfer align value in samples
+ * \param params Configuration space
+ * \return minimum align value otherwise a negative error code if not exactly one is present
+ */
+snd_pcm_sframes_t snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params)
+{
+       int format, channels, fb, min_align;
+
+       format = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL);
+       if (format < 0)
+               return format;
+       channels = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, NULL);
+       if (channels < 0)
+               return channels;
+       // compute frame bits
+       fb = snd_pcm_format_physical_width(format) * channels;
+        min_align = 1;
+       while (fb % 8) {
+               fb *= 2;
+                min_align *= 2;
+       }
+       return min_align;
+}
+
 /**
  * \brief Return current software configuration for a PCM
  * \param pcm PCM handle
index 26061e5e2159689c79216b78d2897ea38c9c9281..83729f4022da686e17dcad642f0ce4d86bd3940e 100644 (file)
@@ -407,6 +407,7 @@ static int snd_pcm_adpcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 {
        snd_pcm_adpcm_t *adpcm = pcm->private_data;
+       snd_pcm_format_t format;
        int err = snd_pcm_hw_params_slave(pcm, params,
                                          snd_pcm_adpcm_hw_refine_cchange,
                                          snd_pcm_adpcm_hw_refine_sprepare,
@@ -415,10 +416,13 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
        if (err < 0)
                return err;
 
+       err = snd_pcm_hw_params_get_format(params, &format);
+       if (err < 0)
+               return err;
 
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
                if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
-                       adpcm->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
+                       adpcm->getput_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S16);
                        adpcm->func = snd_pcm_adpcm_encode;
                } else {
                        adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, adpcm->sformat);
@@ -426,7 +430,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
                }
        } else {
                if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
-                       adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
+                       adpcm->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, format);
                        adpcm->func = snd_pcm_adpcm_decode;
                } else {
                        adpcm->getput_idx = snd_pcm_linear_get_index(adpcm->sformat, SND_PCM_FORMAT_S16);
index 9a8c84709451b1ab9e2849f831045d09570e10fb..6f46d14714472fe8669e5f53051073f5b7ffad20 100644 (file)
@@ -303,6 +303,7 @@ static int snd_pcm_alaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 {
        snd_pcm_alaw_t *alaw = pcm->private_data;
+       snd_pcm_format_t format;
        int err = snd_pcm_hw_params_slave(pcm, params,
                                          snd_pcm_alaw_hw_refine_cchange,
                                          snd_pcm_alaw_hw_refine_sprepare,
@@ -311,9 +312,13 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
        if (err < 0)
                return err;
 
+       err = snd_pcm_hw_params_get_format(params, &format);
+       if (err < 0)
+               return err;
+               
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
                if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
-                       alaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
+                       alaw->getput_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S16);
                        alaw->func = snd_pcm_alaw_encode;
                } else {
                        alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, alaw->sformat);
@@ -321,7 +326,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
                }
        } else {
                if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
-                       alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
+                       alaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, format);
                        alaw->func = snd_pcm_alaw_decode;
                } else {
                        alaw->getput_idx = snd_pcm_linear_get_index(alaw->sformat, SND_PCM_FORMAT_S16);
index 0a602fffe7bd7f5a8b4ddb79a784bf3ea27c9cb4..3a873493d84173942d1d995844e463af1845d929 100644 (file)
@@ -263,13 +263,16 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
        if (hw->mmap_emulation) {
                snd_pcm_hw_params_t old = *params;
                if (hw_params_call(hw, params) < 0) {
+                       snd_pcm_access_t access;
                        snd_pcm_access_mask_t oldmask;
                        const snd_mask_t *pmask;
 
                        *params = old;
                        pmask = snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS);
                        oldmask = *(snd_pcm_access_mask_t *)pmask;
-                       switch (snd_pcm_hw_params_get_access(params)) {
+                       if (snd_pcm_hw_params_get_access(params, &access) < 0)
+                               goto _err;
+                       switch (access) {
                        case SND_PCM_ACCESS_MMAP_INTERLEAVED:
                                snd_pcm_access_mask_reset((snd_pcm_access_mask_t *)pmask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
                                snd_pcm_access_mask_set((snd_pcm_access_mask_t *)pmask, SND_PCM_ACCESS_RW_INTERLEAVED);
index 4abc0f9f34cc3866f5f795fc17f9b9bf92b744e9..2bce2cdfa8e5e0fbe2808bc98bec21bed9d29128 100644 (file)
@@ -278,11 +278,11 @@ static int snd_pcm_lfloat_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
        if (err < 0)
                return err;
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
-               src_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &src_format);
                dst_format = slave->format;
        } else {
                src_format = slave->format;
-               dst_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &dst_format);
        }
        if (snd_pcm_format_linear(src_format)) {
                lfloat->int32_idx = snd_pcm_linear_get32_index(src_format, SND_PCM_FORMAT_S32);
index 6aec4b8e59b73ab1142bc4a069e2114c886d595d..98afd51e5859d118f7024a78d56ae66a1fe9148a 100644 (file)
@@ -310,6 +310,7 @@ static int snd_pcm_linear_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 {
        snd_pcm_linear_t *linear = pcm->private_data;
+       snd_pcm_format_t format;
        int err = snd_pcm_hw_params_slave(pcm, params,
                                          snd_pcm_linear_hw_refine_cchange,
                                          snd_pcm_linear_hw_refine_sprepare,
@@ -317,23 +318,26 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
                                          snd_pcm_plugin_hw_params_slave);
        if (err < 0)
                return err;
-       linear->use_getput = (snd_pcm_format_physical_width(snd_pcm_hw_params_get_format(params)) == 24 ||
+       err = snd_pcm_hw_params_get_format(params, &format);
+       if (err < 0)
+               return err;
+       linear->use_getput = (snd_pcm_format_physical_width(format) == 24 ||
                              snd_pcm_format_physical_width(linear->sformat) == 24);
        if (linear->use_getput) {
                if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
-                       linear->get_idx = snd_pcm_linear_get32_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S32);
+                       linear->get_idx = snd_pcm_linear_get32_index(format, SND_PCM_FORMAT_S32);
                        linear->put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, linear->sformat);
                } else {
                        linear->get_idx = snd_pcm_linear_get32_index(linear->sformat, SND_PCM_FORMAT_S32);
-                       linear->put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, snd_pcm_hw_params_get_format(params));
+                       linear->put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, format);
                }
        } else {
                if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
-                       linear->conv_idx = snd_pcm_linear_convert_index(snd_pcm_hw_params_get_format(params),
+                       linear->conv_idx = snd_pcm_linear_convert_index(format,
                                                                        linear->sformat);
                else
                        linear->conv_idx = snd_pcm_linear_convert_index(linear->sformat,
-                                                                       snd_pcm_hw_params_get_format(params));
+                                                                       format);
        }
        return 0;
 }
index 53b4d319e7e9b43bf8f064985a18740d05382b05..f1d394479a32e66234f2372fbb12045c31f497fd 100644 (file)
@@ -318,6 +318,7 @@ static int snd_pcm_mulaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 {
        snd_pcm_mulaw_t *mulaw = pcm->private_data;
+       snd_pcm_format_t format;
        int err = snd_pcm_hw_params_slave(pcm, params,
                                          snd_pcm_mulaw_hw_refine_cchange,
                                          snd_pcm_mulaw_hw_refine_sprepare,
@@ -326,9 +327,13 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
        if (err < 0)
                return err;
 
+       err = snd_pcm_hw_params_get_format(params, &format);
+       if (err < 0)
+               return err;
+
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
                if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
-                       mulaw->getput_idx = snd_pcm_linear_get_index(snd_pcm_hw_params_get_format(params), SND_PCM_FORMAT_S16);
+                       mulaw->getput_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S16);
                        mulaw->func = snd_pcm_mulaw_encode;
                } else {
                        mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, mulaw->sformat);
@@ -336,7 +341,7 @@ static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
                }
        } else {
                if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
-                       mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, snd_pcm_hw_params_get_format(params));
+                       mulaw->getput_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, format);
                        mulaw->func = snd_pcm_mulaw_decode;
                } else {
                        mulaw->getput_idx = snd_pcm_linear_get_index(mulaw->sformat, SND_PCM_FORMAT_S16);
index 100fa4cd680a989cfcbced1b8fd6e2871ed8b3d2..4e63ad876ac161e2d5636cbec01aba5ab840214b 100644 (file)
@@ -2179,9 +2179,9 @@ int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
                return err;
 
        pcm->setup = 1;
-       pcm->access = snd_pcm_hw_params_get_access(params);
-       pcm->format = snd_pcm_hw_params_get_format(params);
-       pcm->subformat = snd_pcm_hw_params_get_subformat(params);
+       snd_pcm_hw_params_get_access(params, &pcm->access);
+       snd_pcm_hw_params_get_format(params, &pcm->format);
+       snd_pcm_hw_params_get_subformat(params, &pcm->subformat);
        pcm->channels = snd_pcm_hw_params_get_channels(params);
        pcm->rate = snd_pcm_hw_params_get_rate(params, 0);
        pcm->period_time = snd_pcm_hw_params_get_period_time(params, 0);
index efed6609e98714abe32445fd0a615e553bbff743..0142b8a9f6c9d86708ef7fecaa2319111e4f6018 100644 (file)
@@ -859,12 +859,12 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
        err = snd_pcm_hw_refine_soft(slave, &sparams);
        assert(err >= 0);
 
-       clt_params.access = snd_pcm_hw_params_get_access(params);
-       clt_params.format = snd_pcm_hw_params_get_format(params);
+       snd_pcm_hw_params_get_access(params, &clt_params.access);
+       snd_pcm_hw_params_get_format(params, &clt_params.format);
        clt_params.channels = snd_pcm_hw_params_get_channels(params);
        clt_params.rate = snd_pcm_hw_params_get_rate(params, 0);
 
-       slv_params.format = snd_pcm_hw_params_get_format(&sparams);
+       snd_pcm_hw_params_get_format(&sparams, &slv_params.format);
        slv_params.channels = snd_pcm_hw_params_get_channels(&sparams);
        slv_params.rate = snd_pcm_hw_params_get_rate(&sparams, 0);
        snd_pcm_plug_clear(pcm);
index 5273d7dcc2d1470fa74aeb64ff1527749893f082..f9972f31d8934c9e17a41590068db0dd68fb5793 100644 (file)
@@ -375,16 +375,18 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
                return err;
 
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
-               src_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &src_format);
                dst_format = slave->format;
                src_rate = snd_pcm_hw_params_get_rate(params, 0);
                dst_rate = slave->rate;
        } else {
                src_format = slave->format;
-               dst_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &dst_format);
                src_rate = slave->rate;
                dst_rate = snd_pcm_hw_params_get_rate(params, 0);
        }
+       if (err < 0)
+               return err;
        rate->get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16);
        rate->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, dst_format);
        if (src_rate < dst_rate) {
index 26154c0c8a79c5bab8648a6a0e393cb0c51fe394..9455901e2f854b7f00a608c11a46154003c11c9d 100644 (file)
@@ -612,12 +612,14 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
                return err;
 
        if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
-               src_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &src_format);
                dst_format = slave->format;
        } else {
                src_format = slave->format;
-               dst_format = snd_pcm_hw_params_get_format(params);
+               err = snd_pcm_hw_params_get_format(params, &dst_format);
        }
+       if (err < 0)
+               return err;
        route->params.use_getput = snd_pcm_format_physical_width(src_format) == 24 ||
                snd_pcm_format_physical_width(dst_format) == 24;
        route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16);