From: Takashi Iwai Subject: Re: pointer callback in pcm Date: Fri, 10 Mar 2006 21:16:16 +0100 Message-ID: References: <1141942882.10937.5.camel@localhost.localdomain> <1141952015.13319.90.camel@mindpipe> <1142020261.9246.3.camel@localhost.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <1142020261.9246.3.camel@localhost.localdomain> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Adrian McMenamin Cc: Lee Revell , alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Fri, 10 Mar 2006 19:51:01 +0000, Adrian McMenamin wrote: > > On Thu, 2006-03-09 at 19:53 -0500, Lee Revell wrote: > > On Thu, 2006-03-09 at 22:21 +0000, Adrian McMenamin wrote: > > > The documentation states: > > > > > > "This callback is called when the PCM middle layer inquires the current > > > hardware position on the buffer." > > > > > > > > > Does that mean the position the hardware is at (in its ring buffer in my > > > case) or does it mean the position we are at in the dma buffer. > > > > > > ie I have a 128k DMA buffer which transfers samples into the 32k > > > hardware memory buffer. Which position am I meant to be reporting? > > > > > > > The DMA buffer should be the same size as the hardware buffer, so the > > positions should be the same. > > > > The pointer callback should return the position of sample that the > > hardware is currently playing. > > > Thanks. I am sure I am driving you round the twist now, but that (both > buffers being the same size) was a key piece of information I was > unaware of. There are several pints in it if you are ever around in > North London :) > > But my basic problem remains - my buffer is 8 periods long and I get to > hear them over and over again :( - nothing new is ever fed into the DMA > buffer and so nothing new therefore ever gets fed into the hardware > buffer. > > I start the process by transferring a whole eight periods worth into the > hardware buffer is that a mistake? Should I always be feeding in one > period at a time only? Hm, I've not checked your code and thread due to lack of my free time for ALSA recently, but the symptom above sounds like you implemented copy callback but still using mmap. The copy callback is designed basically only for read/write transfer. In the mmap mode, of course, such read/write transfer is eliminated, and no copy action occurs. Thus, first try not to set MMAP flag and let alsa-lib use the traditional read/write method. Some hardwares have actually separate h/w buffer and the memory buffer (s/w buffer). Even with such hardwares, mmap can be implemented. Instead of DMA transfer by hardware, the driver copies data between h/w and s/w buffers on demand, namely, before starting the stream (in trigger callback) and when each period is consumed (via ack callback). There are userful functions for such a case, found in pcm-indirect.h. They are used emu10k1 FX mode and cs46xx. HTH, Takashi ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642