diff options
author | Andreas Huber <andih@google.com> | 2009-08-27 14:50:58 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2009-08-27 14:50:58 -0700 |
commit | 329577aa6d422d1dbb33f4771fc5e2949b4ad312 (patch) | |
tree | 6240bac8ea8e41ada57f30fe41f4a69f1ad97edc /media/libstagefright/OMXClient.cpp | |
parent | e18d4d01152071f3a489a0d3077ad89dfa1f3851 (diff) | |
download | frameworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.zip frameworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.tar.gz frameworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.tar.bz2 |
Squashed commit of the following:
commit 3fa5f3ce910f34da0cedb8bcce1bd593db7eb740
Author: Andreas Huber <andih@google.com>
Date: Thu Aug 27 14:48:54 2009 -0700
Getting rid of more code now obsolete with the departure of OMXDecoder.
commit e0d923ec0c7bb60bec8eb97739036a4c70c0feef
Author: Andreas Huber <andih@google.com>
Date: Thu Aug 27 14:33:06 2009 -0700
Remove obsoleted OMXDecoder class. OMXDecoder is dead, long live OMXCodec.
Diffstat (limited to 'media/libstagefright/OMXClient.cpp')
-rw-r--r-- | media/libstagefright/OMXClient.cpp | 174 |
1 files changed, 0 insertions, 174 deletions
diff --git a/media/libstagefright/OMXClient.cpp b/media/libstagefright/OMXClient.cpp index 2a32b4c..dba7a2a 100644 --- a/media/libstagefright/OMXClient.cpp +++ b/media/libstagefright/OMXClient.cpp @@ -18,11 +18,8 @@ #define LOG_TAG "OMXClient" #include <utils/Log.h> -#include <sys/socket.h> - #include <binder/IServiceManager.h> #include <media/IMediaPlayerService.h> -#include <media/IOMX.h> #include <media/stagefright/MediaDebug.h> #include <media/stagefright/OMXClient.h> @@ -31,13 +28,7 @@ namespace android { OMXClient::OMXClient() { } -OMXClient::~OMXClient() { - disconnect(); -} - status_t OMXClient::connect() { - Mutex::Autolock autoLock(mLock); - sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder = sm->getService(String16("media.player")); sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder); @@ -47,175 +38,10 @@ status_t OMXClient::connect() { mOMX = service->createOMX(); CHECK(mOMX.get() != NULL); - mReflector = new OMXClientReflector(this); - return OK; } void OMXClient::disconnect() { - Mutex::Autolock autoLock(mLock); - - if (mReflector.get() != NULL) { - return; - } - - CHECK(mObservers.isEmpty()); - - mReflector->reset(); - mReflector.clear(); -} - -status_t OMXClient::registerObserver( - IOMX::node_id node, OMXObserver *observer) { - Mutex::Autolock autoLock(&mLock); - - ssize_t index = mObservers.indexOfKey(node); - if (index >= 0) { - return UNKNOWN_ERROR; - } - - mObservers.add(node, observer); - observer->start(); - - mOMX->observe_node(node, mReflector); - - return OK; -} - -void OMXClient::unregisterObserver(IOMX::node_id node) { - Mutex::Autolock autoLock(mLock); - - ssize_t index = mObservers.indexOfKey(node); - CHECK(index >= 0); - - if (index < 0) { - return; - } - - OMXObserver *observer = mObservers.valueAt(index); - observer->stop(); - mObservers.removeItemsAt(index); -} - -bool OMXClient::onOMXMessage(const omx_message &msg) { - bool done = false; - - switch (msg.type) { - case omx_message::EVENT: - { - LOGV("OnEvent node:%p event:%d data1:%ld data2:%ld", - msg.u.event_data.node, - msg.u.event_data.event, - msg.u.event_data.data1, - msg.u.event_data.data2); - - break; - } - - case omx_message::FILL_BUFFER_DONE: - { - LOGV("FillBufferDone %p", msg.u.extended_buffer_data.buffer); - break; - } - - case omx_message::EMPTY_BUFFER_DONE: - { - LOGV("EmptyBufferDone %p", msg.u.buffer_data.buffer); - break; - } - - default: - LOGE("received unknown omx_message type %d", msg.type); - break; - } - - Mutex::Autolock autoLock(mLock); - ssize_t index = mObservers.indexOfKey(msg.node); - - if (index >= 0) { - mObservers.editValueAt(index)->postMessage(msg); - } - - return done; -} - -//////////////////////////////////////////////////////////////////////////////// - -OMXObserver::OMXObserver() { -} - -OMXObserver::~OMXObserver() { -} - -void OMXObserver::start() { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - int err = pthread_create(&mThread, &attr, ThreadWrapper, this); - CHECK_EQ(err, 0); - - pthread_attr_destroy(&attr); -} - -void OMXObserver::stop() { - omx_message msg; - msg.type = omx_message::QUIT_OBSERVER; - postMessage(msg); - - void *dummy; - pthread_join(mThread, &dummy); -} - -void OMXObserver::postMessage(const omx_message &msg) { - Mutex::Autolock autoLock(mLock); - mQueue.push_back(msg); - mQueueNotEmpty.signal(); -} - -// static -void *OMXObserver::ThreadWrapper(void *me) { - static_cast<OMXObserver *>(me)->threadEntry(); - - return NULL; -} - -void OMXObserver::threadEntry() { - for (;;) { - omx_message msg; - - { - Mutex::Autolock autoLock(mLock); - while (mQueue.empty()) { - mQueueNotEmpty.wait(mLock); - } - - msg = *mQueue.begin(); - mQueue.erase(mQueue.begin()); - } - - if (msg.type == omx_message::QUIT_OBSERVER) { - break; - } - - onOMXMessage(msg); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -OMXClientReflector::OMXClientReflector(OMXClient *client) - : mClient(client) { -} - -void OMXClientReflector::on_message(const omx_message &msg) { - if (mClient != NULL) { - mClient->onOMXMessage(msg); - } -} - -void OMXClientReflector::reset() { - mClient = NULL; } } // namespace android |