Phil Burk | 0433d8f | 2018-11-21 16:41:25 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 22 | oboe::DataCallbackResult PlayRecordingCallback::onAudioReady( |
| 23 | oboe::AudioStream *audioStream, |
| 24 | void *audioData, |
| 25 | int numFrames) { |
| 26 | float *floatData = (float *)audioData; |
Phil Burk | 6fb1d80 | 2018-12-21 15:28:07 -0800 | [diff] [blame] | 27 | // Read stored data into the buffer provided. |
Phil Burk | 0433d8f | 2018-11-21 16:41:25 -0800 | [diff] [blame] | 28 | 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 | } |