187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk/*
287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * Copyright (C) 2017 The Android Open Source Project
387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk *
487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * you may not use this file except in compliance with the License.
687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * You may obtain a copy of the License at
787c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk *
887c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
987c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk *
1087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * Unless required by applicable law or agreed to in writing, software
1187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
1287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * See the License for the specific language governing permissions and
1487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk * limitations under the License.
1587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk */
1687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
1787c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#ifndef AAUDIO_SERVICE_ENDPOINT_PLAY_H
1887c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#define AAUDIO_SERVICE_ENDPOINT_PLAY_H
1987c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
2087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include <atomic>
2187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include <functional>
2287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include <mutex>
2387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include <vector>
2487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
2587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "client/AudioStreamInternal.h"
2687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "client/AudioStreamInternalPlay.h"
2787c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "binding/AAudioServiceMessage.h"
2887c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "AAudioServiceStreamShared.h"
2987c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "AAudioServiceStreamMMAP.h"
3087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "AAudioMixer.h"
3187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#include "AAudioService.h"
3287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
3387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burknamespace aaudio {
3487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
3587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burkclass AAudioServiceEndpointPlay : public AAudioServiceEndpoint {
3687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burkpublic:
3787c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    explicit AAudioServiceEndpointPlay(android::AAudioService &audioService);
3887c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    virtual ~AAudioServiceEndpointPlay();
3987c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
4087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    aaudio_result_t open(int32_t deviceId) override;
4187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
4287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    AudioStreamInternal *getStreamInternal() override {
4387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk        return &mStreamInternalPlay;
4487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    }
4587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
4687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    void *callbackLoop() override;
4787c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
4887c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burkprivate:
4987c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    AudioStreamInternalPlay  mStreamInternalPlay; // for playing output of mixer
5087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    bool                     mLatencyTuningEnabled = false; // TODO implement tuning
5187c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    AAudioMixer              mMixer;    //
5287c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk};
5387c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
5487c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk} /* namespace aaudio */
5587c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk
5687c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk#endif //AAUDIO_SERVICE_ENDPOINT_PLAY_H
57