1 /* 2 * Copyright (C) 2017 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 #ifndef AAUDIO_FIXED_BLOCK_READER_H 18 #define AAUDIO_FIXED_BLOCK_READER_H 19 20 #include <stdint.h> 21 22 #include "FixedBlockAdapter.h" 23 24 /** 25 * Read from a fixed-size block to a variable sized block. 26 * 27 * This can be used to convert a pull data flow from fixed sized buffers to variable sized buffers. 28 * An example would be an audio output callback that reads from the app. 29 */ 30 class FixedBlockReader : public FixedBlockAdapter 31 { 32 public: 33 FixedBlockReader(FixedBlockProcessor &fixedBlockProcessor); 34 35 virtual ~FixedBlockReader() = default; 36 37 int32_t open(int32_t bytesPerFixedBlock) override; 38 39 int32_t readFromStorage(uint8_t *buffer, int32_t numBytes); 40 41 /** 42 * Read into a variable sized block. 43 */ 44 int32_t processVariableBlock(uint8_t *buffer, int32_t numBytes) override; 45 }; 46 47 48 #endif /* AAUDIO_FIXED_BLOCK_READER_H */ 49