blob: 3219d78acf100f27756b9b778847e257f7dc1394 [file] [log] [blame]
Glenn Kasten01066232012-02-27 11:50:44 -08001/*
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 "AudioBufferProvider.h"
24
25namespace android {
26
27class SourceAudioBufferProvider : public AudioBufferProvider {
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
37private:
38 const sp<NBAIO_Source> mSource; // the wrapped source
39 /*const*/ size_t mFrameBitShift; // log2(frame size in bytes)
40 void* mAllocated; // pointer to base of allocated memory
41 size_t mSize; // size of mAllocated in frames
42 size_t mOffset; // frame offset within mAllocated of valid data
43 size_t mRemaining; // frame count within mAllocated of valid data
44 size_t mGetCount; // buffer.frameCount of the most recent getNextBuffer
45};
46
47} // namespace android
48
49#endif // ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H