blob: d40642465b8a8e5f7732d55557b9c697a6de1f61 [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/* //device/servers/AudioFlinger/AudioHardwareStub.h
2**
3** Copyright 2007, The Android Open Source Project
4**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -08005** 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
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07008**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -08009** http://www.apache.org/licenses/LICENSE-2.0
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070010**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080011** 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
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070015** 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
The Android Open Source Project8a7a6752009-01-15 16:12:10 -080024#include <hardware_legacy/AudioHardwareBase.h>
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070025
26namespace android {
27
28// ----------------------------------------------------------------------------
29
30class AudioStreamOutStub : public AudioStreamOut {
31public:
32 virtual status_t set(int format, int channelCount, uint32_t sampleRate);
33 virtual uint32_t sampleRate() const { return 44100; }
34 virtual size_t bufferSize() const { return 4096; }
35 virtual int channelCount() const { return 2; }
36 virtual int format() const { return AudioSystem::PCM_16_BIT; }
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080037 virtual uint32_t latency() const { return 0; }
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070038 virtual status_t setVolume(float volume) { return NO_ERROR; }
39 virtual ssize_t write(const void* buffer, size_t bytes);
The Android Open Source Project27629322009-01-09 17:51:23 -080040 virtual status_t standby();
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070041 virtual status_t dump(int fd, const Vector<String16>& args);
42};
43
44class AudioStreamInStub : public AudioStreamIn {
45public:
The Android Open Source Projectd2bd26d2009-02-19 10:57:31 -080046 virtual status_t set(int format, int channelCount, uint32_t sampleRate, AudioSystem::audio_in_acoustics acoustics);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070047 virtual uint32_t sampleRate() const { return 8000; }
48 virtual size_t bufferSize() const { return 320; }
49 virtual int channelCount() const { return 1; }
50 virtual int format() const { return AudioSystem::PCM_16_BIT; }
51 virtual status_t setGain(float gain) { return NO_ERROR; }
52 virtual ssize_t read(void* buffer, ssize_t bytes);
53 virtual status_t dump(int fd, const Vector<String16>& args);
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080054 virtual status_t standby() { return NO_ERROR; }
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070055};
56
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080057class AudioHardwareStub : public AudioHardwareBase
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070058{
59public:
60 AudioHardwareStub();
61 virtual ~AudioHardwareStub();
62 virtual status_t initCheck();
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070063 virtual status_t setVoiceVolume(float volume);
64 virtual status_t setMasterVolume(float volume);
65
66 // mic mute
67 virtual status_t setMicMute(bool state) { mMicMute = state; return NO_ERROR; }
68 virtual status_t getMicMute(bool* state) { *state = mMicMute ; return NO_ERROR; }
69
70 virtual status_t setParameter(const char* key, const char* value)
71 { return NO_ERROR; }
72
73 // create I/O streams
74 virtual AudioStreamOut* openOutputStream(
75 int format=0,
76 int channelCount=0,
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080077 uint32_t sampleRate=0,
78 status_t *status=0);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070079
80 virtual AudioStreamIn* openInputStream(
81 int format,
82 int channelCount,
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080083 uint32_t sampleRate,
The Android Open Source Projectd2bd26d2009-02-19 10:57:31 -080084 status_t *status,
85 AudioSystem::audio_in_acoustics acoustics);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070086
87protected:
88 virtual status_t doRouting() { return NO_ERROR; }
89 virtual status_t dump(int fd, const Vector<String16>& args);
90
91 bool mMicMute;
92private:
93 status_t dumpInternals(int fd, const Vector<String16>& args);
94};
95
96// ----------------------------------------------------------------------------
97
98}; // namespace android
99
100#endif // ANDROID_AUDIO_HARDWARE_STUB_H