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