Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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_FAST_CAPTURE_STATE_H |
| 18 | #define ANDROID_AUDIO_FAST_CAPTURE_STATE_H |
| 19 | |
| 20 | #include <media/nbaio/NBAIO.h> |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 21 | #include <media/AudioBufferProvider.h> |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 22 | #include "FastThreadState.h" |
| 23 | #include <private/media/AudioTrackShared.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | // Represent a single state of the fast capture |
| 28 | struct FastCaptureState : FastThreadState { |
| 29 | FastCaptureState(); |
| 30 | /*virtual*/ ~FastCaptureState(); |
| 31 | |
| 32 | // all pointer fields use raw pointers; objects are owned and ref-counted by RecordThread |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 33 | NBAIO_Source* mInputSource; // HAL input device, must already be negotiated |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 34 | // FIXME by renaming, could pull up these fields to FastThreadState |
| 35 | int mInputSourceGen; // increment when mInputSource is assigned |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 36 | NBAIO_Sink* mPipeSink; // after reading from input source, write to this pipe sink |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 37 | int mPipeSinkGen; // increment when mPipeSink is assigned |
| 38 | size_t mFrameCount; // number of frames per fast capture buffer |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 39 | audio_track_cblk_t* mCblk; // control block for the single fast client, or NULL |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 40 | |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 41 | audio_format_t mFastPatchRecordFormat = AUDIO_FORMAT_INVALID; |
| 42 | AudioBufferProvider* mFastPatchRecordBufferProvider = nullptr; // a reference to a patch |
| 43 | // record in fast mode |
| 44 | |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 45 | // Extends FastThreadState::Command |
| 46 | static const Command |
| 47 | // The following commands also process configuration changes, and can be "or"ed: |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 48 | READ = 0x8, // read from input source |
| 49 | WRITE = 0x10, // write to pipe sink |
| 50 | READ_WRITE = 0x18; // read from input source and write to pipe sink |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 51 | |
Glenn Kasten | d702a56 | 2015-03-02 15:51:38 -0800 | [diff] [blame] | 52 | // never returns NULL; asserts if command is invalid |
| 53 | static const char *commandToString(Command command); |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 54 | }; // struct FastCaptureState |
| 55 | |
| 56 | } // namespace android |
| 57 | |
| 58 | #endif // ANDROID_AUDIO_FAST_CAPTURE_STATE_H |