All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Tla/lka <atlka@pg.gda.pl>
To: Jaroslav Kysela <perex@suse.cz>
Cc: alsa-devel@alsa-project.org
Subject: Re: Re: [Alsa-user] AD1985 full-duplex(?)
Date: Mon, 6 Sep 2004 22:45:59 +0200	[thread overview]
Message-ID: <20040906204559.GA4584@sunrise.pg.gda.pl> (raw)
In-Reply-To: <Pine.LNX.4.58.0408311131310.1762@pnote.perex-int.cz>

Hi,

I am testing modified aoss library.
To satisfy OSS compatibility I defined fixed OSS buffer (64KiB).
So we have two buffers: ALSA ring buffer and emulated OSS ring buffer.
Read/write normal modes are unchanged but in DMA mode we must copy the
first buffer contents to the second. To satisfy low latency I copy data
from hw pointer position so any changes in OSS DMA buffer should be
quickly propagated to ALSA buffer. I can't just fill whole ALSA buffer
and then fill available space at every period because data could change
just several samples after hw position. So I am doing snd_pcm_mmap_begin
and snd_pcm_commit functions to move appl pointer in ALSA ring buffer
so it is all filled 
(alsa_hw_ptr % alsa.buffer_size == alsa_appl_ptr % alsa.buffer_size)
and then calculate oss_hw_ptr as oss_appl_ptr - alsa.buffer_size.
Now I can copy the data (size = alsa.buffer_size - alsa.period_size).
So far it works with Q1, Q2 and Q3. Copying less data not always works
properly - sound is distorted.

IMHO DMA mmaped mode in ALSA is not as easy to use as OSS DMA mode.
All we need is theoretically only the hw pointer position in DMA ring buffer 
to properly mix data from different events. But in ALSA we must
calculate it doing additional calls. Some functions like snd_pcm_delay
in normal DMA mode seems to be not needed. An app needs only ring buffer
hw position. Doing normal system call it can obtain current system time
so it can calculate the delay and correct sample position to mix.
In ALSA we should move appl pointer using mmap_begin and then mmap_commit
functions to avoid buffer underrun and calculate hw pointer manually
to know where mix the new data. So I think there is more to do then in
OSS case and more to do in the wrong way. I will send my sources
after more testing.

I have some questions. If I get delay < 0 and then do
err = snd_pcm_forward(pcm,-delay) what err returned value really means
(I am using dmix and of course rate plugins)?
How interpret err <= 0 value?
Also what is the meaning of snd_pcm_available > alsa.buffer_size?

Regards

-- 
Adam Tla/lka      mailto:atlka@pg.gda.pl    ^v^ ^v^ ^v^
System  & Network Administration Group           ~~~~~~
Computer Center,  Gdansk University of Technology, Poland
PGP public key:   finger atlka@sunrise.pg.gda.pl


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click

  reply	other threads:[~2004-09-06 20:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-31  8:52 Re: [Alsa-user] AD1985 full-duplex(?) Peter Zubaj
2004-08-31  9:39 ` Jaroslav Kysela
2004-09-06 20:45   ` Adam Tla/lka [this message]
2004-09-07  9:05     ` Jaroslav Kysela
2004-09-07 10:34       ` Adam Tla/lka
2004-09-07 13:23         ` Paul Davis
2004-09-07 13:40         ` Jaroslav Kysela
2004-09-08 17:15           ` Adam Tla/lka
     [not found]             ` <20040909122253.GE4584@sunrise.pg.gda.pl>
     [not found]               ` <Pine.LNX.4.58.0409091728420.4150@server.perex-int.cz>
2004-09-10  6:46                 ` Adam Tla/lka
2004-09-09  5:52       ` Adam Tla/lka
2004-09-09 12:59         ` Paul Davis
2004-09-09 13:28           ` Adam Tla/lka
2004-09-09 15:14         ` Jaroslav Kysela
2004-09-10  7:16           ` Adam Tla/lka
2004-09-10 11:44             ` Paul Davis
2004-09-10 19:04               ` Adam Tla/lka
2004-09-13 13:05                 ` Paul Davis
2004-09-13 17:24                   ` Adam Tla/lka
2004-09-26 22:21                   ` Adam Tlałka
2004-09-27  3:00                     ` Paul Davis
2004-09-27  6:38                       ` Adam Tlałka
2004-09-27 12:43                         ` Jaroslav Kysela
2004-09-28  5:11                           ` Adam Tlałka
2004-09-28 14:47                             ` Paul Davis
2004-09-29  5:51                               ` Adam Tlałka
2004-09-27 20:14                         ` Paul Davis
2004-09-28  6:10                           ` Adam Tlałka
     [not found] <200409281113.i8SBDo5U021462@localhost.localdomain>
2004-09-28 13:22 ` Adam Tlałka
2004-09-28 14:48   ` Jaroslav Kysela
2004-09-28 14:57   ` Paul Davis
2004-09-28 15:21     ` Takashi Iwai
2004-09-29  6:15     ` Adam Tlałka
     [not found] <Pine.HPX.4.33n.0408181538550.24798-100000@studcom.urz.uni-halle.de>
     [not found] ` <1092842830.13603.3.camel@localhost.localdomain>
     [not found]   ` <20040818181350.2b38e875@mango.fruits.de>
2004-08-18 17:37     ` Jaroslav Kysela
2004-08-18 18:15       ` Florian Schmidt
2004-08-19  8:58         ` Jaroslav Kysela
2004-08-19  9:46           ` Takashi Iwai
2004-08-19 10:28             ` Jaroslav Kysela
2004-08-23 11:36               ` Adam Tlałka
2004-08-23 11:54                 ` Jaroslav Kysela
2004-08-23 12:34                   ` Adam Tlałka
2004-08-23 14:39                     ` Jaroslav Kysela
2004-08-24  6:01                       ` Adam Tla/lka
2004-08-23 15:30                 ` Takashi Iwai
2004-08-28 19:10                   ` Adam Tlałka
2004-08-29  9:54                     ` Jaroslav Kysela
2004-08-29 18:35                       ` Adam Tlałka
2004-08-31  8:09                         ` Jaroslav Kysela
2004-08-19  9:48           ` Florian Schmidt
2004-08-20 10:58             ` Jaroslav Kysela

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=20040906204559.GA4584@sunrise.pg.gda.pl \
    --to=atlka@pg.gda.pl \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@suse.cz \
    /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.