From 703f9417096c5e7122dbe56721273ae0f79a46ad Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 18 Oct 2002 04:04:10 +0000 Subject: my very first try at the new streams api. some fixes to it (uninitialized stuff and plugins being instatiated several times). actually i got it to play something (have not tried sound though). CVS patchset: 2845 CVS date: 2002/10/18 04:04:10 --- src/demuxers/demux_avi.c | 5 +++- src/input/input_file.c | 13 ++++++++--- src/xine-engine/audio_decoder.c | 29 ++++++++++++----------- src/xine-engine/video_decoder.c | 51 ++++++++++++++++++++++------------------- src/xine-engine/xine.c | 21 +++++++++++++---- src/xine-engine/xine_internal.h | 5 +++- 6 files changed, 77 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 3205f6d71..b233ba52a 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.116 2002/10/17 17:43:42 mroi Exp $ + * $Id: demux_avi.c,v 1.117 2002/10/18 04:04:10 miguelfreitas Exp $ * * demultiplexer for avi streams * @@ -1210,6 +1210,8 @@ static void demux_avi_stop (demux_plugin_t *this_gen) { static void demux_avi_dispose (demux_plugin_t *this_gen) { demux_avi_t *this = (demux_avi_t *) this_gen; + demux_avi_stop(this_gen); + if (this->avi) AVI_close (this->avi); @@ -1530,6 +1532,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->demux_plugin.dispose = demux_avi_dispose; this->demux_plugin.get_status = demux_avi_get_status; this->demux_plugin.get_stream_length = demux_avi_get_stream_length; + this->demux_plugin.demux_class = class_gen; this->status = DEMUX_FINISHED; pthread_mutex_init (&this->mutex, NULL); diff --git a/src/input/input_file.c b/src/input/input_file.c index 123610682..66d028ad3 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.63 2002/10/17 17:43:43 mroi Exp $ + * $Id: input_file.c,v 1.64 2002/10/18 04:04:10 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -174,7 +174,7 @@ static int is_a_dir(char *filepathname) { return (S_ISDIR(pstat.st_mode)); } -static int file_plugin_eject_media (input_plugin_t *this_gen) { +static int file_plugin_eject_media (input_class_t *this_gen) { return 1; /* doesn't make sense */ } @@ -287,6 +287,7 @@ static input_plugin_t *open_plugin (input_class_t *cls_gen, xine_stream_t *strea this->input_plugin.get_mrl = file_plugin_get_mrl; this->input_plugin.get_optional_data = file_plugin_get_optional_data; this->input_plugin.dispose = file_plugin_dispose; + this->input_plugin.input_class = cls_gen; return &this->input_plugin; } @@ -475,6 +476,10 @@ static char *file_class_get_description (input_class_t *this_gen) { return _("file input plugin"); } +static char *file_class_get_identifier (input_class_t *this_gen) { + return "file"; +} + static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, const char *filename, int *nFiles) { @@ -809,10 +814,12 @@ static void *init_plugin (xine_t *xine, void *data) { config = xine->config; this->input_class.open_plugin = open_plugin; - this->input_class.get_dir = file_class_get_dir; + this->input_class.get_identifier = file_class_get_identifier; this->input_class.get_description = file_class_get_description; + this->input_class.get_dir = file_class_get_dir; this->input_class.get_autoplay_list = NULL; this->input_class.dispose = file_class_dispose; + this->input_class.eject_media = file_plugin_eject_media; this->mrls = (xine_mrl_t **) xine_xmalloc(sizeof(xine_mrl_t*)); this->mrls_allocated_entries = 0; diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 892fdbf8d..32fb031e0 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_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: audio_decoder.c,v 1.85 2002/10/14 15:47:23 guenter Exp $ + * $Id: audio_decoder.c,v 1.86 2002/10/18 04:04:10 miguelfreitas Exp $ * * * functions that implement audio decoding @@ -45,7 +45,6 @@ void *audio_decoder_loop (void *stream_gen) { buf_element_t *buf; xine_stream_t *stream = (xine_stream_t *) stream_gen; int running = 1; - audio_decoder_t *decoder; static int prof_audio_decode = -1; static uint32_t buftype_unknown = 0; @@ -237,23 +236,25 @@ void *audio_decoder_loop (void *stream_gen) { if (buf->type == audio_type) { int streamtype = (buf->type>>16) & 0xFF; - - decoder = get_audio_decoder (stream, streamtype); - + /* close old decoder of audio type has changed */ + + if( stream->audio_decoder_streamtype != streamtype || + !stream->audio_decoder_plugin ) { + + if (stream->audio_decoder_plugin) { + free_audio_decoder (stream, stream->audio_decoder_plugin); + } + + stream->audio_decoder_streamtype = streamtype; + stream->audio_decoder_plugin = get_audio_decoder (stream, streamtype); + } if (audio_type != stream->audio_type) { if (stream->audio_decoder_plugin) { - free_audio_decoder (stream, stream->audio_decoder_plugin); - stream->audio_decoder_plugin = NULL; - } - - if (decoder) { xine_event_t event; - stream->audio_decoder_plugin = decoder; - stream->audio_type = audio_type; event.type = XINE_EVENT_UI_CHANNELS_CHANGED; @@ -264,8 +265,8 @@ void *audio_decoder_loop (void *stream_gen) { /* finally - decode data */ - if (decoder) - decoder->decode_data (decoder, buf); + if (stream->audio_decoder_plugin) + stream->audio_decoder_plugin->decode_data (stream->audio_decoder_plugin, buf); else if( buf->type != buftype_unknown ) { xine_log (stream->xine, XINE_LOG_MSG, "audio_decoder: no plugin available to handle '%s'\n", diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 0464a9e69..7a65d26b1 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_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: video_decoder.c,v 1.100 2002/10/14 15:47:40 guenter Exp $ + * $Id: video_decoder.c,v 1.101 2002/10/18 04:04:10 miguelfreitas Exp $ * */ @@ -40,19 +40,23 @@ static spu_decoder_t* update_spu_decoder (xine_stream_t *this, int type) { int streamtype = (type>>16) & 0xFF; - spu_decoder_t *spu_decoder = get_spu_decoder (this, streamtype); - - if (spu_decoder && this->spu_decoder_plugin != spu_decoder) { - + + if( this->spu_decoder_streamtype != streamtype || + !this->spu_decoder_plugin ) { + if (this->spu_decoder_plugin) this->spu_decoder_plugin->close (this->spu_decoder_plugin); + + this->spu_decoder_streamtype = streamtype; + this->spu_decoder_plugin = get_spu_decoder (this, streamtype); - this->spu_decoder_plugin = spu_decoder; - - this->spu_decoder_plugin->init (this->spu_decoder_plugin, + /* obsolete? + if (this->spu_decoder_plugin ) + this->spu_decoder_plugin->init (this->spu_decoder_plugin, this->video_out); + */ } - return spu_decoder; + return this->spu_decoder_plugin; } void *video_decoder_loop (void *stream_gen) { @@ -61,7 +65,6 @@ void *video_decoder_loop (void *stream_gen) { xine_stream_t *stream = (xine_stream_t *) stream_gen; int running = 1; int streamtype; - video_decoder_t *decoder; spu_decoder_t *spu_decoder; static int prof_video_decode = -1; static int prof_spu_decode = -1; @@ -263,21 +266,21 @@ void *video_decoder_loop (void *stream_gen) { */ streamtype = (buf->type>>16) & 0xFF; + + if( stream->video_decoder_streamtype != streamtype || + !stream->video_decoder_plugin ) { + + if (stream->video_decoder_plugin) { + free_video_decoder (stream, stream->video_decoder_plugin); + } + + stream->video_decoder_streamtype = streamtype; + stream->video_decoder_plugin = get_video_decoder (stream, streamtype); + } - decoder = get_video_decoder (stream, streamtype); - - if (decoder) { - - if (stream->video_decoder_plugin != decoder) { - - if (stream->video_decoder_plugin) { - free_video_decoder (stream, stream->video_decoder_plugin); - } - - stream->video_decoder_plugin = decoder; - } - - decoder->decode_data (stream->video_decoder_plugin, buf); + if (stream->video_decoder_plugin) { + + stream->video_decoder_plugin->decode_data (stream->video_decoder_plugin, buf); } else if (buf->type != buftype_unknown) { xine_log (stream->xine, XINE_LOG_MSG, diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 0d3bb5d4d..847390768 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.168 2002/10/16 21:23:59 guenter Exp $ + * $Id: xine.c,v 1.169 2002/10/18 04:04:10 miguelfreitas Exp $ * * top-level xine functions * @@ -62,7 +62,8 @@ void xine_handle_stream_end (xine_stream_t *stream, int non_user) { if (stream->status == XINE_STATUS_QUIT) return; - + stream->status = XINE_STATUS_STOP; + if (non_user) { /* frontends will not be interested in receiving this event * if they have called xine_stop explicitly, so only send @@ -226,8 +227,11 @@ xine_stream_t *xine_stream_new (xine_t *this, stream->input_time = 0; stream->spu_out = NULL; stream->spu_decoder_plugin = NULL; + stream->spu_decoder_streamtype = -1; stream->audio_channel_user = -1; stream->audio_channel_auto = 0; + stream->audio_decoder_plugin = NULL; + stream->audio_decoder_streamtype = -1; stream->spu_channel_auto = -1; stream->spu_channel_letterbox = -1; stream->spu_channel_pan_scan = -1; @@ -236,6 +240,8 @@ xine_stream_t *xine_stream_new (xine_t *this, stream->video_driver = vo; stream->video_in_discontinuity = 0; stream->video_channel = 0; + stream->video_decoder_plugin = NULL; + stream->video_decoder_streamtype = -1; stream->header_count_audio = 0; stream->header_count_video = 0; stream->finished_count_audio = 0; @@ -316,7 +322,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { /* * find a demux plugin */ - if (!find_demux_plugin (stream, stream->input_plugin)) { + if (!(stream->demux_plugin=find_demux_plugin (stream, stream->input_plugin))) { xine_log (stream->xine, XINE_LOG_MSG, _("xine: couldn't find demux for >%s<\n"), mrl); stream->input_plugin->dispose (stream->input_plugin); @@ -404,6 +410,14 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t } else pos = 0; + if (!stream->demux_plugin) { + xine_log (stream->xine, XINE_LOG_MSG, + _("xine_play: no demux available\n")); + stream->err = XINE_ERROR_NO_DEMUX_PLUGIN; + + return 0; + } + if (stream->status == XINE_STATUS_STOP) { demux_status = stream->demux_plugin->start (stream->demux_plugin, @@ -422,7 +436,6 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t if (stream->status == XINE_STATUS_STOP) stream->input_plugin->dispose(stream->input_plugin); - pthread_mutex_unlock (&stream->frontend_lock); return 0; } else { diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index a07916a9e..a7d468915 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.104 2002/10/14 15:47:45 guenter Exp $ + * $Id: xine_internal.h,v 1.105 2002/10/18 04:04:10 miguelfreitas Exp $ * */ @@ -148,6 +148,7 @@ struct xine_stream_s { fifo_buffer_t *video_fifo; pthread_t video_thread; video_decoder_t *video_decoder_plugin; + int video_decoder_streamtype; int video_in_discontinuity; int video_channel; @@ -156,6 +157,7 @@ struct xine_stream_s { lrb_t *audio_temp; pthread_t audio_thread; audio_decoder_t *audio_decoder_plugin; + int audio_decoder_streamtype; uint32_t audio_track_map[50]; int audio_track_map_entries; uint32_t audio_type; @@ -169,6 +171,7 @@ struct xine_stream_s { spu_functions_t *spu_out; pthread_t spu_thread; spu_decoder_t *spu_decoder_plugin; + int spu_decoder_streamtype; int spu_channel_user; int spu_channel_auto; int spu_channel_letterbox; -- cgit v1.2.3