blob: bf63cc5e2e47c8e63abafc5480649e3bceafb21b [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/* //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
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; }
37 virtual uint32_t latency() const { return 0; }
38 virtual status_t setVolume(float volume) { 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};
43
44class AudioStreamInStub : public AudioStreamIn {
45public:
46 virtual status_t set(int format, int channelCount, uint32_t sampleRate, AudioSystem::audio_in_acoustics acoustics);
47 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);
54 virtual status_t standby() { return NO_ERROR; }
55};
56
57class AudioHardwareStub : public AudioHardwareBase
58{
59public:
60 AudioHardwareStub();
61 virtual ~AudioHardwareStub();
62 virtual status_t initCheck();
63 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,
77 uint32_t sampleRate=0,
78 status_t *status=0);
79
80 virtual AudioStreamIn* openInputStream(
Dave Sparksad216e52009-05-19 14:38:46 -070081 int inputSource,
82 int format,
83 int channelCount,
84 uint32_t sampleRate,
85 status_t *status,
86 AudioSystem::audio_in_acoustics acoustics);
87
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088protected:
89 virtual status_t doRouting() { return NO_ERROR; }
90 virtual status_t dump(int fd, const Vector<String16>& args);
91
92 bool mMicMute;
93private:
94 status_t dumpInternals(int fd, const Vector<String16>& args);
95};
96
97// ----------------------------------------------------------------------------
98
99}; // namespace android
100
101#endif // ANDROID_AUDIO_HARDWARE_STUB_H