Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | #ifndef ANDROID_AUDIO_BUFFER_PROVIDER_H |
| 18 | #define ANDROID_AUDIO_BUFFER_PROVIDER_H |
| 19 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 20 | #include <utils/Errors.h> |
| 21 | |
| 22 | namespace android { |
| 23 | // ---------------------------------------------------------------------------- |
| 24 | |
| 25 | class AudioBufferProvider |
| 26 | { |
| 27 | public: |
| 28 | |
| 29 | struct Buffer { |
Glenn Kasten | 01c4ebf | 2012-02-22 10:47:35 -0800 | [diff] [blame] | 30 | Buffer() : raw(NULL), frameCount(0) { } |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 31 | union { |
| 32 | void* raw; |
| 33 | short* i16; |
| 34 | int8_t* i8; |
| 35 | }; |
| 36 | size_t frameCount; |
| 37 | }; |
| 38 | |
Glenn Kasten | 409e374 | 2013-02-27 09:39:39 -0800 | [diff] [blame^] | 39 | virtual ~AudioBufferProvider() {} |
John Grossman | 4ff14ba | 2012-02-08 16:37:41 -0800 | [diff] [blame] | 40 | |
| 41 | // value representing an invalid presentation timestamp |
Glenn Kasten | 01c4ebf | 2012-02-22 10:47:35 -0800 | [diff] [blame] | 42 | static const int64_t kInvalidPTS = 0x7FFFFFFFFFFFFFFFLL; // <stdint.h> is too painful |
John Grossman | 4ff14ba | 2012-02-08 16:37:41 -0800 | [diff] [blame] | 43 | |
| 44 | // pts is the local time when the next sample yielded by getNextBuffer |
| 45 | // will be rendered. |
| 46 | // Pass kInvalidPTS if the PTS is unknown or not applicable. |
Glenn Kasten | 01c4ebf | 2012-02-22 10:47:35 -0800 | [diff] [blame] | 47 | virtual status_t getNextBuffer(Buffer* buffer, int64_t pts = kInvalidPTS) = 0; |
John Grossman | 4ff14ba | 2012-02-08 16:37:41 -0800 | [diff] [blame] | 48 | |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 49 | virtual void releaseBuffer(Buffer* buffer) = 0; |
Mathias Agopian | 65ab471 | 2010-07-14 17:59:35 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | // ---------------------------------------------------------------------------- |
| 53 | }; // namespace android |
| 54 | |
| 55 | #endif // ANDROID_AUDIO_BUFFER_PROVIDER_H |