stackuser
stackuser

Reputation: 669

Stagefright: NuPlayer implementations

I am going through the NuPlayer implementations in Android Stagefright. As per my understanding NuPlayerFactory is creating NuPlayerDriver in turn it creates ALooper and NuPlayer. I Couldn't understand ALooper and what does it do. I can see all the implementations in NuPlayer are invoking AMessage calls e.g as below:

NuPlyercpp: new AMessage(kWhatSourceNotify, id());

I am not sure how does it trigger NuPlayer::onMessageReceived(). Could readers please explain?

Upvotes: 0

Views: 2094

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57183

In NuPlayerDriver constructor, you see

mPlayer = new NuPlayer;
mLooper->registerHandler(mPlayer);

This ALooper::registerHandler() uses a global ALooperRoster to remember the relation between a handler (mPlayer) and a looper (mLooper).

In NuPlyer.cpp, the general pattern is:

sp<AMessage> msg = new AMessage(..., id());
....
msg->post();

AMessage::post() calls the global ALooperRoster to post the message with 0 delay, using the relation that was established in NuPlayerDriver constructor.

Upvotes: 2

Related Questions