1 /* //device/servers/AudioFlinger/AudioHardwareStub.h 2 ** 3 ** Copyright 2007, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #ifndef ANDROID_AUDIO_HARDWARE_STUB_H 19 #define ANDROID_AUDIO_HARDWARE_STUB_H 20 21 #include <stdint.h> 22 #include <sys/types.h> 23 24 #include <hardware_legacy/AudioHardwareBase.h> 25 26 namespace android_audio_legacy { 27 28 // ---------------------------------------------------------------------------- 29 30 class AudioStreamOutStub : public AudioStreamOut { 31 public: 32 virtual status_t set(int *pFormat, uint32_t *pChannels, uint32_t *pRate); 33 virtual uint32_t sampleRate() const { return 44100; } 34 virtual size_t bufferSize() const { return 4096; } 35 virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; } 36 virtual int format() const { return AudioSystem::PCM_16_BIT; } 37 virtual uint32_t latency() const { return 0; } 38 virtual status_t setVolume(float left, float right) { return NO_ERROR; } 39 virtual ssize_t write(const void* buffer, size_t bytes); 40 virtual status_t standby(); 41 virtual status_t dump(int fd, const Vector<String16>& args); 42 virtual status_t setParameters(const String8& keyValuePairs) { return NO_ERROR;} 43 virtual String8 getParameters(const String8& keys); 44 virtual status_t getRenderPosition(uint32_t *dspFrames); 45 }; 46 47 class AudioStreamInStub : public AudioStreamIn { 48 public: 49 virtual status_t set(int *pFormat, uint32_t *pChannels, uint32_t *pRate, AudioSystem::audio_in_acoustics acoustics); 50 virtual uint32_t sampleRate() const { return 8000; } 51 virtual size_t bufferSize() const { return 320; } 52 virtual uint32_t channels() const { return AudioSystem::CHANNEL_IN_MONO; } 53 virtual int format() const { return AudioSystem::PCM_16_BIT; } 54 virtual status_t setGain(float gain) { return NO_ERROR; } 55 virtual ssize_t read(void* buffer, ssize_t bytes); 56 virtual status_t dump(int fd, const Vector<String16>& args); 57 virtual status_t standby() { return NO_ERROR; } 58 virtual status_t setParameters(const String8& keyValuePairs) { return NO_ERROR;} 59 virtual String8 getParameters(const String8& keys); 60 virtual unsigned int getInputFramesLost() const { return 0; } 61 virtual status_t addAudioEffect(effect_handle_t effect) { return NO_ERROR; } 62 virtual status_t removeAudioEffect(effect_handle_t effect) { return NO_ERROR; } 63 }; 64 65 class AudioHardwareStub : public AudioHardwareBase 66 { 67 public: 68 AudioHardwareStub(); 69 virtual ~AudioHardwareStub(); 70 virtual status_t initCheck(); 71 virtual status_t setVoiceVolume(float volume); 72 virtual status_t setMasterVolume(float volume); 73 74 // mic mute 75 virtual status_t setMicMute(bool state) { mMicMute = state; return NO_ERROR; } 76 virtual status_t getMicMute(bool* state) { *state = mMicMute ; return NO_ERROR; } 77 78 // create I/O streams 79 virtual AudioStreamOut* openOutputStream( 80 uint32_t devices, 81 int *format=0, 82 uint32_t *channels=0, 83 uint32_t *sampleRate=0, 84 status_t *status=0); 85 virtual void closeOutputStream(AudioStreamOut* out); 86 87 virtual AudioStreamIn* openInputStream( 88 uint32_t devices, 89 int *format, 90 uint32_t *channels, 91 uint32_t *sampleRate, 92 status_t *status, 93 AudioSystem::audio_in_acoustics acoustics); 94 virtual void closeInputStream(AudioStreamIn* in); 95 96 protected: 97 virtual status_t dump(int fd, const Vector<String16>& args); 98 99 bool mMicMute; 100 private: 101 status_t dumpInternals(int fd, const Vector<String16>& args); 102 }; 103 104 // ---------------------------------------------------------------------------- 105 106 }; // namespace android 107 108 #endif // ANDROID_AUDIO_HARDWARE_STUB_H 109