mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-15 04:10:00 +01:00
fix error handling, fix deadlock , fix stream names
This commit is contained in:
@@ -1879,6 +1879,7 @@ static void *v4l2_grabber_thread( void *v )
|
|||||||
|
|
||||||
if(!v4l2_verify_file( i->file ) ) {
|
if(!v4l2_verify_file( i->file ) ) {
|
||||||
i->stop = 1;
|
i->stop = 1;
|
||||||
|
unlock_(v);
|
||||||
veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Not a device file: %s" , i->file );
|
veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Not a device file: %s" , i->file );
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1886,6 +1887,7 @@ static void *v4l2_grabber_thread( void *v )
|
|||||||
|
|
||||||
v4l2info *v4l2 = v4l2open( i->file, i->channel, i->host_fmt, i->wid, i->hei, i->fps, i->norm );
|
v4l2info *v4l2 = v4l2open( i->file, i->channel, i->host_fmt, i->wid, i->hei, i->fps, i->norm );
|
||||||
if( v4l2 == NULL ) {
|
if( v4l2 == NULL ) {
|
||||||
|
i->stop = 1;
|
||||||
veejay_msg(0, "v4l2: error opening v4l2 device '%s'",i->file );
|
veejay_msg(0, "v4l2: error opening v4l2 device '%s'",i->file );
|
||||||
unlock_(v);
|
unlock_(v);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
@@ -1905,6 +1907,7 @@ static void *v4l2_grabber_thread( void *v )
|
|||||||
for( j = 0; j < N_FRAMES; j ++ ) {
|
for( j = 0; j < N_FRAMES; j ++ ) {
|
||||||
uint8_t *ptr = (uint8_t*) vj_malloc( sizeof(uint8_t) * RUP8(planes[0] * 4) );
|
uint8_t *ptr = (uint8_t*) vj_malloc( sizeof(uint8_t) * RUP8(planes[0] * 4) );
|
||||||
if(!ptr) {
|
if(!ptr) {
|
||||||
|
i->stop = 1;
|
||||||
veejay_msg(0, "v4l2: error allocating memory" );
|
veejay_msg(0, "v4l2: error allocating memory" );
|
||||||
unlock_(v);
|
unlock_(v);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
#include <veejay/vj-font.h>
|
#include <veejay/vj-font.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SOURCE_NAME_LEN 255
|
||||||
|
|
||||||
#include <libplugger/plugload.h>
|
#include <libplugger/plugload.h>
|
||||||
static veejay_t *_tag_info = NULL;
|
static veejay_t *_tag_info = NULL;
|
||||||
static hash_t *TagHash = NULL;
|
static hash_t *TagHash = NULL;
|
||||||
@@ -765,8 +767,7 @@ int vj_tag_set_stream_color(int t1, int r, int g, int b)
|
|||||||
if(!tag)
|
if(!tag)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
veejay_msg(VEEJAY_MSG_DEBUG,"Set stream %d color %d,%d,%d",t1,
|
veejay_msg(VEEJAY_MSG_DEBUG,"Set stream %d color %d,%d,%d",t1, r,g, b );
|
||||||
r,g, b );
|
|
||||||
|
|
||||||
tag->color_r = r;
|
tag->color_r = r;
|
||||||
tag->color_g = g;
|
tag->color_g = g;
|
||||||
@@ -797,8 +798,7 @@ int vj_tag_get_stream_color(int t1, int *r, int *g, int *b )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for network, filename /channel is passed as host/port num
|
// for network, filename /channel is passed as host/port num
|
||||||
int vj_tag_new(int type, char *filename, int stream_nr, editlist * el,
|
int vj_tag_new(int type, char *filename, int stream_nr, editlist * el, int pix_fmt, int channel , int extra , int has_composite)
|
||||||
int pix_fmt, int channel , int extra , int has_composite)
|
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int palette;
|
int palette;
|
||||||
@@ -831,9 +831,10 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag->source_name = (char *) vj_calloc(sizeof(char) * 255);
|
tag->source_name = (char *) vj_calloc(sizeof(char) * SOURCE_NAME_LEN);
|
||||||
if (!tag->source_name)
|
if (!tag->source_name)
|
||||||
{
|
{
|
||||||
|
free(tag);
|
||||||
veejay_msg(0, "Memory allocation error");
|
veejay_msg(0, "Memory allocation error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -850,6 +851,8 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el,
|
|||||||
if (!tag_node)
|
if (!tag_node)
|
||||||
{
|
{
|
||||||
veejay_msg(0, "Unable to find available ID");
|
veejay_msg(0, "Unable to find available ID");
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
id = avail_tag[i];
|
id = avail_tag[i];
|
||||||
@@ -912,16 +915,9 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el,
|
|||||||
#endif
|
#endif
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VJ_TAG_TYPE_V4L:
|
case VJ_TAG_TYPE_V4L:
|
||||||
sprintf(tag->source_name, "%s", filename );
|
snprintf(tag->source_name,SOURCE_NAME_LEN, "%s", filename );
|
||||||
|
|
||||||
veejay_msg(VEEJAY_MSG_DEBUG, "V4l: %s",filename);
|
if (!_vj_tag_new_unicap( tag,
|
||||||
|
|
||||||
/*
|
|
||||||
int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int device_num,
|
|
||||||
char norm, int palette,int pixfmt, int freq, int channel, int has_composite)
|
|
||||||
|
|
||||||
*/
|
|
||||||
if (!_vj_tag_new_unicap( tag,
|
|
||||||
stream_nr,w,h,
|
stream_nr,w,h,
|
||||||
extra, // device num
|
extra, // device num
|
||||||
el->video_norm,
|
el->video_norm,
|
||||||
@@ -931,57 +927,71 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
|||||||
channel,
|
channel,
|
||||||
has_composite,
|
has_composite,
|
||||||
video_driver_ ))
|
video_driver_ ))
|
||||||
{
|
{
|
||||||
veejay_msg(0, "Unable to open capture stream '%dx%d' (norm=%c,format=%x,device=%d,channel=%d)",
|
veejay_msg(0, "Unable to open capture stream '%dx%d' (norm=%c,format=%x,device=%d,channel=%d)", w,h,el->video_norm, pix_fmt, extra,channel );
|
||||||
w,h,el->video_norm, pix_fmt, extra,channel );
|
free(tag->source_name);
|
||||||
return -1;
|
free(tag);
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
case VJ_TAG_TYPE_MCAST:
|
break;
|
||||||
case VJ_TAG_TYPE_NET:
|
case VJ_TAG_TYPE_MCAST:
|
||||||
sprintf(tag->source_name, "%s", filename );
|
case VJ_TAG_TYPE_NET:
|
||||||
if( _vj_tag_new_net( tag,stream_nr, w,h,pix_fmt, filename, channel ,palette,type) != 1 )
|
snprintf(tag->source_name,SOURCE_NAME_LEN, "%s", filename );
|
||||||
return -1;
|
if( _vj_tag_new_net( tag,stream_nr, w,h,pix_fmt, filename, channel ,palette,type) != 1 ) {
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VJ_TAG_TYPE_DV1394:
|
case VJ_TAG_TYPE_DV1394:
|
||||||
#ifdef SUPPORT_READ_DV2
|
#ifdef SUPPORT_READ_DV2
|
||||||
sprintf(tag->source_name, "/dev/dv1394/%d", channel);
|
snprintf(tag->source_name, SOURCE_NAME_LEN,"dv1394 %d", channel);
|
||||||
if( _vj_tag_new_dv1394( tag, stream_nr,channel,1,el ) == 0 )
|
if( _vj_tag_new_dv1394( tag, stream_nr,channel,1,el ) == 0 )
|
||||||
{
|
{
|
||||||
veejay_msg(VEEJAY_MSG_ERROR, "error opening dv1394");
|
veejay_msg(VEEJAY_MSG_ERROR, "error opening dv1394 %d", channel);
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tag->active = 1;
|
tag->active = 1;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
veejay_msg(VEEJAY_MSG_DEBUG, "libdv not enabled at compile time");
|
veejay_msg(VEEJAY_MSG_DEBUG, "libdv not enabled at compile time");
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_GDK_PIXBUF
|
#ifdef USE_GDK_PIXBUF
|
||||||
case VJ_TAG_TYPE_PICTURE:
|
case VJ_TAG_TYPE_PICTURE:
|
||||||
sprintf(tag->source_name, "%s", filename);
|
snprintf(tag->source_name,SOURCE_NAME_LEN, "%s", filename);
|
||||||
if( _vj_tag_new_picture(tag, stream_nr, w, h, fps) != 1 )
|
if( _vj_tag_new_picture(tag, stream_nr, w, h, fps) != 1 ) {
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case VJ_TAG_TYPE_CALI:
|
case VJ_TAG_TYPE_CALI:
|
||||||
sprintf(tag->source_name,"%s",filename);
|
snprintf(tag->source_name,SOURCE_NAME_LEN,"%s",filename);
|
||||||
if(_vj_tag_new_cali( tag,stream_nr,w,h) != 1 )
|
if(_vj_tag_new_cali( tag,stream_nr,w,h) != 1 ) {
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VJ_TAG_TYPE_YUV4MPEG:
|
case VJ_TAG_TYPE_YUV4MPEG:
|
||||||
sprintf(tag->source_name, "%s", filename);
|
snprintf(tag->source_name,SOURCE_NAME_LEN, "%s", filename);
|
||||||
if (_vj_tag_new_yuv4mpeg(tag, stream_nr, w,h,fps) != 1)
|
if (_vj_tag_new_yuv4mpeg(tag, stream_nr, w,h,fps) != 1)
|
||||||
{
|
{
|
||||||
if(tag->source_name) free(tag->source_name);
|
free(tag->source_name);
|
||||||
if(tag) free(tag);
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tag->active = 1;
|
tag->active = 1;
|
||||||
break;
|
break;
|
||||||
case VJ_TAG_TYPE_GENERATOR:
|
case VJ_TAG_TYPE_GENERATOR:
|
||||||
|
|
||||||
sprintf(tag->source_name, "[GEN]" );
|
snprintf(tag->source_name,SOURCE_NAME_LEN, "%s", filename );
|
||||||
|
|
||||||
if( channel == -1 && filename == NULL ) {
|
if( channel == -1 && filename == NULL ) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
@@ -1037,8 +1047,7 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
|||||||
|
|
||||||
case VJ_TAG_TYPE_COLOR:
|
case VJ_TAG_TYPE_COLOR:
|
||||||
|
|
||||||
sprintf(tag->source_name, "[%d,%d,%d]",
|
snprintf(tag->source_name, SOURCE_NAME_LEN, "[solid %d]", tag->id );
|
||||||
tag->color_r,tag->color_g,tag->color_b );
|
|
||||||
/*
|
/*
|
||||||
if( channel == -1 ) {
|
if( channel == -1 ) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
@@ -1082,8 +1091,10 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
veejay_msg(0, "Stream type %d invalid", type );
|
veejay_msg(0, "Stream type %d invalid", type );
|
||||||
return -1;
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vj_tag_get_by_type( tag->source_type, tag->descr);
|
vj_tag_get_by_type( tag->source_type, tag->descr);
|
||||||
@@ -1111,7 +1122,9 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
|||||||
}
|
}
|
||||||
if (!vj_tag_put(tag))
|
if (!vj_tag_put(tag))
|
||||||
{
|
{
|
||||||
veejay_msg(0, "Unable to store stream");
|
veejay_msg(0, "Unable to store stream %d - Internal Error", tag->id);
|
||||||
|
free(tag->source_name);
|
||||||
|
free(tag);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
last_added_tag = tag->id;
|
last_added_tag = tag->id;
|
||||||
|
|||||||
Reference in New Issue
Block a user