blob: f878306eb2455f8c9d7691180afd04494da4706b [file] [log] [blame]
Phil Burk0433d8f2018-11-21 16:41:25 -08001/*
2 * Copyright 2018 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#include "PlayRecordingCallback.h"
18
19/**
20 * Called when the stream is ready to process audio.
21 */
22oboe::DataCallbackResult PlayRecordingCallback::onAudioReady(
23 oboe::AudioStream *audioStream,
24 void *audioData,
25 int numFrames) {
26 float *floatData = (float *)audioData;
Phil Burk6fb1d802018-12-21 15:28:07 -080027 // Read stored data into the buffer provided.
Phil Burk0433d8f2018-11-21 16:41:25 -080028 int32_t framesRead = mRecording->read(floatData, numFrames);
29 // LOGI("%s() framesRead = %d, numFrames = %d", __func__, framesRead, numFrames);
30 return framesRead > 0
31 ? oboe::DataCallbackResult::Continue
32 : oboe::DataCallbackResult::Stop;
33}