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: Hans Verkuil <hverkuil@xs4all.nl>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Devin Heitmueller <dheitmueller@kernellabs.com>
Subject: Re: [ANNOUNCE] experimental alsa stream support at xawtv3
Date: Sat, 28 May 2011 11:10:46 -0300	[thread overview]
Message-ID: <4DE10266.1070709@redhat.com> (raw)
In-Reply-To: <4DE0EE44.8060000@infradead.org>

Em 28-05-2011 09:44, Mauro Carvalho Chehab escreveu:

>> Anyways I think we're are currently
>> doing this the wrong way up. We should first discuss what such an API
>> should look like and then implement it. Hopefully we can re-use a lot
>> of the existing code when we do this, but I think it is better
>> to first design the API and then write code to the API, the current
>> API at least to me feels somewhat like an API written around existing
>> code rather then the other way around.
> 
> No, was just the opposite: the API were designed to fulfil the needs by
> the alsa streaming methods implemented by Devin at tvtime:
> 
> int alsa_thread_startup(const char *pdevice, const char *cdevice);
> 
> The two arguments are the alsa playback device and the alsa capture device.
> 
> the API were designed around that, to do something like:
> 
> 	struct some_opaque_struct *opaque = discover_media_devices();
> 	alsa_playback = alsa_playback(opaque);
> 	alsa_capture = alsa_capture(opaque);
> 	alsa_thread_startup(alsa_playback, alsa_capture);
> 	free_media_devices(opaque);
> 
> PS.: I'm not using the real names/arguments at the above, to keep the example
>      simpler and clearer. The actual code is not that different from the above:
> 
> 	struct media_devices *md;
> 	unsigned int size = 0;
> 	char *alsa_cap, *alsa_out, *p;
> 	char *video_dev = "/dev/video0";
> 
> 	md = discover_media_devices(&size);
> 	p = strrchr(video_dev, '/');
> 	alsa_cap = get_first_alsa_cap_device(md, size, p + 1);
> 	alsa_out = get_first_no_video_out_device(md, size);
> 	if (alsa_cap && alsa_out)
> 		alsa_handler(alsa_out, alsa_cap);
> 	free_media_devices(md, size);
> 	...
> 	fd = open(video_dev, "rw");

I decided to re-organize the way the API will handle the devices, in order
to make clearer that the internal struct should be opaque to the applications
using the library [1].

[1] http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=435f4ba896f76d92a800a2089e06618d8c3d93f0

Now, the functions will just return a void pointer that is used as a parameter
for the other functions.

So, the typical usecase is, currently:

	void *md;
	char *alsa_playback, *alsa_capture, *p;

	md = discover_media_devices();
	if (!md)
		return;
	alsa_capture = get_first_alsa_cap_device(md, video_dev);
	alsa_playback = get_first_no_video_out_device(md);
	if (alsa_capture && alsa_playback)
		alsa_handler(alsa_playback, alsa_capture);
	free_media_devices(md);

I'll be working on improving the API, in order to read the uevent information from the
media nodes (were device major/minor info are stored) and to associate a device with
its file descriptor.

Cheers,
Mauro

  parent reply	other threads:[~2011-05-28 14:10 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 20:17 [ANNOUNCE] experimental alsa stream support at xawtv3 Mauro Carvalho Chehab
2011-05-23 20:19 ` Devin Heitmueller
2011-05-23 20:30   ` Mauro Carvalho Chehab
2011-05-23 20:32   ` Mauro Carvalho Chehab
2011-05-24  6:50 ` Hans Verkuil
2011-05-24  7:21   ` Hans de Goede
2011-05-24 14:09     ` Mauro Carvalho Chehab
2011-05-24 15:55       ` Hans de Goede
2011-05-28 12:44         ` Mauro Carvalho Chehab
2011-05-28 13:01           ` Rémi Denis-Courmont
2011-05-28 14:41             ` Mauro Carvalho Chehab
2011-05-28 14:10           ` Mauro Carvalho Chehab [this message]
2011-05-28 12:55       ` Rémi Denis-Courmont
2011-05-28 14:39         ` Mauro Carvalho Chehab
2011-05-24 14:15   ` Mauro Carvalho Chehab
2011-05-24 14:57   ` Devin Heitmueller
2011-05-26  6:53     ` Hans Verkuil
2011-05-28 12:17       ` Mauro Carvalho Chehab
2011-05-28 12:26         ` Hans de Goede
2011-05-28 15:24         ` Hans Verkuil
2011-05-28 16:04           ` Mauro Carvalho Chehab
2011-05-28 16:20           ` Mauro Carvalho Chehab
2011-05-29  1:01             ` [RFCv2] Add a library to retrieve associated media devices - was: " Mauro Carvalho Chehab
2011-05-29 11:19               ` Hans Verkuil
2011-05-29 11:47                 ` Andy Walls
2011-05-29 12:58                   ` Mauro Carvalho Chehab
2011-05-29 11:54                 ` Hans de Goede
2011-05-29 13:08                   ` Mauro Carvalho Chehab
2011-05-29 13:30                     ` Hans de Goede
2011-05-29 14:55                       ` Mauro Carvalho Chehab
2011-05-30  7:14                         ` Hans Verkuil
2011-05-30 13:15                           ` Mauro Carvalho Chehab
2011-05-29 12:11                 ` Mauro Carvalho Chehab
2011-05-29 14:39                   ` Mauro Carvalho Chehab
2011-05-30  6:34                   ` Hans Verkuil
2011-05-30 11:37                     ` Mauro Carvalho Chehab
2011-05-30  6:54                   ` Hans Verkuil
2011-05-30 13:03                     ` Mauro Carvalho Chehab
2011-05-28 12:00     ` Mauro Carvalho Chehab
  -- strict thread matches above, loose matches on Subject: below --
2011-05-24 17:26 Emil Meier
2011-05-24 17:46 ` Devin Heitmueller

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=4DE10266.1070709@redhat.com \
    --to=mchehab@redhat.com \
    --cc=dheitmueller@kernellabs.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --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