From: Takashi Iwai Subject: Re: [PATCH] alsa-plugins: Pulse: only underrun if no more data has been written Date: Fri, 26 Aug 2011 09:46:34 +0200 Message-ID: References: <4E4D2A67.9050507@canonical.com> <4E4E31A5.2090100@canonical.com> <4E53958A.5050602@canonical.com> <4E55E8ED.8010106@canonical.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6A95224676 for ; Fri, 26 Aug 2011 09:46:39 +0200 (CEST) In-Reply-To: <4E55E8ED.8010106@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: David Henningsson Cc: Raymond Yau , ALSA Development Mailing List List-Id: alsa-devel@alsa-project.org At Thu, 25 Aug 2011 08:17:17 +0200, David Henningsson wrote: > > On 08/25/2011 07:53 AM, Raymond Yau wrote: > > 2011/8/23 Takashi Iwai: > > be enough just to have a > >> boolean for underrun_detect yes/no. > >> > >> So, the patch would be like below. > >> > >> What do you think? > >> > >> > >> Takashi > >> > >> --- > >> diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c > >> index d6c6792..b0e52ab 100644 > >> --- a/pulse/pcm_pulse.c > >> +++ b/pulse/pcm_pulse.c > >> @@ -42,6 +42,7 @@ typedef struct snd_pcm_pulse { > >> int handle_underrun; > >> > >> size_t offset; > >> + int64_t written; > >> > >> pa_stream *stream; > >> > >> @@ -460,6 +461,7 @@ static snd_pcm_sframes_t pulse_write(snd_pcm_ioplug_t * io, > >> > >> /* Make sure the buffer pointer is in sync */ > >> pcm->last_size -= writebytes; > >> + pcm->written += writebytes; > >> ret = update_ptr(pcm); > >> if (ret< 0) > >> goto finish; > >> @@ -585,6 +587,15 @@ static void stream_request_cb(pa_stream * p, size_t length, void *userdata) > >> update_active(pcm); > >> } > >> > >> +#if defined(PA_CHECK_VERSION)&& PA_CHECK_VERSION(0,99,0) > > > > compile fail at these line since PA_CHECK_VERSION is not defined in > > pulseaudio 0.9.14 > > I don't have PA 0.9.14 available, but that's why the line starts with > "if defined(PA_CHECK_VERSION)" so that the second part should never be > evaluated. It actually is. gcc gives an error when it's not available. The preprocessor is not C, so it's a slightly different rule. I committed the build fix patch below. thanks, Takashi --- From: Takashi Iwai Subject: [PATCH] pulse - Define a dummy PA_CHECK_VERSION() when not available An old version of PA doesn't define this macro, and gives a build error. Signed-off-by: Takashi Iwai --- pulse/pcm_pulse.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index b0e52ab..e0fbd4c 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -587,7 +587,11 @@ static void stream_request_cb(pa_stream * p, size_t length, void *userdata) update_active(pcm); } -#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(0,99,0) +#ifndef PA_CHECK_VERSION +#define PA_CHECK_VERSION(x, y, z) 0 +#endif + +#if PA_CHECK_VERSION(0,99,0) #define DEFAULT_HANDLE_UNDERRUN 1 #define do_underrun_detect(pcm, p) \ ((pcm)->written <= pa_stream_get_underflow_index(p)) -- 1.7.6.1