changeset 2818:9f68d309f8cb

printf's changed into mp_msg
author alex
date Sun, 11 Nov 2001 03:40:16 +0000
parents cc93d9786954
children 2e58962dc9fe
files libmpdemux/tv.c libmpdemux/tv.h libmpdemux/tvi_v4l.c
diffstat 3 files changed, 60 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/tv.c	Sun Nov 11 02:54:50 2001 +0000
+++ b/libmpdemux/tv.c	Sun Nov 11 03:40:16 2001 +0000
@@ -47,7 +47,7 @@
     demux_packet_t* dp;
     int len;
 
-    printf("demux_tv_fill_buffer(sequence:%d) called!\n", seq);
+    mp_msg(MSGT_DEMUX, MSGL_DBG2, "demux_tv_fill_buffer(sequence:%d) called!\n", seq);
 
 //    demux->filepos = -1;
 
@@ -90,7 +90,7 @@
     
     if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
     {
-	printf("Error: no video input present!\n");
+	mp_msg(MSGT_TV, MSGL_ERR, "Error: no video input present!\n");
 	return;
     }
     
@@ -110,8 +110,8 @@
 	sh_video->format = IMGFMT_RGB15;
     else
     {
-	printf("Unknown format given: %s\n", tv_param_outfmt);
-	printf("Using default: Planar YV12\n");
+	mp_msg(MSGT_TV, MSGL_ERR, "Unknown format given: %s\n", tv_param_outfmt);
+	mp_msg(MSGT_TV, MSGL_INFO, "Using default: Planar YV12\n");
 	sh_video->format = IMGFMT_YV12;
     }
     funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &sh_video->format);
@@ -139,7 +139,7 @@
 	}
 	else
 	{
-	    printf("Unable set requested width: %d\n", tv_param_width);
+	    mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested width: %d\n", tv_param_width);
 	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
 	    tv_param_width = sh_video->disp_w;
 	}    
@@ -157,7 +157,7 @@
 	}
 	else
 	{
-	    printf("Unable set requested height: %d\n", tv_param_height);
+	    mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested height: %d\n", tv_param_height);
 	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
 	    tv_param_height = sh_video->disp_h;
 	}    
@@ -165,7 +165,7 @@
     else
 	funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
 
-    printf("Output size: %dx%d\n", sh_video->disp_w, sh_video->disp_h);
+    mp_msg(MSGT_TV, MSGL_INFO, "Output size: %dx%d\n", sh_video->disp_w, sh_video->disp_h);
     
     demuxer->video->sh = sh_video;
     sh_video->ds = demuxer->video;
@@ -202,7 +202,7 @@
 	    case AFMT_MPEG:
 	    case AFMT_AC3:
 	    default:
-//		printf("%s unsupported!\n", audio_out_format_name(audio_format));
+		mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s' unsupported!\n", audio_out_format_name(audio_format));
 		goto no_audio;
 	}
 	
@@ -223,7 +223,7 @@
     funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &tv_param_freq);
 
     funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &tv_param_freq);
-    printf("freq: %lu\n", tv_param_freq);
+    mp_msg(MSGT_TV, MSGL_INFO, "Setting to frequency: %lu\n", tv_param_freq);
     
     /* also start device! */
     funcs->start(tvh->priv);
@@ -245,11 +245,11 @@
 {
     tvi_param_t *params;
 
-    printf("Selected driver: %s\n", tvh->info->short_name);
-    printf(" name: %s\n", tvh->info->name);
-    printf(" author: %s\n", tvh->info->author);
+    mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvh->info->short_name);
+    mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvh->info->name);
+    mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvh->info->author);
     if (tvh->info->comment)
-	printf(" comment: %s\n", tvh->info->comment);
+	mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment);
 
     params = malloc(sizeof(tvi_param_t)*2);
     params[0].opt = malloc(strlen("input"));
--- a/libmpdemux/tv.h	Sun Nov 11 02:54:50 2001 +0000
+++ b/libmpdemux/tv.h	Sun Nov 11 03:40:16 2001 +0000
@@ -4,6 +4,7 @@
 #include "../libao2/afmt.h"
 #include "../libvo/img_format.h"
 #include "../libvo/fastmemcpy.h"
+#include "mp_msg.h"
 
 extern unsigned long tv_param_freq;
 extern char *tv_param_channel;
--- a/libmpdemux/tvi_v4l.c	Sun Nov 11 02:54:50 2001 +0000
+++ b/libmpdemux/tvi_v4l.c	Sun Nov 11 03:40:16 2001 +0000
@@ -192,24 +192,6 @@
 
 static int one = 1, zero = 0;
 
