blob: 6b7e4e55400c576026f470e4625f27bcbdc8b519 [file] [log] [blame]
Phil Burk2355edb2016-12-26 13:54:02 -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
17#define LOG_TAG "OboeService"
18//#define LOG_NDEBUG 0
19#include <utils/Log.h>
20
21#include "IOboeAudioService.h"
22#include "OboeService.h"
23#include "OboeServiceStreamBase.h"
24#include "AudioEndpointParcelable.h"
25
26using namespace android;
27using namespace oboe;
28
29/**
30 * Construct the AudioCommandQueues and the AudioDataQueue
31 * and fill in the endpoint parcelable.
32 */
33
34OboeServiceStreamBase::OboeServiceStreamBase()
35 : mUpMessageQueue(nullptr)
36{
37 // TODO could fail so move out of constructor
38 mUpMessageQueue = new SharedRingBuffer();
39 mUpMessageQueue->allocate(sizeof(OboeServiceMessage), QUEUE_UP_CAPACITY_COMMANDS);
40}
41
42OboeServiceStreamBase::~OboeServiceStreamBase() {
43 delete mUpMessageQueue;
44}
45
46void OboeServiceStreamBase::sendServiceEvent(oboe_service_event_t event,
47 int32_t data1,
48 int64_t data2) {
49 OboeServiceMessage command;
50 command.what = OboeServiceMessage::code::EVENT;
51 command.event.event = event;
52 command.event.data1 = data1;
53 command.event.data2 = data2;
54 mUpMessageQueue->getFifoBuffer()->write(&command, 1);
55}
56
57