public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: Some fixes for alsa_stream
Date: Wed, 15 Jun 2011 12:45:00 -0300	[thread overview]
Message-ID: <4DF8D37C.7010307@redhat.com> (raw)
In-Reply-To: <4DF8C32A.7090004@redhat.com>

Em 15-06-2011 11:35, Hans de Goede escreveu:

>>> This is a combination of the assumption there is a shared period size between
>>> the input device and the output device + the broken error handling.
>>
>> The code is doing a negotiation, in order to find a period that are acceptable
>> by both. Ok, there are other ways of doing it, but sharing the same period
>> probably means less overhead.
>>
> 
> This is what we call a premature optimization, there is not all that much
> overhead here, and demanding that both sizes will support a share period size
> may not always fly, and may likely lead to unnecessary large period sizes
> and thus too much latency in some cases.

I didn't write that part of the code, although I fixed it to work with a device
that provides audio at 32kHZ to play back on my audio card at 44.1kHz, using
software interpolation for the frame rate. It came from Devin's tree, that, in
turn, came from an alsa example (alsa-driver test tool latency.c, according with
the source code) but, IMHO, the code should do:

1) try to find a common buffer size that are acceptable by both drivers,
   as using the same buffer size helps to avoid memcpy's, especially if
   mmap mode is enabled;

2) If the buffer size means that the latency will be more than a reasonable
   time interval [1], then fall back to use different periods;

3) inform the latency introduced by the audio driver, in order to allow
   xawtv to sync audio and video.

(3) is not simple, because alsa doesn't provide a reliable timestamp, but
it shouldn't be that hard to implement some logic that will at least 
compensate for the additional delay introduced by the buffer size.

[1] Not sure what would be a reasonable delay. The original code were using a
buffer of 600 bytes, meaning a delay of 600/4800 (12,5 ms). Maybe twice this
value would still be reasonable. If we don't want to create a complicated
sync processing for (3), the maximum upper limit is the video streaming DQBUF
rate (about 166 ms, for an interlaced video at 30 fps).

Cheers,
Mauro.

  parent reply	other threads:[~2011-06-15 15:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-14  2:01 Some fixes for alsa_stream Mauro Carvalho Chehab
2011-06-14 12:48 ` Hans de Goede
2011-06-14 13:05   ` Mauro Carvalho Chehab
2011-06-14 13:39     ` Mauro Carvalho Chehab
2011-06-14 13:47     ` Hans de Goede
2011-06-14 13:52       ` Devin Heitmueller
2011-06-14 14:17         ` Mauro Carvalho Chehab
2011-06-14 14:37           ` Hans de Goede
2011-06-14 14:45             ` Mauro Carvalho Chehab
2011-06-14 14:48               ` Devin Heitmueller
2011-06-14 15:51                 ` Mauro Carvalho Chehab
2011-06-15 13:43               ` Hans de Goede
2011-06-15 14:25                 ` Mauro Carvalho Chehab
2011-06-15 14:35                   ` Hans de Goede
2011-06-15 14:51                     ` Mauro Carvalho Chehab
2011-06-15 15:45                     ` Mauro Carvalho Chehab [this message]
2011-06-16 12:29                       ` Hans de Goede
2011-06-16 14:38                         ` Mauro Carvalho Chehab
2011-06-16 15:11                           ` Hans de Goede
2011-06-16 15:35                             ` Mauro Carvalho Chehab
2011-06-16 18:19                               ` Hans de Goede
2011-06-16 18:28                                 ` Mauro Carvalho Chehab
2011-06-15 14:36                   ` Mauro Carvalho Chehab

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=4DF8D37C.7010307@redhat.com \
    --to=mchehab@redhat.com \
    --cc=dheitmueller@kernellabs.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-media@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox