From 2238f0536fa7bb4ad6d59ff38ed040dc4d81ff64 Mon Sep 17 00:00:00 2001 From: Ewald Snel Date: Tue, 23 Apr 2002 13:30:42 +0000 Subject: Fix memory leaks by disposing input, demux and decoder plugins at exit - add dispose() function to all decoder plugin structures CVS patchset: 1763 CVS date: 2002/04/23 13:30:42 --- src/demuxers/demux_avi.c | 7 ++++++- src/demuxers/demux_cda.c | 4 ++-- src/demuxers/demux_elem.c | 4 ++-- src/demuxers/demux_mpeg.c | 4 ++-- src/demuxers/demux_mpeg_block.c | 3 ++- src/demuxers/demux_mpgaudio.c | 4 ++-- src/demuxers/demux_pes.c | 4 ++-- src/demuxers/demux_ts.c | 5 ++--- src/input/input_cda.c | 16 +++++++++++++++- src/input/input_dvd.c | 18 +++++++++++++++++- src/input/input_file.c | 16 +++++++++++++++- src/input/input_http.c | 5 +++++ src/input/input_mms.c | 5 +++++ src/input/input_net.c | 5 +++++ src/input/input_plugin.h | 7 ++++++- src/input/input_rtp.c | 26 ++++++++++++++++++++++++++ src/input/input_stdin_fifo.c | 7 ++++++- src/input/input_vcd.c | 14 +++++++++++++- src/liba52/xine_decoder.c | 7 ++++++- src/libdts/xine_decoder.c | 7 ++++++- src/libffmpeg/xine_decoder.c | 7 ++++++- src/liblpcm/xine_decoder.c | 7 ++++++- src/libmad/xine_decoder.c | 7 ++++++- src/libmpeg2/xine_decoder.c | 7 ++++++- src/libspucc/xine_decoder.c | 12 +++++++++++- src/libspudec/spu_decoder_api.h | 2 ++ src/libspudec/xine_decoder.c | 12 +++++++++++- src/libsputext/xine_decoder.c | 7 ++++++- src/libvorbis/xine_decoder.c | 7 ++++++- src/libw32dll/w32codec.c | 12 +++++++++++- src/xine-engine/xine.c | 37 +++++++++++++++++++++++++++++++++++-- src/xine-engine/xine_internal.h | 6 +++++- 32 files changed, 256 insertions(+), 35 deletions(-) diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index b768a6dc9..53a4a8cdc 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_avi.c,v 1.79 2002/04/23 00:55:46 miguelfreitas Exp $ + * $Id: demux_avi.c,v 1.80 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for avi streams * @@ -228,6 +228,7 @@ static void AVI_close(avi_t *AVI) #define ERR_EXIT(x) \ do { \ this->AVI_errno = x; \ + free (AVI); \ return 0; \ } while(0) @@ -974,6 +975,10 @@ static void demux_avi_stop (demux_plugin_t *this_gen) { static void demux_avi_close (demux_plugin_t *this_gen) { demux_avi_t *this = (demux_avi_t *) this_gen; + + if (this->avi) + AVI_close (this->avi); + free(this); } diff --git a/src/demuxers/demux_cda.c b/src/demuxers/demux_cda.c index e7a5731a8..9b5c5eb50 100644 --- a/src/demuxers/demux_cda.c +++ b/src/demuxers/demux_cda.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_cda.c,v 1.11 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: demux_cda.c,v 1.12 2002/04/23 13:30:42 esnel Exp $ */ #ifdef HAVE_CONFIG_H @@ -289,7 +289,7 @@ static char *demux_cda_get_mimetypes(void) { * */ static void demux_cda_close (demux_plugin_t *this) { - + free (this); } /* diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index f5fc4c625..ab27c49a9 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_elem.c,v 1.38 2002/04/11 22:27:11 jcdutton Exp $ + * $Id: demux_elem.c,v 1.39 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for elementary mpeg streams * @@ -360,7 +360,7 @@ static char *demux_mpeg_elem_get_mimetypes(void) { } static void demux_mpeg_elem_close (demux_plugin_t *this) { - /* nothing */ + free (this); } static int demux_mpeg_elem_get_stream_length(demux_plugin_t *this_gen) { diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 1f711a336..e78e1633f 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg.c,v 1.55 2002/04/19 03:05:07 miguelfreitas Exp $ + * $Id: demux_mpeg.c,v 1.56 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -971,7 +971,7 @@ static char *demux_mpeg_get_mimetypes(void) { } static void demux_mpeg_close (demux_plugin_t *this) { - /* nothing */ + free (this); } static int demux_mpeg_get_stream_length (demux_plugin_t *this_gen) { diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 730a9e435..30cba9fd8 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg_block.c,v 1.93 2002/04/22 01:08:34 f1rmb Exp $ + * $Id: demux_mpeg_block.c,v 1.94 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -818,6 +818,7 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { static void demux_mpeg_block_close (demux_plugin_t *this_gen) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; + free (this->scratch_base); free (this); } diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index b76ffc48e..6e8556820 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpgaudio.c,v 1.38 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: demux_mpgaudio.c,v 1.39 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -455,7 +455,7 @@ static char *demux_mpgaudio_get_mimetypes(void) { } static void demux_mpgaudio_close (demux_plugin_t *this) { - /* nothing */ + free (this); } static int demux_mpgaudio_get_stream_length (demux_plugin_t *this_gen) { diff --git a/src/demuxers/demux_pes.c b/src/demuxers/demux_pes.c index 99630901a..1d5a3f58f 100644 --- a/src/demuxers/demux_pes.c +++ b/src/demuxers/demux_pes.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_pes.c,v 1.24 2002/04/11 22:27:11 jcdutton Exp $ + * $Id: demux_pes.c,v 1.25 2002/04/23 13:30:42 esnel Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -615,7 +615,7 @@ static char *demux_pes_get_mimetypes(void) { } static void demux_pes_close (demux_plugin_t *this) { - /* nothing */ + free (this); } static int demux_pes_get_stream_length (demux_plugin_t *this_gen) { diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 9352c0724..f52d475e7 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_ts.c,v 1.41 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: demux_ts.c,v 1.42 2002/04/23 13:30:42 esnel Exp $ * * Demultiplexer for MPEG2 Transport Streams. * @@ -1228,8 +1228,7 @@ static void *demux_ts_loop(void *gen_this) { } static void demux_ts_close(demux_plugin_t *gen_this) { - - /* nothing */ + free (gen_this); } static char *demux_ts_get_id(void) { diff --git a/src/input/input_cda.c b/src/input/input_cda.c index bdf2a881b..fb7defe66 100644 --- a/src/input/input_cda.c +++ b/src/input/input_cda.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_cda.c,v 1.19 2002/04/11 22:27:11 jcdutton Exp $ + * $Id: input_cda.c,v 1.20 2002/04/23 13:30:42 esnel Exp $ */ #ifdef HAVE_CONFIG_H @@ -1768,6 +1768,19 @@ static int cda_plugin_get_optional_data (input_plugin_t *this_gen, void *data, i return INPUT_OPTIONAL_UNSUPPORTED; } +static int cda_plugin_dispose (input_plugin_t *this_gen ) { + cda_input_plugin_t *this = (cda_input_plugin_t *) this_gen; + int i; + + for (i = 0; i < 100; i++) + free (this->filelist[i]); + + free (this->cda->device_name); + free (this->cda); + free (this->mrls); + free (this); +} + /* * Initialize plugin. */ @@ -1813,6 +1826,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_mrl = cda_plugin_get_mrl; this->input_plugin.get_autoplay_list = cda_plugin_get_autoplay_list; this->input_plugin.get_optional_data = cda_plugin_get_optional_data; + this->input_plugin.dispose = cda_plugin_dispose; this->input_plugin.is_branch_possible = NULL; this->xine = xine; diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 739d5e173..e0a69fd6c 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_dvd.c,v 1.44 2002/04/11 22:27:11 jcdutton Exp $ + * $Id: input_dvd.c,v 1.45 2002/04/23 13:30:42 esnel Exp $ */ #ifdef HAVE_CONFIG_H @@ -786,6 +786,21 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int dvd_plugin_dispose (input_plugin_t *this_gen ) { + dvd_input_plugin_t *this = (dvd_input_plugin_t *) this_gen; + int i; + + read_cache_free (this->read_cache); + + for (i = 0; i < MAX_DIR_ENTRIES; i++) { + free (this->filelist[i]); + free (this->filelist2[i]); + } + + free (this->mrls); + free (this); +} + input_plugin_t *init_input_plugin (int iface, xine_t *xine) { @@ -830,6 +845,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_mrl = dvd_plugin_get_mrl; this->input_plugin.get_autoplay_list = dvd_plugin_get_autoplay_list; this->input_plugin.get_optional_data = dvd_plugin_get_optional_data; + this->input_plugin.dispose = dvd_plugin_dispose; this->input_plugin.is_branch_possible= NULL; /* disable branch until we fix the problems branching from menu vob to video vob diff --git a/src/input/input_file.c b/src/input/input_file.c index de98d55a8..9aa4e7ce9 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_file.c,v 1.43 2002/04/16 14:26:46 guenter Exp $ + * $Id: input_file.c,v 1.44 2002/04/23 13:30:43 esnel Exp $ */ #ifdef HAVE_CONFIG_H @@ -277,6 +277,9 @@ static int file_plugin_open (input_plugin_t *this_gen, char *mrl) { char *filename, *subtitle; file_input_plugin_t *this = (file_input_plugin_t *) this_gen; + if (this->mrl) + free (this->mrl); + this->mrl = strdup(mrl); /* FIXME: small memory leak */ if (!strncasecmp (this->mrl, "file:",5)) @@ -833,6 +836,16 @@ static int file_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int file_plugin_dispose (input_plugin_t *this_gen ) { + file_input_plugin_t *this = (file_input_plugin_t *) this_gen; + + if (this->mrl) + free (this->mrl); + + free (this->mrls); + free (this); +} + /* * */ @@ -873,6 +886,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_identifier = file_plugin_get_identifier; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = file_plugin_get_optional_data; + this->input_plugin.dispose = file_plugin_dispose; this->input_plugin.is_branch_possible = NULL; this->fh = -1; diff --git a/src/input/input_http.c b/src/input/input_http.c index e0b09d1a4..8cf804ad6 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -659,6 +659,10 @@ static int http_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int http_plugin_dispose (input_plugin_t *this_gen ) { + free (this_gen); +} + input_plugin_t *init_input_plugin (int iface, xine_t *xine) { http_input_plugin_t *this; @@ -696,6 +700,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_identifier = http_plugin_get_identifier; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = http_plugin_get_optional_data; + this->input_plugin.dispose = http_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->fh = -1; diff --git a/src/input/input_mms.c b/src/input/input_mms.c index a323e9d1c..a4888d4cb 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -308,6 +308,10 @@ static int mms_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int mms_plugin_dispose (input_plugin_t *this_gen ) { + free (this_gen); +} + input_plugin_t *init_input_plugin (int iface, xine_t *xine) { @@ -345,6 +349,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_identifier = mms_plugin_get_identifier; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = mms_plugin_get_optional_data; + this->input_plugin.dispose = mms_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->mrl = NULL; diff --git a/src/input/input_net.c b/src/input/input_net.c index 066d90258..2e986b82d 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -325,6 +325,10 @@ static int net_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int net_plugin_dispose (input_plugin_t *this_gen ) { + free (this_gen); +} + /* * */ @@ -365,6 +369,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_identifier = net_plugin_get_identifier; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = net_plugin_get_optional_data; + this->input_plugin.dispose = net_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->fh = -1; diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h index 703b959e3..a3b753e93 100644 --- a/src/input/input_plugin.h +++ b/src/input/input_plugin.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_plugin.h,v 1.22 2002/04/11 22:27:11 jcdutton Exp $ + * $Id: input_plugin.h,v 1.23 2002/04/23 13:30:43 esnel Exp $ */ #ifndef HAVE_INPUT_PLUGIN_H @@ -273,6 +273,11 @@ struct input_plugin_s */ int (*is_branch_possible) (input_plugin_t *this, char *next_mrl); + + /* + * free resources + */ + void (*dispose) (input_plugin_t *this); }; /* diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index 2d6097992..ad73e5e1d 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -476,6 +476,31 @@ static int rtp_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int rtp_plugin_dispose (input_plugin_t *this_gen ) { + rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; + input_buffer_t *buf; + + if (this->fifo_tail.next) { + while (this->fifo_tail.next != &this->fifo_tail) { + buf = this->fifo_tail.next->buf; + this->fifo_tail.next = this->fifo_tail.next->next; + + free (buf->buf); + free (buf); + } + } + + while (this->free_buffers) { + buf = this->free_buffers; + this->free_buffers = this->free_buffers->next; + + free (buf->buf); + free (buf); + } + + free (this); +} + /* * */ @@ -533,6 +558,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_mrl = rtp_plugin_get_mrl; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = rtp_plugin_get_optional_data; + this->input_plugin.dispose = rtp_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->fh = -1; diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index 117f22fa8..37df10a64 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_stdin_fifo.c,v 1.22 2002/03/23 18:56:55 guenter Exp $ + * $Id: input_stdin_fifo.c,v 1.23 2002/04/23 13:30:43 esnel Exp $ */ #ifdef HAVE_CONFIG_H @@ -341,6 +341,10 @@ static int stdin_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int stdin_plugin_dispose (input_plugin_t *this_gen ) { + free (this_gen); +} + input_plugin_t *init_input_plugin (int iface, xine_t *xine) { @@ -379,6 +383,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_identifier = stdin_plugin_get_identifier; this->input_plugin.get_autoplay_list = NULL; this->input_plugin.get_optional_data = stdin_plugin_get_optional_data; + this->input_plugin.dispose = stdin_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->fh = -1; diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index d328d4031..9cd31f7ce 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_vcd.c,v 1.38 2002/04/11 22:27:12 jcdutton Exp $ + * $Id: input_vcd.c,v 1.39 2002/04/23 13:30:43 esnel Exp $ * */ @@ -1121,6 +1121,17 @@ static int vcd_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } +static int vcd_plugin_dispose (input_plugin_t *this_gen ) { + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; + int i; + + for (i = 0; i < 100; i++) + free (this->filelist[i]); + + free (this->mrls); + free (this); +} + /* * */ @@ -1166,6 +1177,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->input_plugin.get_mrl = vcd_plugin_get_mrl; this->input_plugin.get_autoplay_list = vcd_plugin_get_autoplay_list; this->input_plugin.get_optional_data = vcd_plugin_get_optional_data; + this->input_plugin.dispose = vcd_plugin_dispose; this->input_plugin.is_branch_possible= NULL; this->device = config->register_string(config, "input.vcd_device", CDROM, diff --git a/src/liba52/xine_decoder.c b/src/liba52/xine_decoder.c index 017423a78..70d8934ca 100644 --- a/src/liba52/xine_decoder.c +++ b/src/liba52/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.23 2002/04/20 18:31:03 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.24 2002/04/23 13:30:43 esnel Exp $ * * stuff needed to turn liba52 into a xine decoder plugin */ @@ -537,6 +537,10 @@ static char *a52dec_get_id(void) { return "a/52dec"; } +static void a52dec_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { a52dec_decoder_t *this ; @@ -561,6 +565,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = a52dec_reset; this->audio_decoder.close = a52dec_close; this->audio_decoder.get_identifier = a52dec_get_id; + this->audio_decoder.dispose = a52dec_dispose; this->audio_decoder.priority = 2; diff --git a/src/libdts/xine_decoder.c b/src/libdts/xine_decoder.c index e409d2144..a95d33cc5 100644 --- a/src/libdts/xine_decoder.c +++ b/src/libdts/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.18 2002/04/20 18:31:03 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.19 2002/04/23 13:30:43 esnel Exp $ * * 04-09-2001 DTS passtrough (C) Joachim Koenig * 09-12-2001 DTS passthrough inprovements (C) James Courtier-Dutton @@ -221,6 +221,10 @@ static char *dts_get_id(void) { return "dts"; } +static void dts_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { dts_decoder_t *this ; @@ -242,6 +246,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = dts_reset; this->audio_decoder.close = dts_close; this->audio_decoder.get_identifier = dts_get_id; + this->audio_decoder.dispose = dts_dispose; this->audio_decoder.priority = 1; return (audio_decoder_t *) this; diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c index dd357ff86..55218f8f6 100644 --- a/src/libffmpeg/xine_decoder.c +++ b/src/libffmpeg/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.32 2002/04/21 02:56:39 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.33 2002/04/23 13:30:43 esnel Exp $ * * xine decoder plugin using ffmpeg * @@ -394,6 +394,10 @@ static void init_routine(void) { avcodec_register_all(); } +static void ff_dispose (video_decoder_t *this_gen) { + free (this_gen); +} + video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { ff_decoder_t *this ; @@ -419,6 +423,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { this->video_decoder.close = ff_close; this->video_decoder.get_identifier = ff_get_id; this->video_decoder.priority = 5; + this->video_decoder.dispose = ff_dispose; this->size = 0; pthread_once( &once_control, init_routine ); diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c index 408c12490..0c4e25159 100644 --- a/src/liblpcm/xine_decoder.c +++ b/src/liblpcm/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.21 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.22 2002/04/23 13:30:43 esnel Exp $ * * 31-8-2001 Added LPCM rate sensing. * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -149,6 +149,10 @@ static char *lpcm_get_id(void) { return "lpcm"; } +static void lpcm_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { lpcm_decoder_t *this ; @@ -170,6 +174,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = lpcm_reset; this->audio_decoder.close = lpcm_close; this->audio_decoder.get_identifier = lpcm_get_id; + this->audio_decoder.dispose = lpcm_dispose; this->audio_decoder.priority = 1; return (audio_decoder_t *) this; diff --git a/src/libmad/xine_decoder.c b/src/libmad/xine_decoder.c index 4ec9aa907..f7578e800 100644 --- a/src/libmad/xine_decoder.c +++ b/src/libmad/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.17 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.18 2002/04/23 13:30:43 esnel Exp $ * * stuff needed to turn libmad into a xine decoder plugin */ @@ -271,6 +271,10 @@ static char *mad_get_id(void) { return "mad"; } +static void mad_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { mad_decoder_t *this ; @@ -293,6 +297,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = mad_reset; this->audio_decoder.close = mad_close; this->audio_decoder.get_identifier = mad_get_id; + this->audio_decoder.dispose = mad_dispose; this->audio_decoder.priority = 5; return (audio_decoder_t *) this; diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c index 3543ce6e2..2525b888e 100644 --- a/src/libmpeg2/xine_decoder.c +++ b/src/libmpeg2/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.27 2002/04/09 03:38:00 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.28 2002/04/23 13:30:43 esnel Exp $ * * stuff needed to turn libmpeg2 into a xine decoder plugin */ @@ -141,6 +141,10 @@ static char *mpeg2dec_get_id(void) { return "mpeg2dec"; } +static void mpeg2dec_dispose (video_decoder_t *this_gen) { + free (this_gen); +} + video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { mpeg2dec_decoder_t *this ; @@ -164,6 +168,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { this->video_decoder.reset = mpeg2dec_reset; this->video_decoder.close = mpeg2dec_close; this->video_decoder.get_identifier = mpeg2dec_get_id; + this->video_decoder.dispose = mpeg2dec_dispose; this->video_decoder.priority = 5; this->mpeg2.xine = xine; diff --git a/src/libspucc/xine_decoder.c b/src/libspucc/xine_decoder.c index a27274470..4e9e4c17e 100644 --- a/src/libspucc/xine_decoder.c +++ b/src/libspucc/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.7 2002/04/09 13:53:52 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.8 2002/04/23 13:30:43 esnel Exp $ * * closed caption spu decoder. receive data by events. * @@ -362,6 +362,15 @@ static char *spudec_get_id(void) { return "spucc"; } +static void spudec_dispose (spu_decoder_t *this_gen) { + spucc_decoder_t *this = (spucc_decoder_t *) this_gen; + + xine_remove_event_listener (this->xine, spudec_event_listener); + + pthread_mutex_destroy (&this->cc_mutex); + free (this); +} + spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { @@ -383,6 +392,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this->spu_decoder.reset = spudec_reset; this->spu_decoder.close = spudec_close; this->spu_decoder.get_identifier = spudec_get_id; + this->spu_decoder.dispose = spudec_dispose; this->spu_decoder.priority = 1; this->xine = xine; diff --git a/src/libspudec/spu_decoder_api.h b/src/libspudec/spu_decoder_api.h index dc4f3889b..f7f4a6bcb 100644 --- a/src/libspudec/spu_decoder_api.h +++ b/src/libspudec/spu_decoder_api.h @@ -50,6 +50,8 @@ struct spu_decoder_s { char* (*get_identifier) (void); + void (*dispose) (spu_decoder_t *this); + int priority; metronom_t *metronom; diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c index 0b2b437ec..7f937d4d9 100644 --- a/src/libspudec/xine_decoder.c +++ b/src/libspudec/xine_decoder.c @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.60 2002/04/09 13:53:52 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.61 2002/04/23 13:30:44 esnel Exp $ * * stuff needed to turn libspu into a xine decoder plugin */ @@ -267,6 +267,15 @@ static char *spudec_get_id(void) { return "spudec"; } +static void spudec_dispose (spu_decoder_t *this_gen) { + spudec_decoder_t *this = (spudec_decoder_t *) this_gen; + + xine_remove_event_listener (this->xine, spudec_event_listener); + + free (this->event.object.overlay); + free (this); +} + spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { spudec_decoder_t *this ; @@ -289,6 +298,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this->spu_decoder.reset = spudec_reset; this->spu_decoder.close = spudec_close; this->spu_decoder.get_identifier = spudec_get_id; + this->spu_decoder.dispose = spudec_dispose; this->spu_decoder.priority = 1; this->xine = xine; diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c index c5c025d0c..db3d427cd 100644 --- a/src/libsputext/xine_decoder.c +++ b/src/libsputext/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.19 2002/04/09 13:53:52 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.20 2002/04/23 13:30:44 esnel Exp $ * * code based on mplayer module: * @@ -997,6 +997,10 @@ static void update_osd_dst_encoding(void *this_gen, cfg_entry_t *entry) printf("libsputext: spu_dst_encoding = %s\n", this->dst_encoding ); } +static void spudec_dispose (spu_decoder_t *this_gen) { + free (this_gen); +} + spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { sputext_decoder_t *this ; @@ -1017,6 +1021,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this->spu_decoder.reset = spudec_reset; this->spu_decoder.close = spudec_close; this->spu_decoder.get_identifier = spudec_get_id; + this->spu_decoder.dispose = spudec_dispose; this->spu_decoder.priority = 1; this->xine = xine; diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c index 883b2153c..643e0695a 100644 --- a/src/libvorbis/xine_decoder.c +++ b/src/libvorbis/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.9 2002/04/20 18:42:35 guenter Exp $ + * $Id: xine_decoder.c,v 1.10 2002/04/23 13:30:44 esnel Exp $ * * (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine */ @@ -235,6 +235,10 @@ static char *vorbis_get_id(void) { return "vorbis"; } +static void vorbis_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { vorbis_decoder_t *this ; @@ -257,6 +261,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = vorbis_reset; this->audio_decoder.close = vorbis_close; this->audio_decoder.get_identifier = vorbis_get_id; + this->audio_decoder.dispose = vorbis_dispose; this->audio_decoder.priority = 5; return (audio_decoder_t *) this; diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c index 2f0cec91a..d10b9c574 100644 --- a/src/libw32dll/w32codec.c +++ b/src/libw32dll/w32codec.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: w32codec.c,v 1.73 2002/04/23 00:58:32 miguelfreitas Exp $ + * $Id: w32codec.c,v 1.74 2002/04/23 13:30:44 esnel Exp $ * * routines for using w32 codecs * DirectShow support by Miguel Freitas (Nov/2001) @@ -896,6 +896,10 @@ static char *w32v_get_id(void) { return "vfw (win32) video decoder"; } +static void w32v_dispose (video_decoder_t *this_gen) { + free (this_gen); +} + /* * audio stuff */ @@ -1343,6 +1347,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { this->video_decoder.reset = w32v_reset; this->video_decoder.close = w32v_close; this->video_decoder.get_identifier = w32v_get_id; + this->video_decoder.dispose = w32v_dispose; this->video_decoder.priority = 1; pthread_mutex_init (&win32_codec_mutex, NULL); @@ -1356,6 +1361,10 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { return (video_decoder_t *) this; } +static void w32a_dispose (audio_decoder_t *this_gen) { + free (this_gen); +} + audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { w32a_decoder_t *this ; @@ -1384,6 +1393,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.reset = w32a_reset; this->audio_decoder.close = w32a_close; this->audio_decoder.get_identifier = w32a_get_id; + this->audio_decoder.dispose = w32a_dispose; this->audio_decoder.priority = 1; pthread_mutex_init (&win32_codec_mutex, NULL); diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 1606c173d..1b8859991 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.119 2002/04/16 12:27:20 jcdutton Exp $ + * $Id: xine.c,v 1.120 2002/04/23 13:30:44 esnel Exp $ * * top-level xine functions * @@ -455,7 +455,7 @@ int xine_eject (xine_t *this) { void xine_exit (xine_t *this) { - int i; + int i, j; xine_stop(this); @@ -480,6 +480,39 @@ void xine_exit (xine_t *this) { this->metronom->exit (this->metronom); + for (i = 0; i < this->num_demuxer_plugins; i++) + this->demuxer_plugins[i]->close (this->demuxer_plugins[i]); + + for (i = 0; i < this->num_input_plugins; i++) + this->input_plugins[i]->dispose (this->input_plugins[i]); + + for (i = 0; i < DECODER_PLUGIN_MAX; i++) { + if (this->audio_decoder_plugins[i]) { + this->audio_decoder_plugins[i]->dispose (this->audio_decoder_plugins[i]); + + for (j = i + 1; j < DECODER_PLUGIN_MAX; j++) { + if (this->audio_decoder_plugins[j] == this->audio_decoder_plugins[i]) + this->audio_decoder_plugins[j] = NULL; + } + } + if (this->video_decoder_plugins[i]) { + this->video_decoder_plugins[i]->dispose (this->video_decoder_plugins[i]); + + for (j = i + 1; j < DECODER_PLUGIN_MAX; j++) { + if (this->video_decoder_plugins[j] == this->video_decoder_plugins[i]) + this->video_decoder_plugins[j] = NULL; + } + } + if (this->spu_decoder_plugins[i]) { + this->spu_decoder_plugins[i]->dispose (this->spu_decoder_plugins[i]); + + for (j = i + 1; j < DECODER_PLUGIN_MAX; j++) { + if (this->spu_decoder_plugins[j] == this->spu_decoder_plugins[i]) + this->spu_decoder_plugins[j] = NULL; + } + } + } + xine_profiler_print_results (); free (this); diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 51aef162d..423528fa6 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_internal.h,v 1.77 2002/04/16 12:27:21 jcdutton Exp $ + * $Id: xine_internal.h,v 1.78 2002/04/23 13:30:44 esnel Exp $ * */ @@ -88,6 +88,8 @@ struct video_decoder_s { char* (*get_identifier) (void); + void (*dispose) (video_decoder_t *this); + int priority; metronom_t *metronom; @@ -120,6 +122,8 @@ struct audio_decoder_s { char* (*get_identifier) (void); + void (*dispose) (audio_decoder_t *this); + int priority; }; -- cgit v1.2.3