diff mbox

[alsa-lib] pcm: fix return value of snd_pcm_share_slave_avail

Message ID 1409599776-5150-1-git-send-email-patrakov@gmail.com (mailing list archive)
State Accepted
Delegated to: Takashi Iwai
Headers show

Commit Message

Alexander Patrakov Sept. 1, 2014, 7:29 p.m. UTC
The return value was wrong for playback if slave->hw_ptr was near the
boundary and *pcm->appl.ptr was near zero. The wrong result was greater
than the boundary.

Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
---
 src/pcm/pcm_share.c | 2 ++
 1 file changed, 2 insertions(+)

Only compile-tested, as I don't know how to setup the "share" pcm.

Comments

Takashi Iwai Sept. 2, 2014, 5:21 a.m. UTC | #1
At Tue,  2 Sep 2014 01:29:36 +0600,
Alexander E. Patrakov wrote:
> 
> The return value was wrong for playback if slave->hw_ptr was near the
> boundary and *pcm->appl.ptr was near zero. The wrong result was greater
> than the boundary.
> 
> Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>

Applied, thanks.


Takashi

> ---
>  src/pcm/pcm_share.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> Only compile-tested, as I don't know how to setup the "share" pcm.
> 
> diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
> index 9770544..c301c7a 100644
> --- a/src/pcm/pcm_share.c
> +++ b/src/pcm/pcm_share.c
> @@ -128,6 +128,8 @@ static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave)
>  		avail += pcm->buffer_size;
>  	if (avail < 0)
>  		avail += pcm->boundary;
> +	else if ((snd_pcm_uframes_t) avail >= pcm->boundary)
> +		avail -= pcm->boundary;
>  	return avail;
>  }
>  
> -- 
> 2.1.0
>
diff mbox

Patch

diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index 9770544..c301c7a 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -128,6 +128,8 @@  static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave)
 		avail += pcm->buffer_size;
 	if (avail < 0)
 		avail += pcm->boundary;
+	else if ((snd_pcm_uframes_t) avail >= pcm->boundary)
+		avail -= pcm->boundary;
 	return avail;
 }