Removing global variables from tv://

Step 2: fixing tv subdrivers initialization.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23903 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
voroshil
2007-07-29 10:18:38 +00:00
parent b7adae655f
commit 7cdc5ad4fe
6 changed files with 36 additions and 28 deletions

View File

@@ -505,11 +505,11 @@ done:
return 1; return 1;
} }
static tvi_handle_t *tv_begin(void) static tvi_handle_t *tv_begin(tv_param_t* tv_param)
{ {
int i; int i;
tvi_handle_t* h; 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); mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers);
for(i=0;tvi_driver_list[i];i++){ 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); 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++){ for(i=0;tvi_driver_list[i];i++){
if (!strcmp(tvi_driver_list[i]->short_name, tv_param_driver)){ if (!strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
h=tvi_driver_list[i]->tvi_init(tv_param_device,tv_param_adevice); h=tvi_driver_list[i]->tvi_init(tv_param);
if(!h) return NULL; if(!h) return NULL;
h->tv_param=tv_param;
mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name, mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name,
tvi_driver_list[i]->name, tvi_driver_list[i]->name,
tvi_driver_list[i]->author, 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); return(NULL);
} }
@@ -555,7 +556,7 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
tvi_functions_t *funcs; tvi_functions_t *funcs;
demuxer->priv=NULL; 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 (!tvh->functions->init(tvh->priv)) return NULL;
if (!open_tv(tvh)){ if (!open_tv(tvh)){
tv_uninit(tvh); tv_uninit(tvh);

View File

@@ -95,7 +95,7 @@ extern tv_param_t stream_tv_defaults;
typedef struct tvi_info_s 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 *name;
const char *short_name; const char *short_name;
const char *author; const char *author;

View File

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

View File

@@ -8,7 +8,7 @@
#include "libmpcodecs/img_format.h" #include "libmpcodecs/img_format.h"
#include "tv.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 */ /* information about this file */
tvi_info_t tvi_info_dummy = { tvi_info_t tvi_info_dummy = {
tvi_init_dummy, tvi_init_dummy,
@@ -27,7 +27,7 @@ typedef struct {
#include "tvi_def.h" #include "tvi_def.h"
/* handler creator - entry point ! */ /* 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()); return(new_handle());
} }

View File

@@ -48,7 +48,7 @@
#include "audio_in.h" #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_info_t tvi_info_v4l = {
tvi_init_v4l, tvi_init_v4l,
@@ -143,6 +143,7 @@ typedef struct {
long audio_sent_blocks_total; long audio_sent_blocks_total;
long mjpeg_bufsize; long mjpeg_bufsize;
tv_param_t *tv_param;
} priv_t; } priv_t;
#include "tvi_def.h" #include "tvi_def.h"
@@ -269,7 +270,7 @@ static void setup_audio_buffer_sizes(priv_t *priv)
priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt); 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; tvi_handle_t *h;
priv_t *priv; priv_t *priv;
@@ -281,16 +282,16 @@ static tvi_handle_t *tvi_init_v4l(char *device, char *adevice)
priv = h->priv; priv = h->priv;
/* set video device name */ /* set video device name */
if (!device) if (!tv_param->device)
priv->video_device = strdup("/dev/video0"); priv->video_device = strdup("/dev/video0");
else else
priv->video_device = strdup(device); priv->video_device = strdup(tv_param->device);
/* set video device name */ /* set video device name */
if (!adevice) if (!tv_param->adevice)
priv->audio_device = NULL; priv->audio_device = NULL;
else { else {
priv->audio_device = strdup(adevice); priv->audio_device = strdup(tv_param->adevice);
} }
/* allocation failed */ /* allocation failed */
@@ -299,6 +300,7 @@ static tvi_handle_t *tvi_init_v4l(char *device, char *adevice)
return(NULL); return(NULL);
} }
h->tv_param=tv_param;
return(h); return(h);
} }

View File

@@ -47,7 +47,7 @@ known issues:
#include "audio_in.h" #include "audio_in.h"
#define info tvi_info_v4l2 #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 */ /* information about this file */
tvi_info_t tvi_info_v4l2 = { tvi_info_t tvi_info_v4l2 = {
tvi_init_v4l2, tvi_init_v4l2,
@@ -137,6 +137,8 @@ typedef struct {
volatile long audio_null_blocks_inserted; volatile long audio_null_blocks_inserted;
volatile long long dropped_frames_timeshift; volatile long long dropped_frames_timeshift;
long long dropped_frames_compensated; long long dropped_frames_compensated;
tv_param_t *tv_param;
} priv_t; } priv_t;
#include "tvi_def.h" #include "tvi_def.h"
@@ -826,7 +828,7 @@ static int control(priv_t *priv, int cmd, void *arg)
#define PRIV ((priv_t *) (tvi_handle->priv)) #define PRIV ((priv_t *) (tvi_handle->priv))
/* handler creator - entry point ! */ /* 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; tvi_handle_t *tvi_handle;
@@ -837,14 +839,14 @@ static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev)
} }
PRIV->video_fd = -1; 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) { if (!PRIV->video_dev) {
free_handle(tvi_handle); free_handle(tvi_handle);
return NULL; return NULL;
} }
if (audio_dev) { if (tv_param->adevice) {
PRIV->audio_dev = strdup(audio_dev); PRIV->audio_dev = strdup(tv_param->adevice);
if (!PRIV->audio_dev) { if (!PRIV->audio_dev) {
free(PRIV->video_dev); free(PRIV->video_dev);
free_handle(tvi_handle); free_handle(tvi_handle);
@@ -852,6 +854,7 @@ static tvi_handle_t *tvi_init_v4l2(char *video_dev, char *audio_dev)
} }
} }
PRIV->tv_param=tv_param;
return tvi_handle; return tvi_handle;
} }