1*79330504STreehugger Robot /* 2*79330504STreehugger Robot * Copyright (C) 2007 The Android Open Source Project 3*79330504STreehugger Robot * 4*79330504STreehugger Robot * Licensed under the Apache License, Version 2.0 (the "License"); 5*79330504STreehugger Robot * you may not use this file except in compliance with the License. 6*79330504STreehugger Robot * You may obtain a copy of the License at 7*79330504STreehugger Robot * 8*79330504STreehugger Robot * http://www.apache.org/licenses/LICENSE-2.0 9*79330504STreehugger Robot * 10*79330504STreehugger Robot * Unless required by applicable law or agreed to in writing, software 11*79330504STreehugger Robot * distributed under the License is distributed on an "AS IS" BASIS, 12*79330504STreehugger Robot * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*79330504STreehugger Robot * See the License for the specific language governing permissions and 14*79330504STreehugger Robot * limitations under the License. 15*79330504STreehugger Robot */ 16*79330504STreehugger Robot 17*79330504STreehugger Robot #ifndef ANDROID_AUDIO_HARDWARE_BASE_H 18*79330504STreehugger Robot #define ANDROID_AUDIO_HARDWARE_BASE_H 19*79330504STreehugger Robot 20*79330504STreehugger Robot #include <hardware_legacy/AudioHardwareInterface.h> 21*79330504STreehugger Robot 22*79330504STreehugger Robot #include <system/audio.h> 23*79330504STreehugger Robot 24*79330504STreehugger Robot namespace android_audio_legacy { 25*79330504STreehugger Robot 26*79330504STreehugger Robot // ---------------------------------------------------------------------------- 27*79330504STreehugger Robot 28*79330504STreehugger Robot /** 29*79330504STreehugger Robot * AudioHardwareBase is a convenient base class used for implementing the 30*79330504STreehugger Robot * AudioHardwareInterface interface. 31*79330504STreehugger Robot */ 32*79330504STreehugger Robot class AudioHardwareBase : public AudioHardwareInterface 33*79330504STreehugger Robot { 34*79330504STreehugger Robot public: 35*79330504STreehugger Robot AudioHardwareBase(); ~AudioHardwareBase()36*79330504STreehugger Robot virtual ~AudioHardwareBase() { } 37*79330504STreehugger Robot 38*79330504STreehugger Robot /** 39*79330504STreehugger Robot * setMode is called when the audio mode changes. NORMAL mode is for 40*79330504STreehugger Robot * standard audio playback, RINGTONE when a ringtone is playing, IN_CALL 41*79330504STreehugger Robot * when a telephony call is in progress, IN_COMMUNICATION when a VoIP call is in progress. 42*79330504STreehugger Robot */ 43*79330504STreehugger Robot virtual status_t setMode(int mode); 44*79330504STreehugger Robot 45*79330504STreehugger Robot virtual status_t setParameters(const String8& keyValuePairs); 46*79330504STreehugger Robot virtual String8 getParameters(const String8& keys); 47*79330504STreehugger Robot 48*79330504STreehugger Robot virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount); 49*79330504STreehugger Robot virtual status_t getMasterVolume(float *volume); 50*79330504STreehugger Robot 51*79330504STreehugger Robot /**This method dumps the state of the audio hardware */ 52*79330504STreehugger Robot virtual status_t dumpState(int fd, const Vector<String16>& args); 53*79330504STreehugger Robot 54*79330504STreehugger Robot protected: 55*79330504STreehugger Robot /** returns true if the given mode maps to a telephony or VoIP call is in progress */ isModeInCall(int mode)56*79330504STreehugger Robot virtual bool isModeInCall(int mode) 57*79330504STreehugger Robot { return ((mode == AudioSystem::MODE_IN_CALL) 58*79330504STreehugger Robot || (mode == AudioSystem::MODE_IN_COMMUNICATION)); }; 59*79330504STreehugger Robot /** returns true if a telephony or VoIP call is in progress */ isInCall()60*79330504STreehugger Robot virtual bool isInCall() { return isModeInCall(mMode); }; 61*79330504STreehugger Robot int mMode; 62*79330504STreehugger Robot }; 63*79330504STreehugger Robot 64*79330504STreehugger Robot }; // namespace android 65*79330504STreehugger Robot 66*79330504STreehugger Robot #endif // ANDROID_AUDIO_HARDWARE_BASE_H 67