Mediaserver creation process

Source: Internet
Author: User

Create mediaserver and several services running in mediaserver.

1. File frameworks/base/Media/mediaserver/main_mediaserver.cpp

Int main (INT argc, char ** argv) {sp <processstate> proc (processstate: Self (); sp <iservicemanager> Sm = defaultservicemanager (); logi ("servicemanager: % P", SM. get (); audioflinger: instantiate (); // create an audioflinger object named "media. audio_flinger "mediaplayerservice: instantiate (); // create a mediaplayerservice object named" media. player "cameraservice: instantiate (); // create a cameraservice object named" media. camera "audiopol Icyservice: instantiate (); // creates an audiopolicyservice object named "media. audio_policy "processstate: Self ()-> startthreadpool (); // creates a thread. The thread name is in the" binder thread # % d "format and D is a numerical code, for example, "binder thread #1" ipcthreadstate: Self ()-> jointhreadpool (); // Add the preceding thread to the binder for inter-process communication in IPC .}

Poolthread inherits from thread and is a thread class.
The process binder supports a maximum of 15 threads. the maximum number of threads of binder_set_max_threads is set in the open_driver () function.
The code is located in the frameworks/base/libs/binder/processstate. cpp file:

#if defined(HAVE_ANDROID_OS)        size_t maxThreads = 15;        result = ioctl(fd, BINDER_SET_MAX_THREADS, &maxThreads);        if (result == -1) {            LOGE("Binder ioctl to set max threads failed: %s", strerror(errno));        }#endif

2. Generate the MK file corresponding to the mediaserver and compile the executable file mediaserver.
Local_path: = $ (call my-DIR)
Include $ (clear_vars)

Local_src_files: = \
Main_mediaserver.cpp

Local_shared_libraries: = \
Libaudioflinger \
Libcameraservice \
Libmediaplayerservice \
Libutils \
Libbinder

Base: = $ (local_path )/../..

Local_c_includes: = \
$ (Base)/services/audioflinger \
$ (Base)/services/camera/libcameraservice \
$ (Base)/Media/libmediaplayerservice

Local_module: = mediaserver // mediaserver is an executable program.

Include $ (build_executable)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.