blob: 7357aa53a25e91e03d787db2fd120a22325f8092 [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"
Glenn Kasten2dd4bdd2012-08-29 11:10:32 -070023#include <media/ExtendedAudioBufferProvider.h>
Glenn Kasten01066232012-02-27 11:50:44 -080024
25namespace android {
26
Glenn Kasten288ed212012-04-25 17:52:27 -070027class SourceAudioBufferProvider : public ExtendedAudioBufferProvider {
Glenn Kasten01066232012-02-27 11:50:44 -080028
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
Glenn Kasten288ed212012-04-25 17:52:27 -070037 // ExtendedAudioBufferProvider interface
38 virtual size_t framesReady() const;
Glenn Kasten6466c9e2013-08-23 10:54:07 -070039 virtual size_t framesReleased() const;
40 virtual void onTimestamp(const AudioTimestamp& timestamp);
Glenn Kasten288ed212012-04-25 17:52:27 -070041
Glenn Kasten01066232012-02-27 11:50:44 -080042private:
43 const sp<NBAIO_Source> mSource; // the wrapped source
44 /*const*/ size_t mFrameBitShift; // log2(frame size in bytes)
Glenn Kastenac3e9db2014-03-06 08:00:31 -080045 /*const*/ size_t mFrameSize; // frame size in bytes
Glenn Kasten01066232012-02-27 11:50:44 -080046 void* mAllocated; // pointer to base of allocated memory
47 size_t mSize; // size of mAllocated in frames
48 size_t mOffset; // frame offset within mAllocated of valid data
49 size_t mRemaining; // frame count within mAllocated of valid data
50 size_t mGetCount; // buffer.frameCount of the most recent getNextBuffer
Glenn Kasten6466c9e2013-08-23 10:54:07 -070051 uint32_t mFramesReleased; // counter of the total number of frames released
Glenn Kasten01066232012-02-27 11:50:44 -080052};
53
54} // namespace android
55
56#endif // ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H