All of lore.kernel.org
 help / color / mirror / Atom feed
* Problems with snd_pcm_writei() function
@ 2009-10-22 17:34 Douglas Lopes Pereira
  2009-10-23  7:39 ` Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Douglas Lopes Pereira @ 2009-10-22 17:34 UTC (permalink / raw)
  To: alsa-devel

Hi,

I'm modifying an application that calls snd_pcm_writei() function from
libasound2-dev (on verstion 1.0.16-2). I does work.

I'm splitting my audio data into 160 bytes buffers but when buffer
with different size is passed to that function I hear a noise (like
'Krrr') on my audio device.
I tried to add zeroed bytes to complete the buffer but it didn't work.
I tried to ignore the last buffer and it worked but with some side
effects: No other operation worked properly after that.

Please, can anyone help?
Thanks in advance.
Regards,
Douglas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with snd_pcm_writei() function
  2009-10-22 17:34 Problems with snd_pcm_writei() function Douglas Lopes Pereira
@ 2009-10-23  7:39 ` Clemens Ladisch
  2009-10-27 17:07   ` Douglas Lopes Pereira
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2009-10-23  7:39 UTC (permalink / raw)
  To: Douglas Lopes Pereira; +Cc: alsa-devel

Douglas Lopes Pereira wrote:
> I'm splitting my audio data into 160 bytes buffers but when buffer
> with different size is passed to that function I hear a noise (like
> 'Krrr') on my audio device.

Do you actually pass the correct number of frames?

How do you manage the timing of the snd_pcm_writei() calls?


Best regards,
Clemens

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with snd_pcm_writei() function
  2009-10-23  7:39 ` Clemens Ladisch
@ 2009-10-27 17:07   ` Douglas Lopes Pereira
  0 siblings, 0 replies; 3+ messages in thread
From: Douglas Lopes Pereira @ 2009-10-27 17:07 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

Hi Clemens,

thanks for your replay. Sorry about the delay, I was taking care of
high priority tasks.

Back to my problem, I'm convinced that I'm passing the correct number
of frames. Do I have to change the buffer if discarding non complete
buffers (<> 160bytes)?

I'm not sure how timing is managed since my function is called by a
third part application but it looks like my code is invoked in a "for"
loop. Next is part of the code which calls my function:

			for (cur = f, next = AST_LIST_NEXT(cur, frame_list);
			     cur;
			     cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) {
				if (!skip) {
					if ((res = chan->tech->write(chan, cur)) < 0) {
						chan->_softhangup |= AST_SOFTHANGUP_DEV;
						skip = 1;
					} else if (next) {
						/* don't do this for the last frame in the list,
						   as the code outside the loop will do it once
						*/
						chan->fout = FRAMECOUNT_INC(chan->fout);
					}
				}
				ast_frfree(cur);
			}


I sent a copy of my code to pastbin. It is available at:
http://www.pastebin.org/48749

I would be glad if you take a look at it.

Thanks for your time.
Regards,
Douglas

On Fri, Oct 23, 2009 at 5:39 AM, Clemens Ladisch <clemens@ladisch.de> wrote:
> Douglas Lopes Pereira wrote:
>> I'm splitting my audio data into 160 bytes buffers but when buffer
>> with different size is passed to that function I hear a noise (like
>> 'Krrr') on my audio device.
>
> Do you actually pass the correct number of frames?
>
> How do you manage the timing of the snd_pcm_writei() calls?
>
>
> Best regards,
> Clemens
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-10-27 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 17:34 Problems with snd_pcm_writei() function Douglas Lopes Pereira
2009-10-23  7:39 ` Clemens Ladisch
2009-10-27 17:07   ` Douglas Lopes Pereira

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.