From 92e7af754617240646c35482f62a34603e6c50e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 16 Mar 2007 21:37:58 +0000 Subject: Move the wrapper to open the real codecs in the common unit, and assume that the alternative name is always the same with .6.0 at the end. Prefer the full name to the reduced one. CVS patchset: 8683 CVS date: 2007/03/16 21:37:58 --- src/libreal/audio_decoder.c | 41 +++++++++++++---------------------------- src/libreal/real_common.c | 37 ++++++++++++++++++++++++++++++++++++- src/libreal/real_common.h | 4 +++- src/libreal/xine_decoder.c | 37 +++++++++++-------------------------- 4 files changed, 63 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/libreal/audio_decoder.c b/src/libreal/audio_decoder.c index a6a0c551f..b2e000a3a 100644 --- a/src/libreal/audio_decoder.c +++ b/src/libreal/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.54 2007/03/16 20:45:21 dgp85 Exp $ + * $Id: audio_decoder.c,v 1.55 2007/03/16 21:37:58 dgp85 Exp $ * * thin layer to use real binary-only codecs in xine * @@ -104,29 +104,14 @@ typedef struct { void *extras; } ra_init_t; -static int load_syms_linux (realdec_decoder_t *this, char *codec_name, - const char *alt_codec_name) { +static int load_syms_linux (realdec_decoder_t *this, const char *codec_name) { + cfg_entry_t* entry = + this->stream->xine->config->lookup_entry(this->stream->xine->config, + "decoder.external.real_codecs_path"); - cfg_entry_t* entry = this->stream->xine->config->lookup_entry( - this->stream->xine->config, "decoder.external.real_codecs_path"); - char path[1024]; - struct stat sb; - - snprintf (path, sizeof(path), "%s/%s", entry->str_value, codec_name); - if (stat(path, &sb)) - snprintf (path, sizeof(path), "%s/%s", entry->str_value, alt_codec_name); - - lprintf ("(audio) opening shared obj '%s'\n", path); - - this->ra_handle = dlopen (path, RTLD_LAZY); - - if (!this->ra_handle) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libareal: error: %s\n", dlerror()); - _x_message(this->stream, XINE_MSG_LIBRARY_LOAD_ERROR, - codec_name, NULL); + if ( (this->ra_handle = _x_real_codec_open(this->stream, entry->str_value, codec_name)) == NULL ) return 0; - } - + this->raCloseCodec = dlsym (this->ra_handle, "RACloseCodec"); this->raDecode = dlsym (this->ra_handle, "RADecode"); this->raFlush = dlsym (this->ra_handle, "RAFlush"); @@ -142,7 +127,7 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name, !this->raGetFlavorProperty || !this->raOpenCodec2 || !this->raSetFlavor || /*!raSetDLLAccessPath ||*/ !this->raInitDecoder){ xprintf (this->stream->xine, XINE_VERBOSITY_LOG, - _("libareal: (audio) Cannot resolve symbols - incompatible dll: %s\n"), path); + _("libareal: (audio) Cannot resolve symbols - incompatible dll: %s\n"), codec_name); return 0; } @@ -231,32 +216,32 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { switch (buf->type) { case BUF_AUDIO_COOK: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Cook"); - if (!load_syms_linux (this, "cook.so", "cook.so.6.0")) + if (!load_syms_linux (this, "cook.so")) return 0; break; case BUF_AUDIO_ATRK: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Atrac"); - if (!load_syms_linux (this, "atrc.so", "atrc.so.6.0")) + if (!load_syms_linux (this, "atrc.so")) return 0; this->block_align = 384; break; case BUF_AUDIO_14_4: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Real 14.4"); - if (!load_syms_linux (this, "14_4.so", "14_4.so.6.0")) + if (!load_syms_linux (this, "14_4.so")) return 0; break; case BUF_AUDIO_28_8: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Real 28.8"); - if (!load_syms_linux (this, "28_8.so", "28_8.so.6.0")) + if (!load_syms_linux (this, "28_8.so")) return 0; break; case BUF_AUDIO_SIPRO: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Sipro"); - if (!load_syms_linux (this, "sipr.so", "sipr.so.6.0")) + if (!load_syms_linux (this, "sipr.so")) return 0; /* this->block_align = 19; */ break; diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c index f1f47fb6b..d2fccd28d 100644 --- a/src/libreal/real_common.c +++ b/src/libreal/real_common.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: real_common.c,v 1.3 2007/03/16 20:45:21 dgp85 Exp $ + * $Id: real_common.c,v 1.4 2007/03/16 21:37:58 dgp85 Exp $ * * Common function for the thin layer to use Real binary-only codecs in xine */ @@ -28,7 +28,11 @@ #define LOG */ +#include "config.h" + #include +#include +#include #include "real_common.h" @@ -105,3 +109,34 @@ void _x_real_codecs_init(xine_t *const xine) { lprintf ("real codecs path : %s\n", real_codec_path); } + +void *_x_real_codec_open(xine_stream_t *const stream, const char *const path, + const char *const codec_name) { + char *codecpath = NULL; + void *codecmodule = NULL; + + asprintf(&codecpath, "%s/%s.6.0", path, codec_name); + if ( (codecmodule = dlopen(codecpath, RTLD_NOW)) ) { + free(codecpath); + return codecmodule; + } + + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + LOG_MODULE ": error loading %s: %s\n", codecpath, dlerror()); + + free(codecpath); + asprintf(&codecpath, "%s/%s", path, codec_name); + if ( (codecmodule = dlopen(codecpath, RTLD_NOW)) ) { + free(codecpath); + return codecmodule; + } + + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + LOG_MODULE ": error loading %s: %s\n", codecpath, dlerror()); + + free(codecpath); + + _x_message(stream, XINE_MSG_LIBRARY_LOAD_ERROR, codec_name, NULL); + + return NULL; +} diff --git a/src/libreal/real_common.h b/src/libreal/real_common.h index 717c80168..fd27ce5cf 100644 --- a/src/libreal/real_common.h +++ b/src/libreal/real_common.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: real_common.h,v 1.3 2007/03/16 20:45:21 dgp85 Exp $ + * $Id: real_common.h,v 1.4 2007/03/16 21:37:58 dgp85 Exp $ * * Common function for the thin layer to use Real binary-only codecs in xine */ @@ -55,5 +55,7 @@ void __ctype_b(void) EXPORTED; #endif void _x_real_codecs_init(xine_t *const xine); +void *_x_real_codec_open(xine_stream_t *const stream, const char *const path, + const char *const codec_name); #endif diff --git a/src/libreal/xine_decoder.c b/src/libreal/xine_decoder.c index 9cf49a2db..b08222a9a 100644 --- a/src/libreal/xine_decoder.c +++ b/src/libreal/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.88 2007/03/16 20:45:21 dgp85 Exp $ + * $Id: xine_decoder.c,v 1.89 2007/03/16 21:37:58 dgp85 Exp $ * * thin layer to use real binary-only codecs in xine * @@ -109,29 +109,14 @@ void __pure_virtual(void); * real codec loader */ -static int load_syms_linux (realdec_decoder_t *this, char *codec_name, - const char *alt_codec_name) { +static int load_syms_linux (realdec_decoder_t *this, const char *codec_name) { + cfg_entry_t* entry = + this->stream->xine->config->lookup_entry(this->stream->xine->config, + "decoder.external.real_codecs_path"); - cfg_entry_t* entry = this->stream->xine->config->lookup_entry( - this->stream->xine->config, "decoder.external.real_codecs_path"); - char path[1024]; - struct stat sb; - - snprintf (path, sizeof(path), "%s/%s", entry->str_value, codec_name); - if (stat(path, &sb)) - snprintf (path, sizeof(path), "%s/%s", entry->str_value, alt_codec_name); - - lprintf ("opening shared obj '%s'\n", path); - - this->rv_handle = dlopen (path, RTLD_LAZY); - - if (!this->rv_handle) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libreal: error: %s\n", dlerror()); - _x_message(this->stream, XINE_MSG_LIBRARY_LOAD_ERROR, - codec_name, NULL); + if ( (this->rv_handle = _x_real_codec_open(this->stream, entry->str_value, codec_name)) == NULL ) return 0; - } - + this->rvyuv_custom_message = dlsym (this->rv_handle, "RV20toYUV420CustomMessage"); this->rvyuv_free = dlsym (this->rv_handle, "RV20toYUV420Free"); this->rvyuv_hive_message = dlsym (this->rv_handle, "RV20toYUV420HiveMessage"); @@ -173,17 +158,17 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { switch (buf->type) { case BUF_VIDEO_RV20: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Real Video 2.0"); - if (!load_syms_linux (this, "drv2.so", "drv2.so.6.0")) + if (!load_syms_linux (this, "drv2.so")) return 0; break; case BUF_VIDEO_RV30: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Real Video 3.0"); - if (!load_syms_linux (this, "drvc.so", "drv3.so.6.0")) + if (!load_syms_linux (this, "drvc.so")) return 0; break; case BUF_VIDEO_RV40: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Real Video 4.0"); - if (!load_syms_linux(this, "drvc.so", "drv4.so.6.0")) + if (!load_syms_linux(this, "drvc.so")) return 0; break; default: @@ -539,7 +524,7 @@ static void *init_class (xine_t *xine, void *data) { this->decoder_class.get_description = get_description; this->decoder_class.dispose = dispose_class; - _x_real_codecs_init(); + _x_real_codecs_init(xine); return this; } -- cgit v1.2.3