1*ec779b8eSAndroid Build Coastguard Worker /* 2*ec779b8eSAndroid Build Coastguard Worker * Copyright (C) 2014 The Android Open Source Project 3*ec779b8eSAndroid Build Coastguard Worker * 4*ec779b8eSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*ec779b8eSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*ec779b8eSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*ec779b8eSAndroid Build Coastguard Worker * 8*ec779b8eSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*ec779b8eSAndroid Build Coastguard Worker * 10*ec779b8eSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*ec779b8eSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*ec779b8eSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*ec779b8eSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*ec779b8eSAndroid Build Coastguard Worker * limitations under the License. 15*ec779b8eSAndroid Build Coastguard Worker */ 16*ec779b8eSAndroid Build Coastguard Worker 17*ec779b8eSAndroid Build Coastguard Worker #pragma once 18*ec779b8eSAndroid Build Coastguard Worker 19*ec779b8eSAndroid Build Coastguard Worker #include <type_traits> 20*ec779b8eSAndroid Build Coastguard Worker #include <media/nbaio/NBAIO.h> 21*ec779b8eSAndroid Build Coastguard Worker #include <media/AudioBufferProvider.h> 22*ec779b8eSAndroid Build Coastguard Worker #include "FastThreadState.h" 23*ec779b8eSAndroid Build Coastguard Worker #include <private/media/AudioTrackShared.h> 24*ec779b8eSAndroid Build Coastguard Worker 25*ec779b8eSAndroid Build Coastguard Worker namespace android { 26*ec779b8eSAndroid Build Coastguard Worker 27*ec779b8eSAndroid Build Coastguard Worker // Represent a single state of the fast capture 28*ec779b8eSAndroid Build Coastguard Worker struct FastCaptureState : FastThreadState { 29*ec779b8eSAndroid Build Coastguard Worker // all pointer fields use raw pointers; objects are owned and ref-counted by RecordThread 30*ec779b8eSAndroid Build Coastguard Worker NBAIO_Source* mInputSource = nullptr; // HAL input device, must already be negotiated 31*ec779b8eSAndroid Build Coastguard Worker // FIXME by renaming, could pull up these fields to FastThreadState 32*ec779b8eSAndroid Build Coastguard Worker int mInputSourceGen = 0; // increment when mInputSource is assigned 33*ec779b8eSAndroid Build Coastguard Worker NBAIO_Sink* mPipeSink = nullptr; // after reading from input source, 34*ec779b8eSAndroid Build Coastguard Worker // write to this pipe sink 35*ec779b8eSAndroid Build Coastguard Worker int mPipeSinkGen = 0; // increment when mPipeSink is assigned 36*ec779b8eSAndroid Build Coastguard Worker size_t mFrameCount = 0; // number of frames per fast capture buffer 37*ec779b8eSAndroid Build Coastguard Worker audio_track_cblk_t* mCblk; // control block for the single fast client, or NULL 38*ec779b8eSAndroid Build Coastguard Worker 39*ec779b8eSAndroid Build Coastguard Worker audio_format_t mFastPatchRecordFormat = AUDIO_FORMAT_INVALID; 40*ec779b8eSAndroid Build Coastguard Worker AudioBufferProvider* mFastPatchRecordBufferProvider = nullptr; // a reference to a patch 41*ec779b8eSAndroid Build Coastguard Worker // record in fast mode 42*ec779b8eSAndroid Build Coastguard Worker bool mSilenceCapture = false; // request to silence capture for fast track. 43*ec779b8eSAndroid Build Coastguard Worker // note: this also silences the normal mixer pipe 44*ec779b8eSAndroid Build Coastguard Worker 45*ec779b8eSAndroid Build Coastguard Worker // Extends FastThreadState::Command 46*ec779b8eSAndroid Build Coastguard Worker static const Command 47*ec779b8eSAndroid Build Coastguard Worker // The following commands also process configuration changes, and can be "or"ed: 48*ec779b8eSAndroid Build Coastguard Worker READ = 0x8, // read from input source 49*ec779b8eSAndroid Build Coastguard Worker WRITE = 0x10, // write to pipe sink 50*ec779b8eSAndroid Build Coastguard Worker READ_WRITE = 0x18; // read from input source and write to pipe sink 51*ec779b8eSAndroid Build Coastguard Worker 52*ec779b8eSAndroid Build Coastguard Worker // never returns NULL; asserts if command is invalid 53*ec779b8eSAndroid Build Coastguard Worker static const char *commandToString(Command command); 54*ec779b8eSAndroid Build Coastguard Worker }; // struct FastCaptureState 55*ec779b8eSAndroid Build Coastguard Worker 56*ec779b8eSAndroid Build Coastguard Worker // No virtuals. 57*ec779b8eSAndroid Build Coastguard Worker static_assert(!std::is_polymorphic_v<FastCaptureState>); 58*ec779b8eSAndroid Build Coastguard Worker 59*ec779b8eSAndroid Build Coastguard Worker } // namespace android 60