alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind
@ 2014-04-04 18:27 Andrew Eikum
  2014-04-06  2:46 ` Raymond Yau
  2014-04-07 10:43 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Eikum @ 2014-04-04 18:27 UTC (permalink / raw)
  To: patch, alsa-devel

snd_pcm_rewind is documented to return <0 on failure and >=0 on
success.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
---
I checked all other rewind implementations, and this was the only one
that obviously had this bug.

diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
index 54a3e67..2eb4b1b 100644
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -702,7 +702,7 @@ static snd_pcm_sframes_t snd_pcm_rate_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
 	snd_atomic_write_begin(&rate->watom);
 	n = snd_pcm_rate_move_applptr(pcm, -frames);
 	snd_atomic_write_end(&rate->watom);
-	return n;
+	return n < 0 ? -n : n;
 }
 
 static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind
  2014-04-04 18:27 [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind Andrew Eikum
@ 2014-04-06  2:46 ` Raymond Yau
  2014-04-07 10:43 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Raymond Yau @ 2014-04-06  2:46 UTC (permalink / raw)
  To: Andrew Eikum; +Cc: ALSA Development Mailing List, patch

2014-04-05 2:27 GMT+08:00 Andrew Eikum <aeikum@codeweavers.com>:

> snd_pcm_rewind is documented to return <0 on failure and >=0 on
> success.
>


does all resampler  support rewind ?

why do rate plugin assume all hardware support rewind ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind
  2014-04-04 18:27 [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind Andrew Eikum
  2014-04-06  2:46 ` Raymond Yau
@ 2014-04-07 10:43 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2014-04-07 10:43 UTC (permalink / raw)
  To: Andrew Eikum; +Cc: alsa-devel

At Fri, 4 Apr 2014 13:27:25 -0500,
Andrew Eikum wrote:
> 
> snd_pcm_rewind is documented to return <0 on failure and >=0 on
> success.
> 
> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>

Thanks, applied now.


Takashi

> ---
> I checked all other rewind implementations, and this was the only one
> that obviously had this bug.
> 
> diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
> index 54a3e67..2eb4b1b 100644
> --- a/src/pcm/pcm_rate.c
> +++ b/src/pcm/pcm_rate.c
> @@ -702,7 +702,7 @@ static snd_pcm_sframes_t snd_pcm_rate_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
>  	snd_atomic_write_begin(&rate->watom);
>  	n = snd_pcm_rate_move_applptr(pcm, -frames);
>  	snd_atomic_write_end(&rate->watom);
> -	return n;
> +	return n < 0 ? -n : n;
>  }
>  
>  static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-07 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-04 18:27 [PATCH alsa-lib] pcm: rate: Don't return negative frame count on success in rewind Andrew Eikum
2014-04-06  2:46 ` Raymond Yau
2014-04-07 10:43 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).