]> git.alsa-project.org Git - alsa-lib.git/commitdiff
chmap: Always succeed setting the map to what it already is
authorDavid Henningsson <david.henningsson@canonical.com>
Wed, 5 Jun 2013 14:52:10 +0000 (16:52 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 5 Jun 2013 15:56:03 +0000 (17:56 +0200)
If we try to set the channel map to what it already is, this should
always succeed. E g, speaker-test can do this sometimes.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm.c

index 7ec1f0e5aa767bf604b4b26db0befefcebd3a96e..ca4d416fa054465b11b39f86c2e0e7bed513680b 100644 (file)
@@ -7361,6 +7361,13 @@ OBSOLETE1(snd_pcm_sw_params_get_silence_size, ALSA_0.9, ALSA_0.9.0rc4);
 
 #endif /* DOC_HIDDEN */
 
+static int chmap_equal(const snd_pcm_chmap_t *a, const snd_pcm_chmap_t *b)
+{
+       if (a->channels != b->channels)
+               return 0;
+       return !memcmp(a->pos, b->pos, a->channels * sizeof(a->pos[0]));
+}
+
 /**
  * \!brief Query the available channel maps
  * \param pcm PCM handle to query
@@ -7415,6 +7422,10 @@ snd_pcm_chmap_t *snd_pcm_get_chmap(snd_pcm_t *pcm)
  */
 int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
 {
+       const snd_pcm_chmap_t *oldmap = snd_pcm_get_chmap(pcm);
+       if (oldmap && chmap_equal(oldmap, map))
+               return 0;
+
        if (!pcm->ops->set_chmap)
                return -ENXIO;
        return pcm->ops->set_chmap(pcm, map);