| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H | 11 #ifndef WEBRTC_AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H |
| 12 #define WEBRTC_AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H | 12 #define WEBRTC_AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H |
| 13 | 13 |
| 14 #include <assert.h> | 14 #include <assert.h> |
| 15 #include <stddef.h> // for NULL | 15 #include <stddef.h> // for NULL |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 | 17 |
| 18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
| 19 #include "webrtc/system_wrappers/include/trace.h" | |
| 20 | 19 |
| 21 // This file provides macros for creating "symbol table" classes to simplify the | 20 // This file provides macros for creating "symbol table" classes to simplify the |
| 22 // dynamic loading of symbols from DLLs. Currently the implementation only | 21 // dynamic loading of symbols from DLLs. Currently the implementation only |
| 23 // supports Linux and pure C symbols. | 22 // supports Linux and pure C symbols. |
| 24 // See talk/sound/pulseaudiosymboltable.(h|cc) for an example. | 23 // See talk/sound/pulseaudiosymboltable.(h|cc) for an example. |
| 25 | 24 |
| 26 namespace webrtc_adm_linux { | 25 namespace webrtc_adm_linux { |
| 27 | 26 |
| 28 #ifdef WEBRTC_LINUX | 27 #ifdef WEBRTC_LINUX |
| 29 typedef void *DllHandle; | 28 typedef void *DllHandle; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 73 |
| 75 // Loads the DLL and the symbol table. Returns true iff the DLL and symbol | 74 // Loads the DLL and the symbol table. Returns true iff the DLL and symbol |
| 76 // table loaded successfully. | 75 // table loaded successfully. |
| 77 bool Load() { | 76 bool Load() { |
| 78 if (IsLoaded()) { | 77 if (IsLoaded()) { |
| 79 return true; | 78 return true; |
| 80 } | 79 } |
| 81 if (undefined_symbols_) { | 80 if (undefined_symbols_) { |
| 82 // We do not attempt to load again because repeated attempts are not | 81 // We do not attempt to load again because repeated attempts are not |
| 83 // likely to succeed and DLL loading is costly. | 82 // likely to succeed and DLL loading is costly. |
| 84 //WEBRTC_TRACE(kTraceError, kTraceAudioDevice, -1, | |
| 85 // "We know there are undefined symbols"); | |
| 86 return false; | 83 return false; |
| 87 } | 84 } |
| 88 handle_ = InternalLoadDll(kDllName); | 85 handle_ = InternalLoadDll(kDllName); |
| 89 if (!IsLoaded()) { | 86 if (!IsLoaded()) { |
| 90 return false; | 87 return false; |
| 91 } | 88 } |
| 92 if (!InternalLoadSymbols(handle_, NumSymbols(), kSymbolNames, symbols_)) { | 89 if (!InternalLoadSymbols(handle_, NumSymbols(), kSymbolNames, symbols_)) { |
| 93 undefined_symbols_ = true; | 90 undefined_symbols_ = true; |
| 94 Unload(); | 91 Unload(); |
| 95 return false; | 92 return false; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 (ClassName##_SYMBOL_TABLE_INDEX_##sym) | 166 (ClassName##_SYMBOL_TABLE_INDEX_##sym) |
| 170 | 167 |
| 171 // Returns a reference to the given late-binded symbol, with the correct type. | 168 // Returns a reference to the given late-binded symbol, with the correct type. |
| 172 #define LATESYM_GET(ClassName, inst, sym) \ | 169 #define LATESYM_GET(ClassName, inst, sym) \ |
| 173 (*reinterpret_cast<typeof(&sym)>( \ | 170 (*reinterpret_cast<typeof(&sym)>( \ |
| 174 (inst)->GetSymbol(LATESYM_INDEXOF(ClassName, sym)))) | 171 (inst)->GetSymbol(LATESYM_INDEXOF(ClassName, sym)))) |
| 175 | 172 |
| 176 } // namespace webrtc_adm_linux | 173 } // namespace webrtc_adm_linux |
| 177 | 174 |
| 178 #endif // WEBRTC_ADM_LATEBINDINGSYMBOLTABLE_LINUX_H | 175 #endif // WEBRTC_ADM_LATEBINDINGSYMBOLTABLE_LINUX_H |
| OLD | NEW |