blob: 398353b011335e0ce5262def6e79a437992ff290 [file] [log] [blame]
Glenn Kasten01066232012-02-27 11:50:44 -08001/*
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
22namespace android {
23
24// PipeReader is safe for only a single thread
25class PipeReader : public NBAIO_Source {
26
27public:
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 size_t framesOverrun() { return mFramesOverrun; }
44 virtual size_t overruns() { return mOverruns; }
45
46 virtual ssize_t availableToRead();
47
Glenn Kastend79072e2016-01-06 08:41:20 -080048 virtual ssize_t read(void *buffer, size_t count);
Glenn Kasten01066232012-02-27 11:50:44 -080049
50 // NBAIO_Source end
51
52#if 0 // until necessary
53 Pipe& pipe() const { return mPipe; }
54#endif
55
56private:
57 Pipe& mPipe;
58 int32_t mFront; // follows behind mPipe.mRear
59 size_t mFramesOverrun;
60 size_t mOverruns;
61};
62
63} // namespace android
64
65#endif // ANDROID_AUDIO_PIPE_READER_H