summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-03-16 20:45:21 +0000
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-03-16 20:45:21 +0000
commitf39902b9cf71081aa1701e9c7a857f1215982199 (patch)
tree6feaa160244011be6066ad7801a6b78b23afcdfb /src
parent066220e7145c94fd6751c0631374ef3b34dc983c (diff)
downloadxine-lib-f39902b9cf71081aa1701e9c7a857f1215982199.tar.gz
xine-lib-f39902b9cf71081aa1701e9c7a857f1215982199.tar.bz2
Move autodetection of Real codecs path to the common code unit, and rewrite to
a) minimise the number of stat() calls happening; b) support FreeBSD paths. CVS patchset: 8682 CVS date: 2007/03/16 20:45:21
Diffstat (limited to 'src')
-rw-r--r--src/libreal/audio_decoder.c47
-rw-r--r--src/libreal/real_common.c47
-rw-r--r--src/libreal/real_common.h4
-rw-r--r--src/libreal/xine_decoder.c47
4 files changed, 57 insertions, 88 deletions
diff --git a/src/libreal/audio_decoder.c b/src/libreal/audio_decoder.c
index ebffce31d..a6a0c551f 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.53 2007/03/16 20:02:33 dgp85 Exp $
+ * $Id: audio_decoder.c,v 1.54 2007/03/16 20:45:21 dgp85 Exp $
*
* thin layer to use real binary-only codecs in xine
*
@@ -45,6 +45,8 @@
#include "buffer.h"
#include "xineutils.h"
+#include "real_common.h"
+
typedef struct {
audio_decoder_class_t decoder_class;
@@ -618,9 +620,6 @@ 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));
@@ -629,45 +628,7 @@ 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/lib/RealPlayer10/codecs/drvc.so", &s))
- default_real_codec_path = "/usr/lib/RealPlayer10/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/lib64/RealPlayer10/codecs/drvc.so", &s))
- default_real_codec_path = "/usr/lib64/RealPlayer10/codecs";
- if (!stat ("/usr/lib/codecs/drv3.so.6.0", &s))
- default_real_codec_path = "/usr/lib/codecs";
- if (!stat ("/usr/lib/win32/drv3.so.6.0", &s))
- default_real_codec_path = "/usr/lib/win32";
-
- real_codec_path = config->register_filename (config, "decoder.external.real_codecs_path",
- default_real_codec_path,
- XINE_CONFIG_STRING_IS_DIRECTORY_NAME,
- _("path to RealPlayer codecs"),
- _("If you have RealPlayer installed, specify the path "
- "to its codec directory here. You can easily find "
- "the codec directory by looking for a file named "
- "\"drv3.so.6.0\" in it. If xine can find the RealPlayer "
- "codecs, it will use them to decode RealPlayer content "
- "for you. Consult the xine FAQ for more information on "
- "how to install the codecs."),
- 10, NULL, this);
-
- lprintf ("real codec path : %s\n", real_codec_path);
+ _x_real_codecs_init(xine);
return this;
}
diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c
index c4afcbeea..f1f47fb6b 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.2 2007/03/16 20:21:40 dgp85 Exp $
+ * $Id: real_common.c,v 1.3 2007/03/16 20:45:21 dgp85 Exp $
*
* Common function for the thin layer to use Real binary-only codecs in xine
*/
@@ -28,6 +28,8 @@
#define LOG
*/
+#include <sys/stat.h>
+
#include "real_common.h"
#ifdef __alpha__
@@ -60,3 +62,46 @@ void __pure_virtual(void) {
void ___brk_addr(void) { exit(0); }
void __ctype_b(void) { exit(0); }
#endif
+
+void _x_real_codecs_init(xine_t *const xine) {
+ const char *default_real_codecs_path = "";
+ const char *real_codecs_path = NULL;
+ struct stat s;
+
+#define try_real_path(path) \
+ if (!stat (path "/dvr3.so.6.0", &s)) \
+ default_real_codecs_path = path;
+#define try_real_subpath(path) \
+ try_real_path("/usr/" path) \
+ else try_real_path("/usr/local" path) \
+ else try_real_path("/opt" path)
+
+ /* The priority is for the first found */
+ try_real_subpath("lib/win32")
+ else try_real_subpath("lib/codecs")
+ else try_real_subpath("lib64/RealPlayer10/codecs")
+ else try_real_subpath("lib/RealPlayer10/codecs")
+ else try_real_subpath("lib64/RealPlayer9/users/Real/Codecs")
+ else try_real_subpath("lib/RealPlayer9/users/Real/Codecs")
+ else try_real_subpath("lib/RealPlayer8/Codecs")
+ else try_real_subpath("RealPlayer8/Codecs");
+
+#undef try_real_path
+#undef try_real_subpath
+
+ real_codecs_path =
+ xine->config->register_filename (xine->config, "decoder.external.real_codecs_path",
+ default_real_codecs_path,
+ XINE_CONFIG_STRING_IS_DIRECTORY_NAME,
+ _("path to RealPlayer codecs"),
+ _("If you have RealPlayer installed, specify the path "
+ "to its codec directory here. You can easily find "
+ "the codec directory by looking for a file named "
+ "\"drv3.so.6.0\" in it. If xine can find the RealPlayer "
+ "codecs, it will use them to decode RealPlayer content "
+ "for you. Consult the xine FAQ for more information on "
+ "how to install the codecs."),
+ 10, NULL, NULL);
+
+ lprintf ("real codecs path : %s\n", real_codec_path);
+}
diff --git a/src/libreal/real_common.h b/src/libreal/real_common.h
index 2d4c1dee0..717c80168 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.2 2007/03/16 20:21:40 dgp85 Exp $
+ * $Id: real_common.h,v 1.3 2007/03/16 20:45:21 dgp85 Exp $
*
* Common function for the thin layer to use Real binary-only codecs in xine
*/
@@ -54,4 +54,6 @@ void ___brk_addr(void) EXPORTED;
void __ctype_b(void) EXPORTED;
#endif
+void _x_real_codecs_init(xine_t *const xine);
+
#endif
diff --git a/src/libreal/xine_decoder.c b/src/libreal/xine_decoder.c
index 779f577e2..9cf49a2db 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.87 2007/03/16 20:02:33 dgp85 Exp $
+ * $Id: xine_decoder.c,v 1.88 2007/03/16 20:45:21 dgp85 Exp $
*
* thin layer to use real binary-only codecs in xine
*
@@ -44,6 +44,8 @@
#include "buffer.h"
#include "xineutils.h"
+#include "real_common.h"
+
typedef struct {
video_decoder_class_t decoder_class;
@@ -529,9 +531,6 @@ 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));
@@ -540,45 +539,7 @@ 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/lib/RealPlayer10/codecs/drvc.so", &s))
- default_real_codec_path = "/usr/lib/RealPlayer10/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/lib64/RealPlayer10/codecs/drvc.so", &s))
- default_real_codec_path = "/usr/lib64/RealPlayer10/codecs";
- if (!stat ("/usr/lib/codecs/drv3.so.6.0", &s))
- default_real_codec_path = "/usr/lib/codecs";
- if (!stat ("/usr/lib/win32/drv3.so.6.0", &s))
- default_real_codec_path = "/usr/lib/win32";
-
- real_codec_path = config->register_filename (config, "decoder.external.real_codecs_path",
- default_real_codec_path,
- XINE_CONFIG_STRING_IS_DIRECTORY_NAME,
- _("path to RealPlayer codecs"),
- _("If you have RealPlayer installed, specify the path "
- "to its codec directory here. You can easily find "
- "the codec directory by looking for a file named "
- "\"drv3.so.6.0\" in it. If xine can find the RealPlayer "
- "codecs, it will use them to decode RealPlayer content "
- "for you. Consult the xine FAQ for more information on "
- "how to install the codecs."),
- 10, NULL, this);
-
- lprintf ("real codec path : %s\n", real_codec_path);
+ _x_real_codecs_init();
return this;
}