Patchwork [1/1] UBUNTU: SAUCE: Increase the default prealloc buffer for HDA audio devices (non-modem)

login
register
mail settings
Submitter Brad Figg
Date Dec. 10, 2009, 12:45 a.m.
Message ID <1260405905-22731-2-git-send-email-brad.figg@canonical.com>
Download mbox | patch
Permalink /patch/40771/
State Accepted
Delegated to: Andy Whitcroft
Headers show

Comments

Brad Figg - Dec. 10, 2009, 12:45 a.m.
This allows for buffering of up to 4 seconds of audio. This is
intended to improve the audio experience. This patch is being
carried by Fedora but is not upstream.

Signed-off-by: Brad Figg <brad.figg@canonical.com>
---
 sound/pci/hda/hda_intel.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
Daniel Chen - Dec. 10, 2009, 12:54 a.m.
On Wed, Dec 9, 2009 at 7:45 PM, Brad Figg <brad.figg@canonical.com> wrote:
> This allows for buffering of up to 4 seconds of audio. This is
> intended to improve the audio experience. This patch is being
> carried by Fedora but is not upstream.

FWIW, it has been carried in Fedora since 11 but appears to have been
backported to 10 as well. No one has complained about eaten kittens,
yet.

I've been testing since Jaunty via /etc/rc.local, and the hand-wavy
"it seems to smooth audio a bit on my NVidia controller" applies.

-Dan

Patch

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 6517f58..3f02c70 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1944,6 +1944,7 @@  azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
 	struct azx_pcm *apcm;
 	int pcm_dev = cpcm->device;
 	int s, err;
+	size_t prealloc_min = 64*1024;	/* 64KB */
 
 	if (pcm_dev >= AZX_MAX_PCMS) {
 		snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n",
@@ -1977,10 +1978,21 @@  azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
 		if (cpcm->stream[s].substreams)
 			snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
 	}
+
 	/* buffer pre-allocation */
+
+	/* subtle, don't allocate a big buffer for modems...
+	 * also, don't just test 32BIT_MASK, since azx supports
+	 * 64-bit DMA in some cases.
+	 */
+	/* lennart wants a 2.2MB buffer for 2sec of 48khz */
+	if (pcm->dev_class == SNDRV_PCM_CLASS_GENERIC &&
+	    chip->pci->dma_mask >= DMA_32BIT_MASK)
+		prealloc_min = 4 * 1024 * 1024;	/* 4MB */
+
 	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
 					      snd_dma_pci_data(chip->pci),
-					      1024 * 64, 32 * 1024 * 1024);
+					      prealloc_min, 32 * 1024 * 1024);
 	return 0;
 }