diff options
author | Andreas Huber <andih@google.com> | 2010-02-22 11:24:01 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-02-22 15:41:07 -0800 |
commit | 078f7f05d53ba8e92f4a72992edab732125af79f (patch) | |
tree | d491e31671a1a4feebe83817b0b0901d200ae54d /media/libstagefright/omx | |
parent | ab9985ed4c02ef70d4a48bf3bbeedc12d14928f3 (diff) | |
download | frameworks_base-078f7f05d53ba8e92f4a72992edab732125af79f.zip frameworks_base-078f7f05d53ba8e92f4a72992edab732125af79f.tar.gz frameworks_base-078f7f05d53ba8e92f4a72992edab732125af79f.tar.bz2 |
Properly unload the renderer shared library after the renderer goes away.
Diffstat (limited to 'media/libstagefright/omx')
-rw-r--r-- | media/libstagefright/omx/OMX.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp index 9ca060d..ff8757d 100644 --- a/media/libstagefright/omx/OMX.cpp +++ b/media/libstagefright/omx/OMX.cpp @@ -401,6 +401,33 @@ void OMX::invalidateNodeID_l(node_id node) { //////////////////////////////////////////////////////////////////////////////// +struct SharedVideoRenderer : public VideoRenderer { + SharedVideoRenderer(void *libHandle, VideoRenderer *obj) + : mLibHandle(libHandle), + mObj(obj) { + } + + virtual ~SharedVideoRenderer() { + delete mObj; + mObj = NULL; + + dlclose(mLibHandle); + mLibHandle = NULL; + } + + virtual void render( + const void *data, size_t size, void *platformPrivate) { + return mObj->render(data, size, platformPrivate); + } + +private: + void *mLibHandle; + VideoRenderer *mObj; + + SharedVideoRenderer(const SharedVideoRenderer &); + SharedVideoRenderer &operator=(const SharedVideoRenderer &); +}; + sp<IOMXRenderer> OMX::createRenderer( const sp<ISurface> &surface, const char *componentName, @@ -411,11 +438,7 @@ sp<IOMXRenderer> OMX::createRenderer( VideoRenderer *impl = NULL; - static void *libHandle = NULL; - - if (!libHandle) { - libHandle = dlopen("libstagefrighthw.so", RTLD_NOW); - } + void *libHandle = dlopen("libstagefrighthw.so", RTLD_NOW); if (libHandle) { typedef VideoRenderer *(*CreateRendererFunc)( @@ -434,6 +457,16 @@ sp<IOMXRenderer> OMX::createRenderer( if (func) { impl = (*func)(surface, componentName, colorFormat, displayWidth, displayHeight, encodedWidth, encodedHeight); + + if (impl) { + impl = new SharedVideoRenderer(libHandle, impl); + libHandle = NULL; + } + } + + if (libHandle) { + dlclose(libHandle); + libHandle = NULL; } } |