[MPlayer-cvslog] r23903 - in trunk/stream: tv.c tv.h tvi_bsdbt848.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c

voroshil subversion at mplayerhq.hu
Sun Jul 29 12:18:38 CEST 2007


Author: voroshil
Date: Sun Jul 29 12:18:38 2007
New Revision: 23903

Log:
Removing global variables from tv://
Step 2: fixing tv subdrivers initialization.


Modified:
   trunk/stream/tv.c
   trunk/stream/tv.h
   trunk/stream/tvi_bsdbt848.c
   trunk/stream/tvi_dummy.c
   trunk/stream/tvi_v4l.c
   trunk/stream/tvi_v4l2.c

Modified: trunk/stream/tv.c
==============================================================================
--- trunk/stream/tv.c	(original)
+++ trunk/stream/tv.c	Sun Jul 29 12:18:38 2007
@@ -505,11 +505,11 @@ done:    
 	return 1;
 }
 
-static tvi_handle_t *tv_begin(void)
+static tvi_handle_t *tv_begin(tv_param_t* tv_param)
 {
     int i;
     tvi_handle_t* h;
-    if(!strcmp(tv_param_driver,"help")){
+    if(!strcmp(tv_param->driver,"help")){
         mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers);
         for(i=0;tvi_driver_list[i];i++){
 	    mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
@@ -521,10 +521,11 @@ static tvi_handle_t *tv_begin(void)
     }
 
     for(i=0;tvi_driver_list[i];i++){
-        if (!strcmp(tvi_driver_list[i]->short_name, tv_param_driver)){
-            h=tvi_driver_list[i]->tvi_init(tv_param_device,tv_param_adevice);
+        if (!strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
+            h=tvi_driver_list[i]->tvi_init(tv_param);
             if(!h) return NULL;
 
+            h->tv_param=tv_param;
             mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name,
             tvi_driver_list[i]->name,
             tvi_driver_list[i]->author,
@@ -533,7 +534,7 @@ static tvi_handle_t *tv_begin(void)
         }
     }
     
-    mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param_driver); 
+    mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver); 
     return(NULL);
 }
 
