Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: media/base/media_posix.cc

Issue 6537022: Move media library path resolution into Chrome path provider. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Get rid of spurious changes in previous patch-set. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/media.h ('k') | media/base/media_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/media.h" 5 #include "media/base/media.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 case tp_ffmpeg::kModuleAvformat52: 59 case tp_ffmpeg::kModuleAvformat52:
60 return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION)); 60 return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION));
61 case tp_ffmpeg::kModuleAvutil50: 61 case tp_ffmpeg::kModuleAvutil50:
62 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION)); 62 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION));
63 default: 63 default:
64 LOG(DFATAL) << "Invalid stub module requested: " << stub_key; 64 LOG(DFATAL) << "Invalid stub module requested: " << stub_key;
65 return FILE_PATH_LITERAL(""); 65 return FILE_PATH_LITERAL("");
66 } 66 }
67 } 67 }
68 68
69 static bool g_media_library_is_initialized = false;
70
69 // Attempts to initialize the media library (loading DSOs, etc.). 71 // Attempts to initialize the media library (loading DSOs, etc.).
70 // Returns true if everything was successfully initialized, false otherwise. 72 // Returns true if everything was successfully initialized, false otherwise.
71 bool InitializeMediaLibrary(const FilePath& module_dir) { 73 bool InitializeMediaLibrary(const FilePath& module_dir) {
74 if (g_media_library_is_initialized)
75 return true;
76
72 // TODO(ajwong): We need error resolution. 77 // TODO(ajwong): We need error resolution.
73 tp_ffmpeg::StubPathMap paths; 78 tp_ffmpeg::StubPathMap paths;
74 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) { 79 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) {
75 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i); 80 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i);
76 81
77 // Add the sumo library first so it takes precedence. 82 // Add the sumo library first so it takes precedence.
78 paths[module].push_back(module_dir.Append(sumo_name).value()); 83 paths[module].push_back(module_dir.Append(sumo_name).value());
79 84
80 // Add the more specific FFmpeg library name. 85 // Add the more specific FFmpeg library name.
81 FilePath path = module_dir.Append(GetDSOName(module)); 86 FilePath path = module_dir.Append(GetDSOName(module));
82 paths[module].push_back(path.value()); 87 paths[module].push_back(path.value());
83 } 88 }
84 89
85 bool ret = tp_ffmpeg::InitializeStubs(paths); 90 g_media_library_is_initialized = tp_ffmpeg::InitializeStubs(paths);
86 return ret; 91 return g_media_library_is_initialized;
92 }
93
94 bool IsMediaLibraryInitialized() {
95 return g_media_library_is_initialized;
87 } 96 }
88 97
89 #if defined(OS_LINUX) 98 #if defined(OS_LINUX)
90 namespace tp_openmax = third_party_openmax; 99 namespace tp_openmax = third_party_openmax;
91 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { 100 bool InitializeOpenMaxLibrary(const FilePath& module_dir) {
92 // TODO(ajwong): We need error resolution. 101 // TODO(ajwong): We need error resolution.
93 tp_openmax::StubPathMap paths; 102 tp_openmax::StubPathMap paths;
94 for (int i = 0; i < static_cast<int>(tp_openmax::kNumStubModules); ++i) { 103 for (int i = 0; i < static_cast<int>(tp_openmax::kNumStubModules); ++i) {
95 tp_openmax::StubModules module = static_cast<tp_openmax::StubModules>(i); 104 tp_openmax::StubModules module = static_cast<tp_openmax::StubModules>(i);
96 105
97 // Add the OpenMAX library first so it takes precedence. 106 // Add the OpenMAX library first so it takes precedence.
98 paths[module].push_back(module_dir.Append(openmax_name).value()); 107 paths[module].push_back(module_dir.Append(openmax_name).value());
99 } 108 }
100 109
101 bool result = tp_openmax::InitializeStubs(paths); 110 bool result = tp_openmax::InitializeStubs(paths);
102 if (!result) { 111 if (!result) {
103 LOG(FATAL) << "Cannot load " << openmax_name << "." 112 LOG(FATAL) << "Cannot load " << openmax_name << "."
104 << " Make sure it exists for OpenMAX."; 113 << " Make sure it exists for OpenMAX.";
105 } 114 }
106 return result; 115 return result;
107 } 116 }
108 #else 117 #else
109 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { 118 bool InitializeOpenMaxLibrary(const FilePath& module_dir) {
110 NOTIMPLEMENTED() << "OpenMAX is only used in Linux."; 119 NOTIMPLEMENTED() << "OpenMAX is only used in Linux.";
111 return false; 120 return false;
112 } 121 }
113 #endif 122 #endif
114 123
115 } // namespace media 124 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media.h ('k') | media/base/media_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698