[MPlayer-cvslog] r25407 - in trunk: libmenu/menu_dvbin.c stream/dvbin.h stream/stream_dvb.c

nicodvb subversion at mplayerhq.hu
Sat Dec 15 14:30:44 CET 2007


Author: nicodvb
Date: Sat Dec 15 14:30:44 2007
New Revision: 25407

Log:
get rid of the file-static dvb_config and free the config at close() .  Patch by Andrew Calkin and me

Modified:
   trunk/libmenu/menu_dvbin.c
   trunk/stream/dvbin.h
   trunk/stream/stream_dvb.c

Modified: trunk/libmenu/menu_dvbin.c
==============================================================================
--- trunk/libmenu/menu_dvbin.c	(original)
+++ trunk/libmenu/menu_dvbin.c	Sat Dec 15 14:30:44 2007
@@ -248,6 +248,7 @@ static void read_cmd(menu_t* menu, int c
 
 static void close_menu(menu_t* menu)
 {
+	dvb_free_config(mpriv->config);
 	menu_list_uninit(menu, free_entry);
 }
 

Modified: trunk/stream/dvbin.h
==============================================================================
--- trunk/stream/dvbin.h	(original)
+++ trunk/stream/dvbin.h	Sat Dec 15 14:30:44 2007
@@ -112,5 +112,6 @@ typedef struct {
 extern int dvb_step_channel(stream_t *, int);
 extern int dvb_set_channel(stream_t *, int, int);
 extern dvb_config_t *dvb_get_config(void);
+extern void dvb_free_config(dvb_config_t *config);
 
 #endif

Modified: trunk/stream/stream_dvb.c
==============================================================================
--- trunk/stream/stream_dvb.c	(original)
+++ trunk/stream/stream_dvb.c	Sat Dec 15 14:30:44 2007
@@ -125,7 +125,6 @@ extern int dvb_tune(dvb_priv_t *priv, in
 		fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout);
 extern char *dvb_dvrdev[4], *dvb_demuxdev[4], *dvb_frontenddev[4];
 
-static dvb_config_t *dvb_config = NULL;
 
 
 static dvb_channels_list *dvb_get_channels(char *filename, int type)
@@ -425,7 +424,26 @@ static dvb_channels_list *dvb_get_channe
 	return list;
 }
 
+void dvb_free_config(dvb_config_t *config)
+{
+	int i;
 
+	for(i=0; i<config->count; i++) 
+	{
+		if(config->cards[i].name)
+			free(config->cards[i].name);
+		if(!config->cards[i].list)
+			continue;
+		if(config->cards[i].list->channels)
+		{
+			if(config->cards[i].list->channels->name)
+				free(config->cards[i].list->channels->name);
+			free(config->cards[i].list->channels);
+		}
+		free(config->cards[i].list);
+	}  
+	free(config);
+}
 
 static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
 {
@@ -525,7 +543,6 @@ int dvb_set_channel(stream_t *stream, in
 		}
 	}
 
-	dvb_config->priv = priv;
 	priv->card = card;
 	priv->list = new_list;
 	priv->retry = 5;
@@ -605,7 +622,7 @@ static void dvbin_close(stream_t *stream
 #endif
 
 	priv->is_on = 0;
-	dvb_config->priv = NULL;
+	dvb_free_config(priv->config);
 }
 
 
@@ -675,15 +692,13 @@ static int dvb_open(stream_t *stream, in
 
 	priv = (dvb_priv_t *)stream->priv;
 	priv->stream = stream;
-	dvb_config = dvb_get_config();
-	if(dvb_config == NULL)
+	priv->config = dvb_get_config();
+	if(priv->config == NULL)
 	{
 		free(priv);
 		mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB CONFIGURATION IS EMPTY, exit\n");
 		return STREAM_ERROR;
 	}
-	dvb_config->priv = priv;
-	priv->config = dvb_config;
 
 	priv->card = -1;
 	for(i=0; i<priv->config->count; i++)
@@ -752,8 +767,6 @@ dvb_config_t *dvb_get_config(void)
 	dvb_card_config_t *cards = NULL, *tmp;
 	dvb_config_t *conf = NULL;
 	
-	if(dvb_config != NULL)
-		return dvb_config;
 			
 	conf = malloc(sizeof(dvb_config_t));
 	if(conf == NULL)
@@ -841,7 +854,6 @@ dvb_config_t *dvb_get_config(void)
 		conf = NULL;
 	}
 
-	dvb_config = conf;
 	return conf;
 }
 



More information about the MPlayer-cvslog mailing list