165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian/*
265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Copyright (C) 2007 The Android Open Source Project
365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * you may not use this file except in compliance with the License.
665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * You may obtain a copy of the License at
765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian *
1065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * Unless required by applicable law or agreed to in writing, software
1165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
1265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * See the License for the specific language governing permissions and
1465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian * limitations under the License.
1565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian */
1665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
1765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#ifndef ANDROID_AUDIO_BUFFER_PROVIDER_H
1865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define ANDROID_AUDIO_BUFFER_PROVIDER_H
1965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/Errors.h>
2165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopiannamespace android {
2365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian// ----------------------------------------------------------------------------
2465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass AudioBufferProvider
2665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian{
2765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianpublic:
2865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    struct Buffer {
3001c4ebf6b794493898114a502ed36de13137f7e5Glenn Kasten        Buffer() : raw(NULL), frameCount(0) { }
3165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        union {
3265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void*       raw;
3365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            short*      i16;
3465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int8_t*     i8;
3565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
3665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        size_t frameCount;
3765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
3865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
3965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual ~AudioBufferProvider() {}
404ff14bae91075eb274eb1c2975982358946e7e63John Grossman
414ff14bae91075eb274eb1c2975982358946e7e63John Grossman    // value representing an invalid presentation timestamp
4201c4ebf6b794493898114a502ed36de13137f7e5Glenn Kasten    static const int64_t kInvalidPTS = 0x7FFFFFFFFFFFFFFFLL;    // <stdint.h> is too painful
434ff14bae91075eb274eb1c2975982358946e7e63John Grossman
444ff14bae91075eb274eb1c2975982358946e7e63John Grossman    // pts is the local time when the next sample yielded by getNextBuffer
454ff14bae91075eb274eb1c2975982358946e7e63John Grossman    // will be rendered.
464ff14bae91075eb274eb1c2975982358946e7e63John Grossman    // Pass kInvalidPTS if the PTS is unknown or not applicable.
4701c4ebf6b794493898114a502ed36de13137f7e5Glenn Kasten    virtual status_t getNextBuffer(Buffer* buffer, int64_t pts = kInvalidPTS) = 0;
484ff14bae91075eb274eb1c2975982358946e7e63John Grossman
4965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual void releaseBuffer(Buffer* buffer) = 0;
5065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian};
5165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian// ----------------------------------------------------------------------------
5365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian}; // namespace android
5465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#endif // ANDROID_AUDIO_BUFFER_PROVIDER_H
56