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 NBAIO_Source that wraps an AudioBufferProvider 18 19 #ifndef ANDROID_AUDIO_BUFFER_PROVIDER_SOURCE_H 20 #define ANDROID_AUDIO_BUFFER_PROVIDER_SOURCE_H 21 22 #include <media/AudioBufferProvider.h> 23 #include <media/nbaio/NBAIO.h> 24 25 namespace android { 26 27 class AudioBufferProviderSource : public NBAIO_Source { 28 29 public: 30 AudioBufferProviderSource(AudioBufferProvider *provider, const NBAIO_Format& format); 31 virtual ~AudioBufferProviderSource(); 32 33 // NBAIO_Port interface 34 35 //virtual ssize_t negotiate(const NBAIO_Format offers[], size_t numOffers, 36 // NBAIO_Format counterOffers[], size_t& numCounterOffers); 37 //virtual NBAIO_Format format(); 38 39 // NBAIO_Source interface 40 41 //virtual size_t framesRead() const; 42 //virtual size_t framesOverrun(); 43 //virtual size_t overruns(); 44 virtual ssize_t availableToRead(); 45 virtual ssize_t read(void *buffer, size_t count); 46 virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block); 47 48 private: 49 AudioBufferProvider * const mProvider; 50 AudioBufferProvider::Buffer mBuffer; // current buffer 51 size_t mConsumed; // number of frames consumed so far from current buffer 52 }; 53 54 } // namespace android 55 56 #endif // ANDROID_AUDIO_BUFFER_PROVIDER_SOURCE_H 57