changeset 7329:9129781e5939

removed messy global 'tv_handle', use stream->priv for that purpose note: i couldn't test it (only compile test) may be broken :( we're going to an unified demuxer API - required for modularization
author arpi
date Sun, 08 Sep 2002 23:00:01 +0000
parents 418c29a6d916
children 2f3fe8274028
files libmpdemux/demuxer.c libmpdemux/open.c libmpdemux/stream.h libmpdemux/tv.c mplayer.c
diffstat 5 files changed, 28 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sun Sep 08 22:57:23 2002 +0000
+++ b/libmpdemux/demuxer.c	Sun Sep 08 23:00:01 2002 +0000
@@ -157,13 +157,12 @@
 
 #ifdef USE_TV
 #include "tv.h"
-extern tvi_handle_t *tv_handler;
 extern int tv_param_on;
 
-extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh);
-extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
+extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds);
+extern int demux_open_tv(demuxer_t *demuxer);
 #if defined(USE_TV) && defined(HAVE_TV_V4L)
-extern void demux_close_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
+extern void demux_close_tv(demuxer_t *demuxer);
 #endif
 #endif
 
@@ -191,7 +190,7 @@
       demux_close_nuv(demuxer); break;
 #if defined(USE_TV) && defined(HAVE_TV_V4L)
     case DEMUXER_TYPE_TV:
-	demux_close_tv(demuxer, tv_handler); break;
+	demux_close_tv(demuxer); break;
 #endif
 #ifdef HAVE_LIBDV095
     case DEMUXER_TYPE_RAWDV:
@@ -312,7 +311,7 @@
     case DEMUXER_TYPE_REAL: return demux_real_fill_buffer(demux);
     case DEMUXER_TYPE_NUV: return demux_nuv_fill_buffer(demux);
 #ifdef USE_TV
-    case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, ds, tv_handler);
+    case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, ds);
 #endif
     case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
     case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
@@ -994,11 +993,7 @@
  }
 #ifdef USE_TV
  case DEMUXER_TYPE_TV: {
-    if (!demux_open_tv(demuxer, tv_handler))
-    {
-	tv_uninit(tv_handler);
-	return(NULL);
-    }
+    if (!demux_open_tv(demuxer)) return(NULL);
     break;
  }
 #endif
--- a/libmpdemux/open.c	Sun Sep 08 22:57:23 2002 +0000
+++ b/libmpdemux/open.c	Sun Sep 08 23:00:01 2002 +0000
@@ -68,7 +68,6 @@
 
 #ifdef USE_TV
 #include "tv.h"
-tvi_handle_t *tv_handler;
 
 extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh);
 #endif
@@ -401,6 +400,8 @@
 //============ Check for TV-input ====
   if (tv_param_on == 1)
   {
+    tvi_handle_t *tv_handler;
+
     /* create stream */
     stream = new_stream(-1, STREAMTYPE_TV);
     if (!stream)
@@ -417,6 +418,8 @@
 
     if (!stream_open_tv(stream, tv_handler))
 	goto tv_err;
+
+    stream->priv=tv_handler;
     
     return(stream);
 
--- a/libmpdemux/stream.h	Sun Sep 08 22:57:23 2002 +0000
+++ b/libmpdemux/stream.h	Sun Sep 08 23:00:01 2002 +0000
@@ -42,7 +42,7 @@
   int eof;
   unsigned int cache_pid;
   void* cache_data;
-  void* priv; // used for DVD
+  void* priv; // used for DVD, TV, RTSP etc
   unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE];
 #ifdef STREAMING
   streaming_ctrl_t *streaming_ctrl;
--- a/libmpdemux/tv.c	Sun Sep 08 22:57:23 2002 +0000
+++ b/libmpdemux/tv.c	Sun Sep 08 23:00:01 2002 +0000
@@ -73,8 +73,9 @@
 */
 /* fill demux->video and demux->audio */
 
-int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh)
+int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
 {
+    tvi_handle_t *tvh=(tvi_handle_t*)(demux->stream->priv);
     demux_packet_t* dp;
 
     sh_video_t *sh_video = demux->video->sh;
@@ -254,8 +255,9 @@
 	return 1;
 }
 
-int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
+int demux_open_tv(demuxer_t *demuxer)
 {
+    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->stream->priv);
     sh_video_t *sh_video = NULL;
     sh_audio_t *sh_audio = NULL;
     tvi_functions_t *funcs = tvh->functions;
@@ -374,12 +376,18 @@
     }
 no_audio:
 
-    return(funcs->start(tvh->priv));	
+    if(!(funcs->start(tvh->priv))){
+	// start failed :(
+	tv_uninit(tvh);
+	return 0;
+    }
+    return 1;
 }
 
 #if defined(USE_TV) && defined(HAVE_TV_V4L)
-int demux_close_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
+int demux_close_tv(demuxer_t *demuxer)
 {
+    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->stream->priv);
     return(tvh->functions->uninit(tvh->priv));
 }
 #endif
--- a/mplayer.c	Sun Sep 08 22:57:23 2002 +0000
+++ b/mplayer.c	Sun Sep 08 23:00:01 2002 +0000
@@ -82,7 +82,7 @@
 #include "libmpdemux/tv.h"
 
 extern int tv_param_on;
-extern tvi_handle_t *tv_handler;
+//extern tvi_handle_t *tv_handler;
 #endif
 
 //**************************************************************************//
@@ -2220,18 +2220,18 @@
       if (tv_param_on == 1) {
 	int v = cmd->args[0].v.i;
 	if(v > 0)
-	  tv_step_channel(tv_handler, TV_CHANNEL_HIGHER);
+	  tv_step_channel((tvi_handle_t*)(stream->priv), TV_CHANNEL_HIGHER);
 	else
-	  tv_step_channel(tv_handler, TV_CHANNEL_LOWER);
+	  tv_step_channel((tvi_handle_t*)(stream->priv), TV_CHANNEL_LOWER);
       }
     } break;
     case MP_CMD_TV_STEP_NORM :  {
       if (tv_param_on == 1)
-	tv_step_norm(tv_handler);
+	tv_step_norm((tvi_handle_t*)(stream->priv));
     } break;
     case MP_CMD_TV_STEP_CHANNEL_LIST :  {
       if (tv_param_on == 1)
-	tv_step_chanlist(tv_handler);
+	tv_step_chanlist((tvi_handle_t*)(stream->priv));
     } break;
 #endif
     case MP_CMD_VO_FULLSCREEN: