1e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk/*
2e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * Copyright (C) 2017 The Android Open Source Project
3e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk *
4e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * you may not use this file except in compliance with the License.
6e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * You may obtain a copy of the License at
7e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk *
8e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk *
10e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * Unless required by applicable law or agreed to in writing, software
11e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * See the License for the specific language governing permissions and
14e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * limitations under the License.
15e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk */
16e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
17e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk#ifndef AAUDIO_FIXED_BLOCK_WRITER_H
18e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk#define AAUDIO_FIXED_BLOCK_WRITER_H
19e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
20e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk#include <stdint.h>
21e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
22e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk#include "FixedBlockAdapter.h"
23e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
24e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk/**
25e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * This can be used to convert a push data flow from variable sized buffers to fixed sized buffers.
26e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk * An example would be an audio input callback.
27e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk */
28e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burkclass FixedBlockWriter : public FixedBlockAdapter
29e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk{
30e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burkpublic:
31e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk    FixedBlockWriter(FixedBlockProcessor &fixedBlockProcessor);
32e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
33e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk    virtual ~FixedBlockWriter() = default;
34e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
35e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk    int32_t writeToStorage(uint8_t *buffer, int32_t numBytes);
36e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
37e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk    /**
38e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk     * Write from a variable sized block.
39e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk     */
40e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk    int32_t processVariableBlock(uint8_t *buffer, int32_t numBytes) override;
41e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk};
42e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk
43e4d7bb418df0fdc4c708c334ba3601f5ed8d89b3Phil Burk#endif /* AAUDIO_FIXED_BLOCK_WRITER_H */
44