From: <bc...@us...> - 2007-11-01 13:49:38
|
Revision: 1252 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1252&view=rev Author: bcholew Date: 2007-11-01 06:49:42 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Ensure video capture device ids start at a fixed number - even if they weren't present at initialization. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-10-31 19:01:27 UTC (rev 1251) +++ trunk/lib/video.c 2007-11-01 13:49:42 UTC (rev 1252) @@ -1371,19 +1371,14 @@ new_iaxc_dev_list[n].name = strdup(new_src_list[n].description); new_iaxc_dev_list[n].id_string = strdup(new_src_list[n].identifier); - /* this device may have been here all along - * Check if it has, and re-assign that device id + /* This device may have been here all along. + * If it has, re-assign that device id * else assign a new id */ for ( i = 0; i < vinfo.device_count; i++ ) { if ( !strcmp(new_iaxc_dev_list[n].name, vinfo.devices[i].name) ) { - /*fprintf(stderr, "EXISTING DEVICE: %s - (id=%d) '%s'\n", - new_iaxc_dev_list[n].name, - vinfo.devices[i].id, - new_iaxc_dev_list[n].id_string); - */ new_iaxc_dev_list[n].id = vinfo.devices[i].id; if ( vinfo.selected_device_id == new_iaxc_dev_list[n].id ) @@ -1394,10 +1389,6 @@ if ( i == vinfo.device_count ) { new_iaxc_dev_list[n].id = vinfo.next_id++; - fprintf(stderr, "NEW DEVICE: %s - (id=%d) '%s'\n", - new_iaxc_dev_list[n].name, - new_iaxc_dev_list[n].id, - new_iaxc_dev_list[n].id_string); list_changed = 1; } @@ -1530,12 +1521,14 @@ memset(&vinfo, 0, sizeof(vinfo)); - MUTEXINIT(&vinfo.camera_lock); - MUTEXINIT(&vinfo.dev_list_lock); - vinfo.width = vfinfo.width; vinfo.height = vfinfo.height; + vinfo.selected_device_id = -1; + vinfo.next_id = starting_id; + MUTEXINIT(&vinfo.camera_lock); + MUTEXINIT(&vinfo.dev_list_lock); + if ( !(vinfo.vc = vidcap_initialize()) ) { fprintf(stderr, "ERROR: failed vidcap_initialize\n"); @@ -1558,8 +1551,6 @@ vinfo.sapi_info.description, vinfo.sapi_info.identifier); - vinfo.selected_device_id = -1; - vinfo.device_count = vidcap_src_list_update(vinfo.sapi); if ( vinfo.device_count < 0 ) { @@ -1604,13 +1595,12 @@ * these ids may diverge as devices are added * and removed. */ - vinfo.devices[i].id = i + starting_id; + vinfo.devices[i].id = vinfo.next_id++; } - vinfo.next_id = vinfo.devices[vinfo.device_count - 1].id + 1; - /* set default source - the first device */ if ( vinfo.device_count ) { + /* set default source - the first device */ iaxc_video_device_set(vinfo.devices[0].id); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |