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 #ifndef ANDROID_AUDIO_PIPE_READER_H 18 #define ANDROID_AUDIO_PIPE_READER_H 19 20 #include "Pipe.h" 21 22 namespace android { 23 24 // PipeReader is safe for only a single thread 25 class PipeReader : public NBAIO_Source { 26 27 public: 28 29 // Construct a PipeReader and associate it with a Pipe 30 // FIXME make this constructor a factory method of Pipe. 31 PipeReader(Pipe& pipe); 32 virtual ~PipeReader(); 33 34 // NBAIO_Port interface 35 36 //virtual ssize_t negotiate(const NBAIO_Format offers[], size_t numOffers, 37 // NBAIO_Format counterOffers[], size_t& numCounterOffers); 38 //virtual NBAIO_Format format() const; 39 40 // NBAIO_Source interface 41 42 //virtual size_t framesRead() const; 43 virtual int64_t framesOverrun() { return mFramesOverrun; } 44 virtual int64_t overruns() { return mOverruns; } 45 46 virtual ssize_t availableToRead(); 47 48 virtual ssize_t read(void *buffer, size_t count); 49 50 virtual ssize_t flush(); 51 52 // NBAIO_Source end 53 54 #if 0 // until necessary 55 Pipe& pipe() const { return mPipe; } 56 #endif 57 58 private: 59 Pipe& mPipe; 60 audio_utils_fifo_reader mFifoReader; 61 int64_t mFramesOverrun; 62 int64_t mOverruns; 63 }; 64 65 } // namespace android 66 67 #endif // ANDROID_AUDIO_PIPE_READER_H 68