The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 { |
| 27 | |
| 28 | // ---------------------------------------------------------------------------- |
| 29 | |
| 30 | class AudioStreamOutStub : public AudioStreamOut { |
| 31 | public: |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 32 | virtual status_t set(int *pFormat, uint32_t *pChannels, uint32_t *pRate); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | virtual uint32_t sampleRate() const { return 44100; } |
| 34 | virtual size_t bufferSize() const { return 4096; } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 35 | virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | virtual int format() const { return AudioSystem::PCM_16_BIT; } |
| 37 | virtual uint32_t latency() const { return 0; } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 38 | virtual status_t setVolume(float left, float right) { return NO_ERROR; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 42 | virtual status_t setParameters(const String8& keyValuePairs) { return NO_ERROR;} |
Eric Laurent | ab19b21 | 2009-08-04 06:17:43 -0700 | [diff] [blame] | 43 | virtual String8 getParameters(const String8& keys); |
Eric Laurent | 0986e79 | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 44 | virtual status_t getRenderPosition(uint32_t *dspFrames); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | class AudioStreamInStub : public AudioStreamIn { |
| 48 | public: |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 49 | virtual status_t set(int *pFormat, uint32_t *pChannels, uint32_t *pRate, AudioSystem::audio_in_acoustics acoustics); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | virtual uint32_t sampleRate() const { return 8000; } |
| 51 | virtual size_t bufferSize() const { return 320; } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 52 | virtual uint32_t channels() const { return AudioSystem::CHANNEL_IN_MONO; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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; } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 58 | virtual status_t setParameters(const String8& keyValuePairs) { return NO_ERROR;} |
Eric Laurent | ab19b21 | 2009-08-04 06:17:43 -0700 | [diff] [blame] | 59 | virtual String8 getParameters(const String8& keys); |
Eric Laurent | 47d0a92 | 2010-02-26 02:47:27 -0800 | [diff] [blame^] | 60 | virtual unsigned int getInputFramesLost() const { return 0; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | class AudioHardwareStub : public AudioHardwareBase |
| 64 | { |
| 65 | public: |
| 66 | AudioHardwareStub(); |
| 67 | virtual ~AudioHardwareStub(); |
| 68 | virtual status_t initCheck(); |
| 69 | virtual status_t setVoiceVolume(float volume); |
| 70 | virtual status_t setMasterVolume(float volume); |
| 71 | |
| 72 | // mic mute |
| 73 | virtual status_t setMicMute(bool state) { mMicMute = state; return NO_ERROR; } |
| 74 | virtual status_t getMicMute(bool* state) { *state = mMicMute ; return NO_ERROR; } |
| 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | // create I/O streams |
| 77 | virtual AudioStreamOut* openOutputStream( |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 78 | uint32_t devices, |
| 79 | int *format=0, |
| 80 | uint32_t *channels=0, |
| 81 | uint32_t *sampleRate=0, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | status_t *status=0); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 83 | virtual void closeOutputStream(AudioStreamOut* out); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
| 85 | virtual AudioStreamIn* openInputStream( |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 86 | uint32_t devices, |
| 87 | int *format, |
| 88 | uint32_t *channels, |
| 89 | uint32_t *sampleRate, |
Dave Sparks | ad216e5 | 2009-05-19 14:38:46 -0700 | [diff] [blame] | 90 | status_t *status, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 91 | AudioSystem::audio_in_acoustics acoustics); |
| 92 | virtual void closeInputStream(AudioStreamIn* in); |
Dave Sparks | ad216e5 | 2009-05-19 14:38:46 -0700 | [diff] [blame] | 93 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | protected: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 96 | |
| 97 | bool mMicMute; |
| 98 | private: |
| 99 | status_t dumpInternals(int fd, const Vector<String16>& args); |
| 100 | }; |
| 101 | |
| 102 | // ---------------------------------------------------------------------------- |
| 103 | |
| 104 | }; // namespace android |
| 105 | |
| 106 | #endif // ANDROID_AUDIO_HARDWARE_STUB_H |