* [PATCH (alsa-lib)] chmap: Always succeed setting the map to what it already is
@ 2013-06-05 14:52 David Henningsson
2013-06-05 15:57 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: David Henningsson @ 2013-06-05 14:52 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: David Henningsson
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>
---
src/pcm/pcm.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 7ec1f0e..ca4d416 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -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);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH (alsa-lib)] chmap: Always succeed setting the map to what it already is
2013-06-05 14:52 [PATCH (alsa-lib)] chmap: Always succeed setting the map to what it already is David Henningsson
@ 2013-06-05 15:57 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2013-06-05 15:57 UTC (permalink / raw)
To: David Henningsson; +Cc: alsa-devel
At Wed, 5 Jun 2013 16:52:10 +0200,
David Henningsson wrote:
>
> 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>
Thanks, applied.
Takashi
> ---
> src/pcm/pcm.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
> index 7ec1f0e..ca4d416 100644
> --- a/src/pcm/pcm.c
> +++ b/src/pcm/pcm.c
> @@ -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);
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-05 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 14:52 [PATCH (alsa-lib)] chmap: Always succeed setting the map to what it already is David Henningsson
2013-06-05 15:57 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.