OSDN Git Service

Wifi-HAL: New NAN Discovery engine changes
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / AudioHardwareBase.h
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 #include <system/audio.h>
23
24 namespace android_audio_legacy {
25
26 // ----------------------------------------------------------------------------
27
28 /**
29  * AudioHardwareBase is a convenient base class used for implementing the
30  * AudioHardwareInterface interface.
31  */
32 class AudioHardwareBase : public AudioHardwareInterface
33 {
34 public:
35                         AudioHardwareBase();
36     virtual             ~AudioHardwareBase() { }
37
38     /**
39      * setMode is called when the audio mode changes. NORMAL mode is for
40      * standard audio playback, RINGTONE when a ringtone is playing, IN_CALL
41      * when a telephony call is in progress, IN_COMMUNICATION when a VoIP call is in progress.
42      */
43     virtual status_t    setMode(int mode);
44
45     virtual status_t    setParameters(const String8& keyValuePairs);
46     virtual String8     getParameters(const String8& keys);
47
48     virtual  size_t     getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
49     virtual status_t    getMasterVolume(float *volume);
50
51     /**This method dumps the state of the audio hardware */
52     virtual status_t dumpState(int fd, const Vector<String16>& args);
53
54 protected:
55     /** returns true if the given mode maps to a telephony or VoIP call is in progress */
56     virtual bool     isModeInCall(int mode)
57                         { return ((mode == AudioSystem::MODE_IN_CALL)
58                                 || (mode == AudioSystem::MODE_IN_COMMUNICATION)); };
59     /** returns true if a telephony or VoIP call is in progress */
60     virtual bool     isInCall() { return isModeInCall(mMode); };
61     int              mMode;
62 };
63
64 }; // namespace android
65
66 #endif // ANDROID_AUDIO_HARDWARE_BASE_H