blob: a520d7ab1117f83c3254ed762c75213129c46766 [file] [log] [blame]
Phil Burk5ed503c2017-02-01 09:38:15 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Phil Burk3316d5e2017-02-15 11:23:01 -080017#ifndef AAUDIO_AAUDIO_SERVICE_H
18#define AAUDIO_AAUDIO_SERVICE_H
Phil Burk5ed503c2017-02-01 09:38:15 -080019
20#include <time.h>
21#include <pthread.h>
22
23#include <binder/BinderService.h>
24
25#include <aaudio/AAudioDefinitions.h>
26#include <aaudio/AAudio.h>
27#include "utility/HandleTracker.h"
28#include "IAAudioService.h"
29#include "AAudioServiceStreamBase.h"
30
31namespace android {
32
33class AAudioService :
34 public BinderService<AAudioService>,
35 public BnAAudioService
36{
37 friend class BinderService<AAudioService>;
38
39public:
40 AAudioService();
41 virtual ~AAudioService();
42
43 static const char* getServiceName() { return "media.audio_aaudio"; }
44
45 virtual aaudio_handle_t openStream(aaudio::AAudioStreamRequest &request,
46 aaudio::AAudioStreamConfiguration &configuration);
47
48 virtual aaudio_result_t closeStream(aaudio_handle_t streamHandle);
49
50 virtual aaudio_result_t getStreamDescription(
51 aaudio_handle_t streamHandle,
52 aaudio::AudioEndpointParcelable &parcelable);
53
54 virtual aaudio_result_t startStream(aaudio_handle_t streamHandle);
55
56 virtual aaudio_result_t pauseStream(aaudio_handle_t streamHandle);
57
58 virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle);
59
60 virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
Phil Burk3316d5e2017-02-15 11:23:01 -080061 pid_t pid, int64_t periodNanoseconds) ;
Phil Burk5ed503c2017-02-01 09:38:15 -080062
63 virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle, pid_t pid);
64
65private:
66
67 aaudio::AAudioServiceStreamBase *convertHandleToServiceStream(aaudio_handle_t streamHandle) const;
68
69 HandleTracker mHandleTracker;
70
71};
72
73} /* namespace android */
74
Phil Burk3316d5e2017-02-15 11:23:01 -080075#endif //AAUDIO_AAUDIO_SERVICE_H