summaryrefslogtreecommitdiff
path: root/cas/1.1/default/SharedLibrary.cpp
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2019-02-05 23:29:57 -0800
committerSteven Moreland <smoreland@google.com>2019-02-06 19:31:20 +0000
commit1c5b5d75ceeeae9b4902bd62d2907a0b40d22f26 (patch)
tree6a542cdf2e2e37f83041151f2d2de9046e58eabf /cas/1.1/default/SharedLibrary.cpp
parent44c873c6ea9ddae6188f5925dbc25958edd962c1 (diff)
parent7dc0a011c2f9fa7221003b2b6859299e88405713 (diff)
Merge QP1A.190205.002
Change-Id: I00eea204467afb5984b2dbcc87d8e8ff82aac307
Diffstat (limited to 'cas/1.1/default/SharedLibrary.cpp')
-rw-r--r--cas/1.1/default/SharedLibrary.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/cas/1.1/default/SharedLibrary.cpp b/cas/1.1/default/SharedLibrary.cpp
new file mode 100644
index 0000000000..ffe4bb977a
--- /dev/null
+++ b/cas/1.1/default/SharedLibrary.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "android.hardware.cas@1.1-SharedLibrary"
+
+#include "SharedLibrary.h"
+#include <dlfcn.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <utils/Log.h>
+
+namespace android {
+namespace hardware {
+namespace cas {
+namespace V1_1 {
+namespace implementation {
+
+SharedLibrary::SharedLibrary(const String8& path) {
+ mLibHandle = dlopen(path.string(), RTLD_NOW);
+}
+
+SharedLibrary::~SharedLibrary() {
+ if (mLibHandle != NULL) {
+ dlclose(mLibHandle);
+ mLibHandle = NULL;
+ }
+}
+
+bool SharedLibrary::operator!() const {
+ return mLibHandle == NULL;
+}
+
+void* SharedLibrary::lookup(const char* symbol) const {
+ if (!mLibHandle) {
+ return NULL;
+ }
+ // Clear last error before we load the symbol again,
+ // in case the caller didn't retrieve it.
+ (void)dlerror();
+ return dlsym(mLibHandle, symbol);
+}
+
+const char* SharedLibrary::lastError() const {
+ const char* error = dlerror();
+ return error ? error : "No errors or unknown error";
+}
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace cas
+} // namespace hardware
+} // namespace android