From fa90e04b407a5bbfda3cf35650981aad10aa6f8b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 28 May 2011 11:09:00 -0300 Subject: [PATCH] get_media_devices: Improve usecase example and put it at the beginning Signed-off-by: Mauro Carvalho Chehab --- utils/libmedia_dev/get_media_devices.h | 46 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/utils/libmedia_dev/get_media_devices.h b/utils/libmedia_dev/get_media_devices.h index c56f8ff..0d3e809 100644 --- a/utils/libmedia_dev/get_media_devices.h +++ b/utils/libmedia_dev/get_media_devices.h @@ -22,6 +22,30 @@ */ #define GET_MEDIA_DEVICES_VERSION 0x0101 +/* + A typical usecase for the above API is: + +void start_alsa(char *video_dev) { + 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); +} + +start_alsa("/dev/video0"); + +Where alsa_handler() is some function that will need to handle + both alsa capture and playback devices. +*/ + + /** * enum device_type - Enumerates the type for each device * @@ -113,25 +137,3 @@ char *get_first_alsa_cap_device(void *opaque, char *v4l_device); * device. */ char *get_first_no_video_out_device(void *opaque); - -/* - * A typical usecase for the above API is: - * - * void *md; - * unsigned int size = 0; - * char *alsa_cap, *alsa_out, *p; - * char *video_dev = "/dev/video0"; - * - * md = discover_media_devices(); - * if (md) { - * p = strrchr(video_dev, '/'); - * alsa_cap = get_first_alsa_cap_device(md, p + 1); - * alsa_out = get_first_no_video_out_device(md); - * if (alsa_cap && alsa_out) - * alsa_handler(alsa_out, alsa_cap); - * free_media_devices(md); - * } - * - * Where alsa_handler() is some function that will need to handle - * both alsa capture and playback devices. - */ -- 2.7.4