• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
framesOverrun()43     virtual int64_t framesOverrun() { return mFramesOverrun; }
overruns()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     // NBAIO_Source end
51 
52 #if 0   // until necessary
53     Pipe& pipe() const { return mPipe; }
54 #endif
55 
56 private:
57     Pipe&       mPipe;
58     int32_t     mFront;         // follows behind mPipe.mRear
59     int64_t     mFramesOverrun;
60     int64_t     mOverruns;
61 };
62 
63 }   // namespace android
64 
65 #endif  // ANDROID_AUDIO_PIPE_READER_H
66