summaryrefslogtreecommitdiff
path: root/src/libreal/audio_decoder.c
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2004-12-08 17:10:29 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2004-12-08 17:10:29 +0000
commit7c68209592b556679dc9400aa7e580ea645d7fa3 (patch)
tree8904b31ca0e4db8413d8c22a4cefe29356f7ae1e /src/libreal/audio_decoder.c
parentb836efe6f75ec4edfa3749fa363b870064e7d77c (diff)
downloadxine-lib-7c68209592b556679dc9400aa7e580ea645d7fa3.tar.gz
xine-lib-7c68209592b556679dc9400aa7e580ea645d7fa3.tar.bz2
- patch from mandrake folks to use realplayer libraries on amd64
- use autodetected path as config's default. this way, user can safely move or update the real stuff without having to play with config entries. CVS patchset: 7203 CVS date: 2004/12/08 17:10:29
Diffstat (limited to 'src/libreal/audio_decoder.c')
-rw-r--r--src/libreal/audio_decoder.c103
1 files changed, 75 insertions, 28 deletions
diff --git a/src/libreal/audio_decoder.c b/src/libreal/audio_decoder.c
index d37689a49..f22eea71e 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.40 2004/09/21 14:23:20 hadess Exp $
+ * $Id: audio_decoder.c,v 1.41 2004/12/08 17:10:29 miguelfreitas Exp $
*
* thin layer to use real binary-only codecs in xine
*
@@ -32,6 +32,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <dlfcn.h>
+#ifdef __x86_64__
+ #include <elf.h>
+#endif
#define LOG_MODULE "real_audio_decoder"
#define LOG_VERBOSE
@@ -118,6 +121,49 @@ void __builtin_delete (void *foo) {
free (foo);
}
+#ifdef __x86_64__
+/* (gb) quick-n-dirty check to be run natively */
+static int is_x86_64_object_(FILE *f)
+{
+ Elf64_Ehdr *hdr = malloc(sizeof(Elf64_Ehdr));
+ if (hdr == NULL)
+ return 0;
+
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ free(hdr);
+ return 0;
+ }
+
+ if (fread(hdr, sizeof(Elf64_Ehdr), 1, f) != 1) {
+ free(hdr);
+ return 0;
+ }
+
+ if (hdr->e_ident[EI_MAG0] != ELFMAG0 ||
+ hdr->e_ident[EI_MAG1] != ELFMAG1 ||
+ hdr->e_ident[EI_MAG2] != ELFMAG2 ||
+ hdr->e_ident[EI_MAG3] != ELFMAG3) {
+ free(hdr);
+ return 0;
+ }
+
+ return hdr->e_machine == EM_X86_64;
+}
+
+static inline int is_x86_64_object(const char *filename)
+{
+ FILE *f;
+ int ret;
+
+ if ((f = fopen(filename, "r")) == NULL)
+ return 0;
+
+ ret = is_x86_64_object_(f);
+ fclose(f);
+ return ret;
+}
+#endif
+
static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
cfg_entry_t* entry = this->stream->xine->config->lookup_entry(
@@ -126,6 +172,12 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
snprintf (path, sizeof(path), "%s/%s", entry->str_value, codec_name);
+#ifdef __x86_64__
+ /* check whether it's a real x86-64 library */
+ if (!is_x86_64_object(path))
+ return 0;
+#endif
+
lprintf ("(audio) opening shared obj '%s'\n", path);
this->ra_handle = dlopen (path, RTLD_LAZY);
@@ -645,6 +697,8 @@ static void *init_class (xine_t *xine, void *data) {
real_class_t *this;
config_values_t *config = xine->config;
char *real_codec_path;
+ char *default_real_codec_path = "";
+ struct stat s;
this = (real_class_t *) xine_xmalloc (sizeof (real_class_t));
@@ -653,8 +707,27 @@ static void *init_class (xine_t *xine, void *data) {
this->decoder_class.get_description = get_description;
this->decoder_class.dispose = dispose_class;
+ /* try some auto-detection */
+
+ if (!stat ("/usr/local/RealPlayer8/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/local/RealPlayer8/Codecs";
+ if (!stat ("/usr/RealPlayer8/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/RealPlayer8/Codecs";
+ if (!stat ("/usr/lib/RealPlayer8/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/lib/RealPlayer8/Codecs";
+ if (!stat ("/opt/RealPlayer8/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/opt/RealPlayer8/Codecs";
+ if (!stat ("/usr/lib/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/lib/RealPlayer9/users/Real/Codecs";
+ if (!stat ("/usr/lib64/RealPlayer8/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/lib64/RealPlayer8/Codecs";
+ if (!stat ("/usr/lib64/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/lib64/RealPlayer9/users/Real/Codecs";
+ if (!stat ("/usr/lib/win32/drv3.so.6.0", &s))
+ default_real_codec_path = "/usr/lib/win32";
+
real_codec_path = config->register_string (config, "codec.real_codecs_path",
- "unknown",
+ default_real_codec_path,
_("path to RealPlayer codecs"),
_("If you have RealPlayer installed, specify the path "
"to its codec directory here. You can easily find "
@@ -665,32 +738,6 @@ static void *init_class (xine_t *xine, void *data) {
"how to install the codecs."),
10, NULL, this);
- if (!strcmp (real_codec_path, "unknown")) {
-
- struct stat s;
-
- /* try some auto-detection */
-
- if (!stat ("/usr/local/RealPlayer8/Codecs/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/usr/local/RealPlayer8/Codecs");
- if (!stat ("/usr/RealPlayer8/Codecs/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/usr/RealPlayer8/Codecs");
- if (!stat ("/usr/lib/RealPlayer8/Codecs/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/usr/lib/RealPlayer8/Codecs");
- if (!stat ("/opt/RealPlayer8/Codecs/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/opt/RealPlayer8/Codecs");
- if (!stat ("/usr/lib/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/usr/lib/RealPlayer9/users/Real/Codecs");
- if (!stat ("/usr/lib/win32/drv3.so.6.0", &s))
- config->update_string (config, "codec.real_codecs_path",
- "/usr/lib/win32");
- }
-
lprintf ("real codec path : %s\n", real_codec_path);
return this;