Android MediaPlayer事件通知调用层次关系

date: 2015.11.26; modification:2015.11.26

MediaPlayerService::Client::notify(
|
+-> c->notify(msg, ext1, ext2, obj);  // c即具体的player, 如AwesomePlayer.


MediaPlayer.cpp:::MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj)
|
+-> sp<MediaPlayerListener>listener->notify(msg, ext1, ext2, obj);
    |
    +-> android_media_MediaPlayer.cpp:::JNIMediaPlayerListener::notify()
        |
        +-> env->CallStaticVoidMethod(mClass, fields.post_event, mObject, msg, ext1, ext2, NULL);
            |
            +-> MediaPlayer.java:::MediaPlayer::EventHandler::postEventFromNative()
                |
                +-> Message m = mp.mEventHandler.obtainMessage(what, arg1, arg2, obj);
                +-> mp.mEventHandler.sendMessage(m);


MediaPlayer.java:::MediaPlayer::EventHandler::handleMessage(Message msg)
|
+-> switch(msg.what) {
        case MEDIA_ERROR:
            error_was_handled = mOnErrorListener.onError(mMediaPlayer, msg.arg1, msg.arg2);
    }