All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabien Chevalier <fabchevalier@free.fr>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] PATCH1/2: bluez-utils - fix-a2dp-buffer-constraints
Date: Sun, 14 Oct 2007 13:19:41 +0200	[thread overview]
Message-ID: <4711FB4D.2010609@free.fr> (raw)
In-Reply-To: <000001c80cca$eff9ed00$c72915ac@NOE.Nokia.com>

Hello Kai,

Please find a few comments below

> Hello,
> 
> I've been having some problems in using the Bluez ALSA/A2DP plugin
> with applications that use the ALSA API in event driven fashion (so
> 'write samples at last possible moment' instead of 'write samples when 
> there is free room in the buffer'). One test application I've used is
> Pulseaudio. 
> 
> Here're couple of patches (against CVS HEAD) that solve the 
> problems for me (for instance pulseaudio starts working with
> the plugin, less CPU usage with other apps).

Could you provide some details on the problems you experienced, as well 
the hardware platform you experienced them on ?

> diff -ruN bluez-utils.orig/audio/pcm_bluetooth.c bluez-utils/audio/pcm_bluetooth.c
> --- bluez-utils.orig/audio/pcm_bluetooth.c	2007-10-12 12:57:28.000000000 +0300
> +++ bluez-utils/audio/pcm_bluetooth.c	2007-10-12 15:04:49.000000000 +0300
> @@ -45,7 +45,8 @@
>  
>  #define MIN_PERIOD_TIME 1
>  
> -#define BUFFER_SIZE 2048
> +#define MIN_BUFFER_SIZE 256    /* minimum size of buffer */
> +#define MAX_BUFFER_SIZE 16384  /* allocated RAM for buffer */
>  
>  #ifdef ENABLE_DEBUG
>  #define DBG(fmt, arg...)  printf("DEBUG: %s: " fmt "\n" , __FUNCTION__ , ## arg)
> @@ -123,7 +124,7 @@
>  	sbc_t sbc;			/* Codec data */
>  	int codesize;			/* SBC codesize */
>  	int samples;			/* Number of encoded samples */
> -	uint8_t buffer[BUFFER_SIZE];	/* Codec transfer buffer */
> +	uint8_t buffer[MAX_BUFFER_SIZE];/* Codec transfer buffer */
>  	int count;			/* Codec transfer buffer counter */
>  
>  	int nsamples;			/* Cumulative number of codec samples */
> @@ -137,7 +138,7 @@
>  	struct ipc_data_cfg cfg;	/* Bluetooth device config */
>  	struct pollfd stream;		/* Audio stream filedescriptor */
>  	struct pollfd server;		/* Audio daemon filedescriptor */
> -	uint8_t buffer[BUFFER_SIZE];	/* Encoded transfer buffer */
> +	uint8_t buffer[MAX_BUFFER_SIZE];/* Encoded transfer buffer */
>  	int count;			/* Transfer buffer counter */
>  	struct bluetooth_a2dp a2dp;	/* A2DP data */
>  
> @@ -932,14 +933,24 @@
>  	if (err < 0)
>  		return err;
>  
> -	/* supported block size */
> +	/* supported block sizes:
> +	 *   - lower limit is A2DP codec size
> +	 *   - total buffer size is the upper limit (with two periods) */
>  	err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_PERIOD_BYTES,
> -						a2dp->codesize, a2dp->codesize);
> +					      a2dp->codesize, MAX_BUFFER_SIZE / 2);
> +	if (err < 0)
> +		return err;
> +
> +	/* supported buffer sizes */
> +	err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_BUFFER_BYTES,
> +					      MIN_BUFFER_SIZE, MAX_BUFFER_SIZE);
>  	if (err < 0)
>  		return err;

This part of the code is useless, you don't need to set 
SND_PCM_IOPLUG_HW_BUFFER_BYTES if you set SND_PCM_IOPLUG_HW_PERIODS, you 
just have to choose one of the two alternatives :-)

>  
> +	/* supported period count: 
> +	 *   - derived from max buffer size and minimum period size */
>  	err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_PERIODS,
> -									2, 50);
> +					      2, MAX_BUFFER_SIZE / a2dp->codesize);
>  	if (err < 0)
>  		return err;
>  
> 

Apart from that i'd say this is a foot step in the right direction :-)

Cheers,

Fabien

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  parent reply	other threads:[~2007-10-14 11:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 12:25 [Bluez-devel] PATCH1/2: bluez-utils - fix-a2dp-buffer-constraints Kai Vehmanen
2007-10-14  3:36 ` Luiz Augusto von Dentz
2007-10-14 11:19 ` Fabien Chevalier [this message]
2007-10-15 10:54   ` [Bluez-devel] PATCH1/2: bluez-utils -fix-a2dp-buffer-constraints Kai Vehmanen
2007-10-17 10:23     ` Fabien Chevalier
2007-10-17 14:36       ` Kai.Vehmanen
  -- strict thread matches above, loose matches on Subject: below --
2007-10-17 16:31 [Bluez-devel] PATCH1/2: bluez-utils - fix-a2dp-buffer-constraints Kai.Vehmanen
2007-10-18  8:42 ` Johan Hedberg
2007-10-18 10:08 ` Fabien Chevalier
2007-10-18 17:33   ` Jim Carter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4711FB4D.2010609@free.fr \
    --to=fabchevalier@free.fr \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.