@@ -555,7 +556,7 @@ static demuxer_t* demux_open_tv(demuxer_
     tvi_functions_t *funcs;
     
     demuxer->priv=NULL;
-    if(!(tvh=tv_begin())) return NULL;
+    if(!(tvh=tv_begin(demuxer->stream->priv))) return NULL;
     if (!tvh->functions->init(tvh->priv)) return NULL;
     if (!open_tv(tvh)){
 	tv_uninit(tvh);

Modified: trunk/stream/tv.h
==============================================================================
--- trunk/stream/tv.h	(original)
+++ trunk/stream/tv.h	Sun Jul 29 12:18:38 2007
@@ -95,7 +95,7 @@ extern tv_param_t stream_tv_defaults;
  
 typedef struct tvi_info_s
 {
-    struct tvi_handle_s * (*tvi_init)(char *device,char *adevice);
+    struct tvi_handle_s * (*tvi_init)(tv_param_t* tv_param);
     const char *name;
     const char *short_name;
     const char *author;

Modified: trunk/stream/tvi_bsdbt848.c
==============================================================================
--- trunk/stream/tvi_bsdbt848.c	(original)
+++ trunk/stream/tvi_bsdbt848.c	Sun Jul 29 12:18:38 2007
@@ -64,7 +64,7 @@
 #include "libmpcodecs/img_format.h"
 #include "tv.h"
 
-static tvi_handle_t *tvi_init_bsdbt848(char *device, char *adevice);
+static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param);
 /* information about this file */
 tvi_info_t tvi_info_bsdbt848 = {
     tvi_init_bsdbt848,
@@ -134,6 +134,7 @@ typedef struct {
     int immediatemode;
     double starttime;
 
+    tv_param_t *tv_param;
 } priv_t;
 
 #include "tvi_def.h"
@@ -169,7 +170,7 @@ return;
 }
 
 /* handler creator - entry point ! */
-static tvi_handle_t *tvi_init_bsdbt848(char *device,char* adevice)
+static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param)
 {
     char* sep ;
     tvi_handle_t* tvh;
@@ -185,31 +186,32 @@ static tvi_handle_t *tvi_init_bsdbt848(c
     */
 
     /* set video device name */
-    if (!device){
+    if (!tv_param->device){
         priv->btdev = strdup("/dev/bktr0");
         priv->tunerdev = strdup("/dev/tuner0");
     }else{
-        sep = strchr(device,',');
-        priv->btdev = strdup(device);
+        sep = strchr(tv_param->device,',');
+        priv->btdev = strdup(tv_param->device);
         if(sep){
             // tuner device is also passed
             priv->tunerdev = strdup(sep+1);
-            priv->btdev[sep - device] = 0;
+            priv->btdev[sep - tv_param->device] = 0;
         }else{
             priv->tunerdev = strdup("/dev/tuner0");
         }
     }
 
     /* set audio device name */
-    if (!adevice)
+    if (!tv_param->adevice)
 #ifdef USE_SUN_AUDIO
         priv->dspdev = strdup("/dev/sound");
 #else
         priv->dspdev = strdup("/dev/dsp");
 #endif
     else
-        priv->dspdev = strdup(adevice);
+        priv->dspdev = strdup(tv_param->adevice);
 
+    tvh->tv_param=tv_param;
     return tvh;
 }
 

Modified: trunk/stream/tvi_dummy.c
==============================================================================
--- trunk/stream/tvi_dummy.c	(original)
+++ trunk/stream/tvi_dummy.c	Sun Jul 29 12:18:38 2007
@@ -8,7 +8,7 @@
 #include "libmpcodecs/img_format.h"
 #include "tv.h"
 
-static tvi_handle_t *tvi_init_dummy(char *device,char *adevice);
+static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param);
 /* information about this file */
 tvi_info_t tvi_info_dummy = {
 	tvi_init_dummy,
@@ -27,7 +27,7 @@ typedef struct {
 #include "tvi_def.h"
 
 /* handler creator - entry point ! */
-static tvi_handle_t *tvi_init_dummy(char *device,char *adevice)
+static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param)
 {
     return(new_handle());
 }

Modified: trunk/stream/tvi_v4l.c
==============================================================================
--- trunk/stream/tvi_v4l.c	(original)
+++ trunk/stream/tvi_v4l.c	Sun Jul 29 12:18:38 2007
@@ -48,7 +48,7 @@
 
 #include "audio_in.h"
 
-static tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
+static tvi_handle_t *tvi_init_v4l(tv_param_t* tv_param);
 
 tvi_info_t tvi_info_v4l = {
     tvi_init_v4l,
@@ -143,6 +143,7 @@ typedef struct {
     long                        audio_sent_blocks_total;
     long                        mjpeg_bufsize;
 
+    tv_param_t                  *tv_param;
 } priv_t;
 
 #include "tvi_def.h"
@@ -269,7 +270,7 @@ static void setup_audio_buffer_sizes(pri
            priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt);
 }
 
-static tvi_handle_t *tvi_init_v4l(char *device, char *adevice)
+static tvi_handle_t *tvi_init_v4l(tv_param_t* tv_param)
 {
     tvi_handle_t *h;
     priv_t *priv;
@@ -281,16 +282,16 @@ static tvi_handle_t *tvi_init_v4l(char *
     priv = h->priv;
 
     /* set video device name */
-    if (!device)
+    if (!tv_param->device)
         priv->video_device = strdup("/dev/video0");
     else
-        priv->video_device = strdup(device);
+        priv->video_device = strdup(tv_param->device);
 
     /* set video device name */
-    if (!adevice)
+    if (!tv_param->adevice)
         priv->audio_device = NULL;
     else {
-        priv->audio_device = strdup(adevice);
+        priv->audio_device = strdup(tv_param->adevice);
     }
 
     /* allocation failed */
@@ -299,6 +300,7 @@ static tvi_handle_t *tvi_init_v4l(char *
         return(NULL);
     }
 
+    h->tv_param=tv_param;
     return(h);
 }
 

Modified: trunk/stream/tvi_v4l2.c
==============================================================================
--- trunk/stream/tvi_v4l2.c	(original)
+++ trunk/stream/tvi_v4l2.c	Sun Jul 29 12:18:38 2007
@@ -47,7 +47,7 @@ known issues:
 #include "audio_in.h"
 
 #define info tvi_info_v4l2
-static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev);
+static tvi_handle_t *tvi_init_v4l2(tv_param_t* tv_param);
 /* information about this file */
 tvi_info_t tvi_info_v4l2 = {
     tvi_init_v4l2,
@@ -137,6 +137,8 @@ typedef struct {
     volatile long               audio_null_blocks_inserted;
     volatile long long          dropped_frames_timeshift;
     long long                   dropped_frames_compensated;
+
+    tv_param_t                  *tv_param;
 } priv_t;
 
 #include "tvi_def.h"
@@ -826,7 +828,7 @@ static int control(priv_t *priv, int cmd
 #define PRIV ((priv_t *) (tvi_handle->priv))
 
 /* handler creator - entry point ! */
-static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev)
+static tvi_handle_t *tvi_init_v4l2(tv_param_t* tv_param)
 {
     tvi_handle_t *tvi_handle;
 
@@ -837,14 +839,14 @@ static tvi_handle_t *tvi_init_v4l2(char 
     }
     PRIV->video_fd = -1;
 
-    PRIV->video_dev = strdup(video_dev? video_dev: "/dev/video0");
+    PRIV->video_dev = strdup(tv_param->device? tv_param->device: "/dev/video0");
     if (!PRIV->video_dev) {
         free_handle(tvi_handle);
         return NULL;
     }
 
-    if (audio_dev) {
-        PRIV->audio_dev = strdup(audio_dev);
+    if (tv_param->adevice) {
+        PRIV->audio_dev = strdup(tv_param->adevice);
         if (!PRIV->audio_dev) {
             free(PRIV->video_dev);
             free_handle(tvi_handle);
@@ -852,6 +854,7 @@ static tvi_handle_t *tvi_init_v4l2(char 
         }
     }
 
+    PRIV->tv_param=tv_param;
     return tvi_handle;
 }
 



More information about the MPlayer-cvslog mailing list