RecordTracks.h revision 9a54bc27876acd5d8be5b1fc3dc46701fe76fbb3
181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent/*
281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent**
381784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** Copyright 2012, The Android Open Source Project
481784c37c61b09289654b979567a42bf73cd2b12Eric Laurent**
581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** Licensed under the Apache License, Version 2.0 (the "License");
681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** you may not use this file except in compliance with the License.
781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** You may obtain a copy of the License at
881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent**
981784c37c61b09289654b979567a42bf73cd2b12Eric Laurent**     http://www.apache.org/licenses/LICENSE-2.0
1081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent**
1181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** Unless required by applicable law or agreed to in writing, software
1281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** distributed under the License is distributed on an "AS IS" BASIS,
1381784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1481784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** See the License for the specific language governing permissions and
1581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent** limitations under the License.
1681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent*/
1781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
1881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent#ifndef INCLUDING_FROM_AUDIOFLINGER_H
1981784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    #error This header file should only be included from AudioFlinger.h
2081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent#endif
2181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
2281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent// record track
2381784c37c61b09289654b979567a42bf73cd2b12Eric Laurentclass RecordTrack : public TrackBase {
2481784c37c61b09289654b979567a42bf73cd2b12Eric Laurentpublic:
2581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                        RecordTrack(RecordThread *thread,
2681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                const sp<Client>& client,
2781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                uint32_t sampleRate,
2881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                audio_format_t format,
2981784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                audio_channel_mask_t channelMask,
3081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                size_t frameCount,
3181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                int sessionId);
3281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    virtual             ~RecordTrack();
3381784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
3481784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    virtual status_t    start(AudioSystem::sync_event_t event, int triggerSession);
3581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    virtual void        stop();
3681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
3781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            void        destroy();
3881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
399a54bc27876acd5d8be5b1fc3dc46701fe76fbb3Eric Laurent            void        invalidate();
4081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            // clear the buffer overflow flag
4181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            void        clearOverflow() { mOverflow = false; }
4281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            // set the buffer overflow flag and return previous value
4381784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            bool        setOverflow() { bool tmp = mOverflow; mOverflow = true;
4481784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                                return tmp; }
4581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
4681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    static  void        appendDumpHeader(String8& result);
4781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent            void        dump(char* buffer, size_t size);
4881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
4981784c37c61b09289654b979567a42bf73cd2b12Eric Laurentprivate:
5081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    friend class AudioFlinger;  // for mState
5181784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
5281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                        RecordTrack(const RecordTrack&);
5381784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                        RecordTrack& operator = (const RecordTrack&);
5481784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
5581784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    // AudioBufferProvider interface
5681784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer,
5781784c37c61b09289654b979567a42bf73cd2b12Eric Laurent                                   int64_t pts = kInvalidPTS);
5881784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    // releaseBuffer() not overridden
5981784c37c61b09289654b979567a42bf73cd2b12Eric Laurent
6081784c37c61b09289654b979567a42bf73cd2b12Eric Laurent    bool                mOverflow;  // overflow on most recent attempt to fill client buffer
619f80dd223d83d9bb9077fb6baee056cee4eaf7e5Glenn Kasten    AudioRecordServerProxy* mAudioRecordServerProxy;
6281784c37c61b09289654b979567a42bf73cd2b12Eric Laurent};
63