drop send devices

fix v4l2 device list
This commit is contained in:
niels
2011-07-10 21:56:18 +02:00
parent 2486b67251
commit aaa614fa92
4 changed files with 23 additions and 55 deletions

View File

@@ -1722,10 +1722,19 @@ char **v4l2_get_device_list()
memset( files, 0, sizeof(char*) * (n_devices+1)); memset( files, 0, sizeof(char*) * (n_devices+1));
for( i = 0;i < n_devices; i ++ ) { for( i = 0;i < n_devices; i ++ ) {
files[i] = (char*) malloc(sizeof(char) * (strlen(list[i]) + 5)); char tmp[1024];
sprintf(files[i],"%s%s",v4lprefix, list[i]);
veejay_msg(VEEJAY_MSG_DEBUG, "Found %s", files[i]); snprintf(tmp, sizeof(tmp) - 1, "%03dDevice %02d%03d%s%s",
9, // 'Device xx'
i, // 'device num'
(5 + strlen(list[i])), //@ '/dev/' + device
v4lprefix, // '/dev/'
list[i] // 'video0'
);
files[i] = strdup(tmp);
veejay_msg(VEEJAY_MSG_DEBUG, "Found '%s'", list[i]);
} }
files[n_devices] = NULL;
return files; return files;
} }

View File

@@ -237,7 +237,7 @@ char *vj_tag_scan_devices( void )
const char *default_str = "000000"; const char *default_str = "000000";
int num = 0; int num = 0;
int i; int i;
int len = 6; int len = 0;
#ifdef HAVE_UNICAP #ifdef HAVE_UNICAP
char **device_list = vj_unicap_get_devices(unicap_data_, &num); char **device_list = vj_unicap_get_devices(unicap_data_, &num);
#else #else
@@ -254,14 +254,16 @@ char *vj_tag_scan_devices( void )
for( i = 0; device_list[i] != NULL ;i++ ) for( i = 0; device_list[i] != NULL ;i++ )
len += strlen( device_list[i] ); len += strlen( device_list[i] );
char *n = (char*) vj_calloc(sizeof(char) * (len+1) ); char *n = (char*) vj_calloc(sizeof(char) * (6 + len) );
char *p = n + 6; char *p = n + 6;
sprintf(n, "%06d", (len-6) ); sprintf(n, "%06d", len );
for( i = 0; device_list[i] != NULL ;i++ ) for( i = 0; device_list[i] != NULL ;i++ )
{ {
int str_len = strlen(device_list[i]); char tmp[1024];
veejay_memcpy( p, device_list[i], str_len); snprintf( tmp, sizeof(tmp)-1, "%s", device_list[i] );
int str_len = strlen(tmp);
strncpy( p, tmp, str_len );
p += str_len; p += str_len;
free(device_list[i]); free(device_list[i]);
} }

View File

@@ -209,11 +209,11 @@ static inline unsigned long long int rdtsc()
#define small_memset(to,val,n) memset(to,val,n) #define small_memset(to,val,n) memset(to,val,n)
char *veejay_strncpy( char *dest, const char *src, size_t n ) char *veejay_strncpy( char *dest, const char *src, size_t n )
{ {
// dest[n-1] = '\0';
return strncpy( dest,src, n-1 ); return strncpy( dest,src, n-1 );
} }
char *veejay_strncat( char *s1, char *s2, size_t n ) {
// s2[n] = '\0'; char *veejay_strncat( char *s1, char *s2, size_t n )
{
return strncat( s1,s2, n); return strncat( s1,s2, n);
} }

View File

@@ -9051,49 +9051,6 @@ void vj_event_send_editlist ( void *ptr, const char format[], va_list ap )
free(s_print_buf); free(s_print_buf);
} }
void vj_event_send_devices ( void *ptr, const char format[], va_list ap )
{
char str[255];
struct dirent **namelist;
int n_dev = 0;
int n;
char device_list[512];
char useable_devices[2];
int *args = NULL;
veejay_t *v = (veejay_t*)ptr;
P_A(args,str,format,ap);
veejay_memset(device_list,0,512);
n = scandir(str,&namelist,0,alphasort);
if( n<= 0)
{
veejay_msg(VEEJAY_MSG_ERROR, "No device information in [%s]",str);
SEND_MSG(v,"0000");
return;
}
while(n--)
{
if( strncmp(namelist[n]->d_name, "video", 4)==0)
{
FILE *fd;
char filename[300];
sprintf(filename,"%s%s",str,namelist[n]->d_name);
fd = fopen( filename, "r");
if(fd)
{
fclose(fd);
}
}
}
sprintf(useable_devices,"%02d", n_dev);
APPEND_MSG( device_list, useable_devices );
SEND_MSG(v,device_list);
}
void vj_event_send_frame ( void *ptr, const char format[], va_list ap ) void vj_event_send_frame ( void *ptr, const char format[], va_list ap )
{ {
veejay_t *v = (veejay_t*) ptr; veejay_t *v = (veejay_t*) ptr;