Android 7.1 与 8.0.0_r4 Audio对比

Android-8.0.0_r4源码 源自:
http://androidxref.com/8.0.0_r4/

Android-O 在 Android-N之上添加了libaaudio 路径如下:
frameworks/av/media/

在audioserver服务中新添加了 AAudioService 服务

frameworks/av/media/audioserver/main_audioserver.cpp
130        sp<ProcessState> proc(ProcessState::self());
131        sp<IServiceManager> sm = defaultServiceManager();
132        ALOGI("ServiceManager: %p", sm.get());
133        AudioFlinger::instantiate();
134        AudioPolicyService::instantiate();
           //add the new AAudioService service
135        AAudioService::instantiate();
136        RadioService::instantiate();
137        SoundTriggerHwService::instantiate();
138        ProcessState::self()->startThreadPool();

AAudioService的声明及实现:
frameworks/av/services/oboeservice/AAudioService.cpp
frameworks/av/services/oboeservice/AAudioService.h

AAudioService.h类声明如下:

frameworks/av/services/oboeservice/AAudioService.h
34 class AAudioService :
35    public BinderService<AAudioService>,
36    public BnAAudioService,
37    public aaudio::AAudioServiceInterface
38{
39    friend class BinderService<AAudioService>;
40
41public:
42    AAudioService();
43    virtual ~AAudioService();
44
45    static const char* getServiceName() { return AAUDIO_SERVICE_NAME; }
46
47    virtual aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
48                                     aaudio::AAudioStreamConfiguration &configuration);
49
50    virtual aaudio_result_t closeStream(aaudio_handle_t streamHandle);
51
52    virtual aaudio_result_t getStreamDescription(
53                aaudio_handle_t streamHandle,
54                aaudio::AudioEndpointParcelable &parcelable);
55
56    virtual aaudio_result_t startStream(aaudio_handle_t streamHandle);
57
58    virtual aaudio_result_t pauseStream(aaudio_handle_t streamHandle);
59
60    virtual aaudio_result_t stopStream(aaudio_handle_t streamHandle);
61
62    virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle);
63
64    virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
65                                              pid_t pid, pid_t tid,
66                                              int64_t periodNanoseconds) ;
67
68    virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
69                                                  pid_t pid, pid_t tid);
70
71private:
72
73    aaudio::AAudioServiceStreamBase *convertHandleToServiceStream(aaudio_handle_t streamHandle) const;
74
75    HandleTracker mHandleTracker;
76
77    enum constants {
78        DEFAULT_AUDIO_PRIORITY = 2
79    };
80};

IAAudioService.h接口声明如下:

frameworks/av/media/libaaudio/src/binding/IAAudioService.h
35#define AAUDIO_SERVICE_NAME  "media.aaudio"
36
37// Interface (our AIDL) - Shared by server and client
38class IAAudioService : public IInterface {
39public:
40
41    DECLARE_META_INTERFACE(AAudioService);
42
43    /**
44     * @param request info needed to create the stream
45     * @param configuration contains information about the created stream
46     * @return handle to the stream or a negative error
47     */
48    virtual aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
49                                     aaudio::AAudioStreamConfiguration &configurationOutput) = 0;
50
51    virtual aaudio_result_t closeStream(aaudio::aaudio_handle_t streamHandle) = 0;
52
53    /* Get an immutable description of the in-memory queues
54    * used to communicate with the underlying HAL or Service.
55    */
56    virtual aaudio_result_t getStreamDescription(aaudio::aaudio_handle_t streamHandle,
57                                               aaudio::AudioEndpointParcelable &parcelable) = 0;
58
59    /**
60     * Start the flow of data.
61     * This is asynchronous. When complete, the service will send a STARTED event.
62     */
63    virtual aaudio_result_t startStream(aaudio::aaudio_handle_t streamHandle) = 0;
64
65    /**
66     * Stop the flow of data such that start() can resume without loss of data.
67     * This is asynchronous. When complete, the service will send a PAUSED event.
68     */
69    virtual aaudio_result_t pauseStream(aaudio::aaudio_handle_t streamHandle) = 0;
70
71    /**
72     * Stop the flow of data such that the data currently in the buffer is played.
73     * This is asynchronous. When complete, the service will send a STOPPED event.
74     */
75    virtual aaudio_result_t stopStream(aaudio::aaudio_handle_t streamHandle) = 0;
76
77    /**
78     *  Discard any data held by the underlying HAL or Service.
79     * This is asynchronous. When complete, the service will send a FLUSHED event.
80     */
81    virtual aaudio_result_t flushStream(aaudio::aaudio_handle_t streamHandle) = 0;
82
83    /**
84     * Manage the specified thread as a low latency audio thread.
85     * TODO Consider passing this information as part of the startStream() call.
86     */
87    virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
88                                              pid_t clientProcessId,
89                                              pid_t clientThreadId,
90                                              int64_t periodNanoseconds) = 0;
91
92    virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
93                                                pid_t clientProcessId,
94                                                pid_t clientThreadId) = 0;
95};
96
97class BnAAudioService : public BnInterface<IAAudioService> {
98public:
99    virtual status_t onTransact(uint32_t code, const Parcel& data,
100                                Parcel* reply, uint32_t flags = 0);
101
102};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值