1 /* 2 * Copyright (C) 2007 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_HARDWARE_BASE_H 18 #define ANDROID_AUDIO_HARDWARE_BASE_H 19 20 #include "hardware_legacy/AudioHardwareInterface.h" 21 22 23 namespace android { 24 25 // ---------------------------------------------------------------------------- 26 27 /** 28 * AudioHardwareBase is a convenient base class used for implementing the 29 * AudioHardwareInterface interface. 30 */ 31 class AudioHardwareBase : public AudioHardwareInterface 32 { 33 public: 34 AudioHardwareBase(); ~AudioHardwareBase()35 virtual ~AudioHardwareBase() { } 36 37 /** 38 * Audio routing methods. Routes defined in include/hardware_legacy/AudioSystem.h. 39 * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH 40 * | ROUTE_HEADSET) 41 * 42 * setRouting sets the routes for a mode. This is called at startup. It is 43 * also called when a new device is connected, such as a wired headset is 44 * plugged in or a Bluetooth headset is paired. 45 */ 46 virtual status_t setRouting(int mode, uint32_t routes); 47 48 virtual status_t getRouting(int mode, uint32_t* routes); 49 50 /** 51 * setMode is called when the audio mode changes. NORMAL mode is for 52 * standard audio playback, RINGTONE when a ringtone is playing, and IN_CALL 53 * when a call is in progress. 54 */ 55 virtual status_t setMode(int mode); 56 virtual status_t getMode(int* mode); 57 58 // Temporary interface, do not use 59 // TODO: Replace with a more generic key:value get/set mechanism 60 virtual status_t setParameter(const char* key, const char* value); 61 62 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount); 63 64 /**This method dumps the state of the audio hardware */ 65 virtual status_t dumpState(int fd, const Vector<String16>& args); 66 67 protected: 68 int mMode; 69 uint32_t mRoutes[AudioSystem::NUM_MODES]; 70 }; 71 72 }; // namespace android 73 74 #endif // ANDROID_AUDIO_HARDWARE_BASE_H 75