-static int alarms;
-
-static void sigalarm(int signal)
-{
-    alarms++;
-    printf("v4l: timeout (got SIGALRM), hardware/driver problems?\n");
-}
-
-static void siginit(void)
-{
-    struct sigaction act, old;
-    
-    memset(&act, 0, sizeof(act));
-    act.sa_handler = sigalarm;
-    sigemptyset(&act.sa_mask);
-    sigaction(SIGALRM, &act, &old);
-}
-
 tvi_handle_t *tvi_init_v4l(char *device)
 {
     tvi_handle_t *h;
@@ -243,22 +225,22 @@
     priv->fd = open(priv->video_device, O_RDWR);
     if (priv->fd == -1)
     {
-	printf("v4l: unable to open '%s': %s\n",
+	mp_msg(MSGT_TV, MSGL_ERR, "unable to open '%s': %s\n",
 	    priv->video_device, strerror(errno));
 	goto err;
     }
 
-    printf("fd: %d\n", priv->fd);
+    mp_msg(MSGT_TV, MSGL_V, "Video fd: %d\n", priv->fd);
     
     /* get capabilities (priv->capability is needed!) */
     if (ioctl(priv->fd, VIDIOCGCAP, &priv->capability) == -1)
     {
-	printf("ioctl get capabilites error: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilites failed: %s\n", strerror(errno));
 	goto err;
     }
 
     fcntl(priv->fd, F_SETFD, FD_CLOEXEC);
-    siginit();
+//    siginit();
 
 #if 0
     for (i=0; params[i].opt; i++)
@@ -269,19 +251,19 @@
     printf("priv->input: %d\n", priv->input);
 #endif
 
-    printf("Selected device: %s\n", priv->capability.name);
-    printf(" Capabilites: ");
+    mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name);
+    mp_msg(MSGT_TV, MSGL_INFO, " Capabilites: ");
     for (i = 0; device_cap[i] != NULL; i++)
 	if (priv->capability.type & (1 << i))
-	    printf("%s ", device_cap[i]);
-    printf("\n");
-    printf(" Device type: %d\n", priv->capability.type);
-    printf(" Supported sizes: %dx%d => %dx%d\n",
+	    mp_msg(MSGT_TV, MSGL_INFO, "%s ", device_cap[i]);
+    mp_msg(MSGT_TV, MSGL_INFO, "\n");
+    mp_msg(MSGT_TV, MSGL_INFO, " Device type: %d\n", priv->capability.type);
+    mp_msg(MSGT_TV, MSGL_INFO, " Supported sizes: %dx%d => %dx%d\n",
 	priv->capability.minwidth, priv->capability.minheight,
 	priv->capability.maxwidth, priv->capability.maxheight);
     priv->width = priv->capability.minwidth;
     priv->height = priv->capability.minheight;
-    printf(" Inputs: %d\n", priv->capability.channels);
+    mp_msg(MSGT_TV, MSGL_INFO, " Inputs: %d\n", priv->capability.channels);
 
     priv->channels = malloc(sizeof(struct video_channel)*priv->capability.channels);
     memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels);
@@ -289,7 +271,7 @@
     {
 	priv->channels[i].channel = i;
 	ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]);
