File: 0001-Fallback-on-different-registry-location-except-for.patch

package info (click to toggle)
libomxil-bellagio 0.9.3-8
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 3,848 kB
  • sloc: ansic: 14,251; sh: 10,279; makefile: 212
file content (126 lines) | stat: -rw-r--r-- 4,485 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From: =?utf-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
Date: Wed, 25 Jun 2008 20:20:53 +0300
Subject: [PATCH] Fallback on different registry location (except for OMX_BELLAGIO_REGISTRY)
Index: libomxil-bellagio/src/common.c
===================================================================
--- libomxil-bellagio.orig/src/common.c	2011-06-02 11:27:40.758388019 +0800
+++ libomxil-bellagio/src/common.c	2011-06-02 11:27:59.818030905 +0800
@@ -33,6 +33,7 @@
 #include "common.h"
 
 #define REGISTRY_FILENAME ".omxregister"
+#define REGISTRY_DIR "/var/lib/libomxil-bellagio0/"
 
 #ifdef ANDROID_COMPILATION
 #define TMP_DATA_DIRECTORY "/data/omx/"
@@ -43,14 +44,27 @@
 /** @brief Get registry filename
  * This function returns the name of the registry file for the components loaded with the default component loader.
  */
-char* componentsRegistryGetFilename() {
+char* componentsRegistryGetFilename(void) {
+  return componentsRegistryGetFilenameCheck(0);
+}
+
+char* componentsRegistryGetFilenameCheck(int check_exists) {
   char *omxregistryfile = NULL;
   char *buffer;
+  struct stat sb;
 
   buffer=getenv("OMX_BELLAGIO_REGISTRY");
   if(buffer!=NULL&&*buffer!='\0') {
     omxregistryfile = strdup(buffer);
-    return omxregistryfile;
+    if (!check_exists||stat(omxregistryfile, &sb) == 0) {
+      return omxregistryfile;
+    } else {
+      if (omxregistryfile) {
+	free(omxregistryfile);
+	omxregistryfile=NULL;
+      }
+    }
+    return NULL;
   }
 
   buffer=getenv("XDG_DATA_HOME");
@@ -59,7 +73,14 @@
     strcpy(omxregistryfile, buffer);
     strcat(omxregistryfile, "/");
     strcat(omxregistryfile, REGISTRY_FILENAME);
-    return omxregistryfile;
+    if (!check_exists||stat(omxregistryfile, &sb) == 0) {
+      return omxregistryfile;
+    } else {
+      if (omxregistryfile) {
+	free(omxregistryfile);
+	omxregistryfile=NULL;
+      }
+    }
   }
 
   buffer=getenv("HOME");
@@ -73,6 +94,17 @@
     strcpy(omxregistryfile, TMP_DATA_DIRECTORY);
     strcat(omxregistryfile, REGISTRY_FILENAME);
   }
+  if (!check_exists||stat(omxregistryfile, &sb) == 0) {
+    return omxregistryfile;
+  } else {
+    if (omxregistryfile) {
+      free(omxregistryfile);
+      omxregistryfile=NULL;
+    }
+  }
+  omxregistryfile = malloc(strlen(REGISTRY_DIR) + strlen("registry") + 2);
+  strcpy(omxregistryfile, REGISTRY_DIR);
+  strcat(omxregistryfile, "registry");
   return omxregistryfile;
 }
 
@@ -171,7 +203,7 @@
 
 #ifdef COMMON_TEST
 int main (int argc, char*argv[]) {
-  printf (componentsRegistryGetFilename ());
+  printf (componentsRegistryGetFilename (1));
 }
 #endif
 
Index: libomxil-bellagio/src/common.h
===================================================================
--- libomxil-bellagio.orig/src/common.h	2011-06-02 11:27:40.758388019 +0800
+++ libomxil-bellagio/src/common.h	2011-06-02 11:27:59.818030905 +0800
@@ -32,6 +32,7 @@
 int makedir(const char *newdir);
 
 char *componentsRegistryGetFilename(void);
+char *componentsRegistryGetFilenameCheck(int check_exists);
 char* loadersRegistryGetFilename(char* registry_name);
 int exists(const char* fname);
 
Index: libomxil-bellagio/src/core_extensions/OMXCoreRMExt.c
===================================================================
--- libomxil-bellagio.orig/src/core_extensions/OMXCoreRMExt.c	2011-06-02 11:27:40.762387944 +0800
+++ libomxil-bellagio/src/core_extensions/OMXCoreRMExt.c	2011-06-02 11:27:59.818030905 +0800
@@ -161,7 +161,7 @@
 	DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
 	qualityList = NULL;
 
-	registry_filename = componentsRegistryGetFilename();
+	registry_filename = componentsRegistryGetFilenameCheck(1);
 	omxregistryfp = fopen(registry_filename, "r");
 	if (omxregistryfp == NULL){
 		DEBUG(DEB_LEV_ERR, "Cannot open OpenMAX registry file %s\n", registry_filename);
Index: libomxil-bellagio/src/st_static_component_loader.c
===================================================================
--- libomxil-bellagio.orig/src/st_static_component_loader.c	2011-06-02 11:27:40.762387944 +0800
+++ libomxil-bellagio/src/st_static_component_loader.c	2011-06-02 11:27:59.818030905 +0800
@@ -88,7 +88,7 @@
 
   DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
 
-  registry_filename = componentsRegistryGetFilename();
+  registry_filename = componentsRegistryGetFilenameCheck(1);
   omxregistryfp = fopen(registry_filename, "r");
   if (omxregistryfp == NULL){
     DEBUG(DEB_LEV_ERR, "Cannot open OpenMAX registry file %s\n", registry_filename);