1/*
2 * Copyright (C) 2012 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// Implementation of AudioBufferProvider that wraps an NBAIO_Source
18
19#ifndef ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H
20#define ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H
21
22#include "NBAIO.h"
23#include <media/ExtendedAudioBufferProvider.h>
24
25namespace android {
26
27class SourceAudioBufferProvider : public ExtendedAudioBufferProvider {
28
29public:
30    SourceAudioBufferProvider(const sp<NBAIO_Source>& source);
31    virtual ~SourceAudioBufferProvider();
32
33    // AudioBufferProvider interface
34    virtual status_t getNextBuffer(Buffer *buffer, int64_t pts);
35    virtual void     releaseBuffer(Buffer *buffer);
36
37    // ExtendedAudioBufferProvider interface
38    virtual size_t   framesReady() const;
39
40private:
41    const sp<NBAIO_Source> mSource;     // the wrapped source
42    /*const*/ size_t    mFrameBitShift; // log2(frame size in bytes)
43    void*               mAllocated; // pointer to base of allocated memory
44    size_t              mSize;      // size of mAllocated in frames
45    size_t              mOffset;    // frame offset within mAllocated of valid data
46    size_t              mRemaining; // frame count within mAllocated of valid data
47    size_t              mGetCount;  // buffer.frameCount of the most recent getNextBuffer
48};
49
50}   // namespace android
51
52#endif  // ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H
53