-	printf("  %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i,
+	mp_msg(MSGT_TV, MSGL_INFO, "  %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i,
 	    priv->channels[i].name,
 	    (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "",
 	    (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "",
@@ -301,27 +283,27 @@
 
     if (!(priv->capability.type & VID_TYPE_CAPTURE))
     {
-	printf("Only grabbing supported (for overlay use another program)\n");
+	mp_msg(MSGT_TV, MSGL_ERR, "Only grabbing supported (for overlay use another program)\n");
 	goto err;
     }
     
     /* map grab buffer */
     if (ioctl(priv->fd, VIDIOCGMBUF, &priv->mbuf) == -1)
     {
-	printf("ioctl get mbuf failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
 	goto err;
     }
 
-    printf("mbuf: size=%d, frames=%d\n",
+    mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
 	priv->mbuf.size, priv->mbuf.frames);
     priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
 		MAP_SHARED, priv->fd, 0);
     if (priv->mmap == -1)
     {
-	printf("Unabel to map memory for buffers: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "Unabel to map memory for buffers: %s\n", strerror(errno));
 	goto err;
     }
-    printf("our buffer: %p\n", priv->mmap);
+    mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap);
 
     /* num of buffers */
     priv->nbuf = priv->mbuf.frames;
@@ -350,7 +332,7 @@
     
     if (ioctl(priv->fd, VIDIOCGPICT, &priv->picture) == -1)
     {
-	printf("ioctl get picture failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno));
 	return(0);
     }
 
@@ -358,17 +340,17 @@
     priv->picture.depth = palette2depth(priv->picture.palette);
     priv->bytesperline = priv->width * priv->picture.depth / 8;
     
-    printf("Picture values:\n");
-    printf(" Depth: %d, Palette: %d (Format: %s)\n", priv->picture.depth,
+    mp_msg(MSGT_TV, MSGL_INFO, "Picture values:\n");
+    mp_msg(MSGT_TV, MSGL_INFO, " Depth: %d, Palette: %d (Format: %s)\n", priv->picture.depth,
 	priv->picture.palette, vo_format_name(priv->format));
-    printf(" Brightness: %d, Hue: %d, Colour: %d, Contrast: %d\n",
+    mp_msg(MSGT_TV, MSGL_INFO, " Brightness: %d, Hue: %d, Colour: %d, Contrast: %d\n",
 	priv->picture.brightness, priv->picture.hue,
 	priv->picture.colour, priv->picture.contrast);
     
 
     if (ioctl(priv->fd, VIDIOCSPICT, &priv->picture) == -1)
     {
-	printf("ioctl set picture failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
 	return(0);
     }
 
@@ -379,20 +361,20 @@
 	priv->buf[i].frame = i;
 	priv->buf[i].width = priv->width;
 	priv->buf[i].height = priv->height;
-	printf("buffer: %d => %p\n", i, &priv->buf[i]);
+	mp_msg(MSGT_TV, MSGL_DBG2, "buffer: %d => %p\n", i, &priv->buf[i]);
     } 
     
     /* start capture */
     if (ioctl(priv->fd, VIDIOCCAPTURE, &one) == -1)
     {
-	printf("ioctl capture failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl capture failed: %s\n", strerror(errno));
 	return(0);
     }
 }
 
 static int control(priv_t *priv, int cmd, void *arg)
 {
-    printf("debug: control(priv=%p, cmd=%d, arg=%p)\n",
+    mp_msg(MSGT_TV, MSGL_DBG2, "debug: control(priv=%p, cmd=%d, arg=%p)\n",
 	priv, cmd, arg);
     switch(cmd)
     {
@@ -439,14 +421,14 @@
 		    output_fmt = IMGFMT_YV12;
 		    break;
 		default:
-		    printf("no suitable output format found (%s)\n",
+		    mp_msg(MSGT_TV, MSGL_ERR, "no suitable output format found (%s)\n",
 			PALETTE(priv->palette));
 		    return(TVI_CONTROL_FALSE);
 	    }
 #endif
 	    output_fmt = priv->format;
 	    (int)*(void **)arg = output_fmt;
-	    printf("Output format: %s\n", vo_format_name(output_fmt));
+	    mp_msg(MSGT_TV, MSGL_INFO, "Output format: %s\n", vo_format_name(output_fmt));
 	    return(TVI_CONTROL_TRUE);
 	}
 	case TVI_CONTROL_VID_SET_FORMAT:
@@ -465,7 +447,7 @@
 	{
 	    int req_width = (int)*(void **)arg;
 	    
-	    printf("Requested width: %d\n", req_width);
+	    mp_msg(MSGT_TV, MSGL_INFO, "Requested width: %d\n", req_width);
 	    if ((req_width >= priv->capability.minwidth) &&
 		(req_width <= priv->capability.maxwidth))
 		return(TVI_CONTROL_TRUE);
@@ -481,7 +463,7 @@
 	{
 	    int req_height = (int)*(void **)arg;
 	    
-	    printf("Requested height: %d\n", req_height);
+	    mp_msg(MSGT_TV, MSGL_INFO, "Requested height: %d\n", req_height);
 	    if ((req_height >= priv->capability.minheight) &&
 		(req_height <= priv->capability.maxheight))
 		return(TVI_CONTROL_TRUE);
@@ -498,7 +480,7 @@
 	    
 	    if (ioctl(priv->fd, VIDIOCGFREQ, &freq) == -1)
 	    {
-		printf("ioctl get freq failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get freq failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
 	    
@@ -513,15 +495,15 @@
 	    /* argument is in MHz ! */
 	    unsigned long freq = (unsigned long)*(void **)arg;
 	    
-	    printf("requested frequency: %lu MHz\n", (float)freq/16);
+	    mp_msg(MSGT_TV, MSGL_V, "requested frequency: %lu MHz\n", (float)freq/16);
 	    
 	    /* tuner uses khz not mhz ! */
 	    if (priv->tuner.flags & VIDEO_TUNER_LOW)
 	        freq *= 1000;
-	    printf(" requesting from driver: freq=%.3f\n", (float)freq/16);
+	    mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16);
 	    if (ioctl(priv->fd, VIDIOCSFREQ, &freq) == -1)
 	    {
-		printf("ioctl set freq failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl set freq failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
 	    return(TVI_CONTROL_TRUE);
@@ -530,11 +512,11 @@
 	{
 	    if (ioctl(priv->fd, VIDIOCGTUNER, &priv->tuner) == -1)
 	    {
-		printf("ioctl get tuner failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
 	    
-	    printf("Tuner (%s) range: %lu -> %lu\n", priv->tuner.name,
+	    mp_msg(MSGT_TV, MSGL_INFO, "Tuner (%s) range: %lu -> %lu\n", priv->tuner.name,
 		priv->tuner.rangelow, priv->tuner.rangehigh);
 	    return(TVI_CONTROL_TRUE);
 	}
@@ -542,7 +524,7 @@
 	{
 	    if (ioctl(priv->fd, VIDIOCSTUNER, &priv->tuner) == -1)
 	    {
-		printf("ioctl get tuner failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
 	    return(TVI_CONTROL_TRUE);
@@ -556,7 +538,7 @@
 		((req_mode == VIDEO_MODE_NTSC) && !(priv->tuner.flags & VIDEO_TUNER_NTSC)) ||
 		((req_mode == VIDEO_MODE_SECAM) && !(priv->tuner.flags & VIDEO_TUNER_SECAM)))
 	    {
-		printf("tuner isn't capable to set norm!\n");
+		mp_msg(MSGT_TV, MSGL_ERR, "Tuner isn't capable to set norm!\n");
 		return(TVI_CONTROL_FALSE);
 	    }
 
@@ -609,7 +591,7 @@
 
 	    if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
 	    {
-		printf("ioctl get channel failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
 	    return(TVI_CONTROL_TRUE);
@@ -623,7 +605,7 @@
 	    
 	    if (req_chan >= priv->capability.channels)
 	    {
-		printf("Invalid input requested: %d, valid: 0-%d\n",
+		mp_msg(MSGT_TV, MSGL_ERR, "Invalid input requested: %d, valid: 0-%d\n",
 		    req_chan, priv->capability.channels);
 		return(TVI_CONTROL_FALSE);
 	    }
@@ -636,10 +618,10 @@
 
 	    if (ioctl(priv->fd, VIDIOCSCHAN, &chan) == -1)
 	    {
-		printf("ioctl set chan failed: %s\n", strerror(errno));
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno));
 		return(TVI_CONTROL_FALSE);
 	    }
-	    printf("Using input '%s'\n", chan.name);
+	    mp_msg(MSGT_TV, MSGL_INFO, "Using input '%s'\n", chan.name);
 
 	    /* update tuner state */
 	    if (priv->capability.type & VID_TYPE_TUNER)
@@ -659,22 +641,22 @@
     int frame = priv->queue % priv->nbuf;
     int nextframe = (priv->queue+1) % priv->nbuf;
 
-    printf("grab_video_frame(priv=%p, buffer=%p, len=%d\n",
+    mp_msg(MSGT_TV, MSGL_DBG2, "grab_video_frame(priv=%p, buffer=%p, len=%d\n",
 	priv, buffer, len);
 
-    printf("buf: %p + frame: %d => %p\n",
+    mp_msg(MSGT_TV, MSGL_DBG3, "buf: %p + frame: %d => %p\n",
 	priv->buf, nextframe, &priv->buf[nextframe]);
     if (ioctl(priv->fd, VIDIOCMCAPTURE, &priv->buf[nextframe]) == -1)
     {
-	printf("ioctl mcapture failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl mcapture failed: %s\n", strerror(errno));
 	return(0);
     }
     
     if (ioctl(priv->fd, VIDIOCSYNC, &priv->buf[frame].frame) == -1)
-	printf("ioctl sync failed: %s\n", strerror(errno));
+	mp_msg(MSGT_TV, MSGL_ERR, "ioctl sync failed: %s\n", strerror(errno));
     priv->queue++;
     
-    printf("mmap: %p + offset: %d => %p\n",
+    mp_msg(MSGT_TV, MSGL_DBG3, "mmap: %p + offset: %d => %p\n",
 	priv->mmap, priv->mbuf.offsets[frame],
 	priv->mmap+priv->mbuf.offsets[frame]);
     memcpy(buffer, priv->mmap+priv->mbuf.offsets[frame], len);