am df992ac9: Merge "ALoopers can now be named (useful to distinguish threads)." into gingerbread

Merge commit 'df992ac9cc54cedb3e384617ed683a2d1a24d38b' into gingerbread-plus-aosp

* commit 'df992ac9cc54cedb3e384617ed683a2d1a24d38b':
  ALoopers can now be named (useful to distinguish threads).
This commit is contained in:
Andreas Huber
2010-08-30 12:33:08 -07:00
committed by Android Git Automerger
6 changed files with 19 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#define A_LOOPER_H_ #define A_LOOPER_H_
#include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AString.h>
#include <utils/Errors.h> #include <utils/Errors.h>
#include <utils/KeyedVector.h> #include <utils/KeyedVector.h>
#include <utils/List.h> #include <utils/List.h>
@ -36,6 +37,9 @@ struct ALooper : public RefBase {
ALooper(); ALooper();
// Takes effect in a subsequent call to start().
void setName(const char *name);
handler_id registerHandler(const sp<AHandler> &handler); handler_id registerHandler(const sp<AHandler> &handler);
void unregisterHandler(handler_id handlerID); void unregisterHandler(handler_id handlerID);
@ -63,6 +67,8 @@ private:
Mutex mLock; Mutex mLock;
Condition mQueueChangedCondition; Condition mQueueChangedCondition;
AString mName;
List<Event> mEventQueue; List<Event> mEventQueue;
struct LooperThread; struct LooperThread;

View File

@ -1241,6 +1241,7 @@ status_t AwesomePlayer::finishSetDataSource_l() {
} else if (!strncmp("rtsp://gtalk/", mUri.string(), 13)) { } else if (!strncmp("rtsp://gtalk/", mUri.string(), 13)) {
if (mLooper == NULL) { if (mLooper == NULL) {
mLooper = new ALooper; mLooper = new ALooper;
mLooper->setName("gtalk rtp");
mLooper->start( mLooper->start(
false /* runOnCallingThread */, false /* runOnCallingThread */,
false /* canCallJava */, false /* canCallJava */,
@ -1352,6 +1353,7 @@ status_t AwesomePlayer::finishSetDataSource_l() {
} else if (!strncasecmp("rtsp://", mUri.string(), 7)) { } else if (!strncasecmp("rtsp://", mUri.string(), 7)) {
if (mLooper == NULL) { if (mLooper == NULL) {
mLooper = new ALooper; mLooper = new ALooper;
mLooper->setName("rtsp");
mLooper->start(); mLooper->start();
} }
mRTSPController = new ARTSPController(mLooper); mRTSPController = new ARTSPController(mLooper);

View File

@ -180,6 +180,7 @@ NuCachedSource2::NuCachedSource2(const sp<DataSource> &source)
mLastAccessPos(0), mLastAccessPos(0),
mFetching(true), mFetching(true),
mLastFetchTimeUs(-1) { mLastFetchTimeUs(-1) {
mLooper->setName("NuCachedSource2");
mLooper->registerHandler(mReflector); mLooper->registerHandler(mReflector);
mLooper->start(); mLooper->start();

View File

@ -65,6 +65,10 @@ ALooper::~ALooper() {
stop(); stop();
} }
void ALooper::setName(const char *name) {
mName = name;
}
ALooper::handler_id ALooper::registerHandler(const sp<AHandler> &handler) { ALooper::handler_id ALooper::registerHandler(const sp<AHandler> &handler) {
return gLooperRoster.registerHandler(this, handler); return gLooperRoster.registerHandler(this, handler);
} }
@ -100,7 +104,8 @@ status_t ALooper::start(
mThread = new LooperThread(this, canCallJava); mThread = new LooperThread(this, canCallJava);
status_t err = mThread->run("ALooper", priority); status_t err = mThread->run(
mName.empty() ? "ALooper" : mName.c_str(), priority);
if (err != OK) { if (err != OK) {
mThread.clear(); mThread.clear();
} }

View File

@ -31,6 +31,7 @@ ARTPWriter::ARTPWriter(int fd)
mReflector(new AHandlerReflector<ARTPWriter>(this)) { mReflector(new AHandlerReflector<ARTPWriter>(this)) {
CHECK_GE(fd, 0); CHECK_GE(fd, 0);
mLooper->setName("rtp writer");
mLooper->registerHandler(mReflector); mLooper->registerHandler(mReflector);
mLooper->start(); mLooper->start();

View File

@ -76,7 +76,7 @@ struct MyHandler : public AHandler {
mFirstAccessUnitNTP(0), mFirstAccessUnitNTP(0),
mNumAccessUnitsReceived(0), mNumAccessUnitsReceived(0),
mCheckPending(false) { mCheckPending(false) {
mNetLooper->setName("rtsp net");
mNetLooper->start(false /* runOnCallingThread */, mNetLooper->start(false /* runOnCallingThread */,
false /* canCallJava */, false /* canCallJava */,
PRIORITY_HIGHEST); PRIORITY_HIGHEST);
@ -389,7 +389,7 @@ struct MyHandler : public AHandler {
} }
mNumAccessUnitsReceived = 0; mNumAccessUnitsReceived = 0;
msg->post(500000); msg->post(1000000);
break; break;
} }
@ -400,7 +400,7 @@ struct MyHandler : public AHandler {
if (!mCheckPending) { if (!mCheckPending) {
mCheckPending = true; mCheckPending = true;
sp<AMessage> check = new AMessage('chek', id()); sp<AMessage> check = new AMessage('chek', id());
check->post(500000); check->post(1000000);
} }
size_t trackIndex; size_t trackIndex;