During Android device bootup processes present in init.rc will be loaded. adb, ril, zygote, mediaserver, bluetooth are few to name in the bootup processes.
Zygote helps in reducing the loading time of applications.Since all the core libraries are loaded and exist in a single place which are generally readonly can be forked from this place itself reducing the time for loading. Only some specific libraries needed to be loaded for any specific task since all the dependent core/common libraries are already loaded by Zygote process.
mediaserver is useful in handling all media related operations and this is also loaded during boot up time. Even if we kill the mediaserver process it will be created again. mediaserver process will instantiate services like AudioFlinger, MediaPlayerService, CameraService etc.
First lets understand what happens during the device boot up time for the media part. Below figure shows few important calls.
DEVICE BOOTUP:
Now let see how the playback sequence happens in the Android stagefright mediaframework. Below figures depict the important functions flow in the stagefright framework.
To concentrate on only the playback part, lets consider a file browser application, to avoid thumbnail and metadata complications. When we select a file for playback new mediaplayer is created with fd. The main calls from application to middleware are "setDataSource","prepare","prepareAsync","_start","_stop". Below explained the flow for "setDataSource","prepare","prepareAsync","_start".
SET DATA SOURCE:
PREPARE / PREPARE ASYNC:
START: