blob: f5a7d2f9917d9de1ccae0474451a1b9a127dc82a [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
Phil Burk5ed503c2017-02-01 09:38:15 -080025#include <aaudio/AAudio.h>
26#include "utility/HandleTracker.h"
Phil Burkc0c70e32017-02-09 13:18:38 -080027#include "binding/IAAudioService.h"
28#include "binding/AAudioServiceInterface.h"
29
Phil Burk5ed503c2017-02-01 09:38:15 -080030#include "AAudioServiceStreamBase.h"
31
32namespace android {
33
34class AAudioService :
35 public BinderService<AAudioService>,
Phil Burkc0c70e32017-02-09 13:18:38 -080036 public BnAAudioService,
37 public aaudio::AAudioServiceInterface
Phil Burk5ed503c2017-02-01 09:38:15 -080038{
39 friend class BinderService<AAudioService>;
40
41public:
42 AAudioService();
43 virtual ~AAudioService();
44
Phil Burkc0c70e32017-02-09 13:18:38 -080045 static const char* getServiceName() { return AAUDIO_SERVICE_NAME; }
Phil Burk5ed503c2017-02-01 09:38:15 -080046
Phil Burkc0c70e32017-02-09 13:18:38 -080047 virtual aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
Phil Burk5ed503c2017-02-01 09:38:15 -080048 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
Phil Burk71f35bb2017-04-13 16:05:07 -070060 virtual aaudio_result_t stopStream(aaudio_handle_t streamHandle);
61
Phil Burk5ed503c2017-02-01 09:38:15 -080062 virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle);
63
64 virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
Phil Burkc0c70e32017-02-09 13:18:38 -080065 pid_t pid, pid_t tid,
66 int64_t periodNanoseconds) ;
Phil Burk5ed503c2017-02-01 09:38:15 -080067
Phil Burkc0c70e32017-02-09 13:18:38 -080068 virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
69 pid_t pid, pid_t tid);
Phil Burk5ed503c2017-02-01 09:38:15 -080070
71private:
72
73 aaudio::AAudioServiceStreamBase *convertHandleToServiceStream(aaudio_handle_t streamHandle) const;
74
75 HandleTracker mHandleTracker;
76
Phil Burkc0c70e32017-02-09 13:18:38 -080077 enum constants {
78 DEFAULT_AUDIO_PRIORITY = 2
79 };
Phil Burk5ed503c2017-02-01 09:38:15 -080080};
81
82} /* namespace android */
83
Phil Burk3316d5e2017-02-15 11:23:01 -080084#endif //AAUDIO_AAUDIO_SERVICE_H