17 #ifndef ANDROID_AUDIO_HARDWARE_INTERFACE_H
18 #define ANDROID_AUDIO_HARDWARE_INTERFACE_H
21 #include <sys/types.h>
23 #include <utils/Errors.h>
24 #include <utils/Vector.h>
25 #include <utils/String16.h>
26 #include <utils/String8.h>
28 #include <media/IAudioFlinger.h>
29 #include <hardware_legacy/AudioSystemLegacy.h>
31 #include <system/audio.h>
32 #include <hardware/audio.h>
34 #include <cutils/bitops.h>
36 namespace android_audio_legacy {
37 using android::Vector;
38 using android::String16;
39 using android::String8;
61 virtual uint32_t
channels()
const = 0;
67 virtual int format()
const = 0;
72 uint32_t
frameSize()
const {
return popcount(
channels())*((
format()==AUDIO_FORMAT_PCM_16_BIT)?
sizeof(int16_t):
sizeof(int8_t)); }
77 virtual uint32_t
latency()
const = 0;
86 virtual status_t
setVolume(
float left,
float right) = 0;
89 virtual ssize_t
write(
const void* buffer,
size_t bytes) = 0;
98 virtual status_t
dump(
int fd,
const Vector<String16>& args) = 0;
106 virtual status_t
setParameters(
const String8& keyValuePairs) = 0;
130 virtual uint32_t
channels()
const = 0;
136 virtual int format()
const = 0;
141 uint32_t
frameSize()
const {
return AudioSystem::popCount(
channels())*((
format()==AudioSystem::PCM_16_BIT)?
sizeof(int16_t):
sizeof(int8_t)); }
145 virtual status_t
setGain(
float gain) = 0;
148 virtual ssize_t
read(
void* buffer, ssize_t bytes) = 0;
151 virtual status_t
dump(
int fd,
const Vector<String16>& args) = 0;
157 virtual status_t
standby() = 0;
165 virtual status_t
setParameters(
const String8& keyValuePairs) = 0;
217 virtual status_t
setMode(
int mode) = 0;
224 virtual status_t
setParameters(
const String8& keyValuePairs) = 0;
229 virtual size_t getInputBufferSize(uint32_t sampleRate,
int format,
int channelCount) = 0;
235 uint32_t *channels=0,
236 uint32_t *sampleRate=0,
237 status_t *status=0) = 0;
244 uint32_t *sampleRate,
246 AudioSystem::audio_in_acoustics acoustics) = 0;
250 virtual status_t
dumpState(
int fd,
const Vector<String16>& args) = 0;
256 virtual status_t
dump(
int fd,
const Vector<String16>& args) = 0;
265 #endif // ANDROID_AUDIO_HARDWARE_INTERFACE_H
virtual ~AudioStreamOut()=0
AudioHardwareInterface.h defines the interface to the audio hardware abstraction layer.
uint32_t frameSize() const
return the frame size (number of bytes per sample).
virtual status_t setParameters(const String8 &keyValuePairs)=0
virtual unsigned int getInputFramesLost() const =0
virtual status_t removeAudioEffect(effect_handle_t effect)=0
virtual int format() const =0
return audio format in 8bit or 16bit PCM format - eg.
virtual uint32_t sampleRate() const =0
return audio sampling rate in hz - eg.
virtual int format() const =0
return audio format in 8bit or 16bit PCM format - eg.
virtual status_t setGain(float gain)=0
set the input gain for the audio driver.
AudioHardwareInterface * createAudioHardware(void)
virtual status_t getRenderPosition(uint32_t *dspFrames)=0
virtual String8 getParameters(const String8 &keys)=0
virtual status_t setParameters(const String8 &keyValuePairs)=0
AudioStreamOut is the abstraction interface for the audio output hardware.
virtual ~AudioStreamIn()=0
virtual status_t dump(int fd, const Vector< String16 > &args)=0
virtual status_t setMode(int mode)=0
setMode is called when the audio mode changes.
virtual uint32_t latency() const =0
return the audio hardware driver latency in milli seconds.
virtual status_t standby()=0
Put the audio hardware input into standby mode.
virtual status_t addAudioEffect(effect_handle_t effect)=0
virtual status_t setVoiceVolume(float volume)=0
set the audio volume of a voice call.
virtual uint32_t channels() const =0
returns the output channel nask
virtual status_t setMasterVolume(float volume)=0
set the audio volume for all audio activities other than voice call.
virtual status_t getMicMute(bool *state)=0
virtual String8 getParameters(const String8 &keys)=0
virtual size_t bufferSize() const =0
return the input buffer size allowed by audio driver
virtual status_t dumpState(int fd, const Vector< String16 > &args)=0
This method dumps the state of the audio hardware.
virtual status_t setParameters(const String8 &keyValuePairs)=0
virtual uint32_t channels() const =0
return input channel mask
virtual status_t dump(int fd, const Vector< String16 > &args)=0
dump the state of the audio output device
virtual void closeOutputStream(AudioStreamOut *out)=0
static AudioHardwareInterface * create()
virtual status_t initCheck()=0
check to see if the audio hardware interface has been initialized.
virtual AudioStreamIn * openInputStream(uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status, AudioSystem::audio_in_acoustics acoustics)=0
This method creates and opens the audio hardware input stream.
virtual status_t setVolume(float left, float right)=0
Use this method in situations where audio mixing is done in the hardware.
virtual size_t bufferSize() const =0
returns size of output buffer - eg.
virtual AudioStreamOut * openOutputStream(uint32_t devices, int *format=0, uint32_t *channels=0, uint32_t *sampleRate=0, status_t *status=0)=0
This method creates and opens the audio hardware output stream.
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount)=0
virtual ssize_t read(void *buffer, ssize_t bytes)=0
read audio buffer in from audio driver
AudioStreamIn is the abstraction interface for the audio input hardware.
virtual void closeInputStream(AudioStreamIn *in)=0
virtual ssize_t write(const void *buffer, size_t bytes)=0
write audio buffer to driver.
virtual status_t setMicMute(bool state)=0
virtual uint32_t sampleRate() const =0
return audio sampling rate in hz - eg.
virtual String8 getParameters(const String8 &keys)=0
virtual ~AudioHardwareInterface()
virtual status_t dump(int fd, const Vector< String16 > &args)=0
dump the state of the audio input device
uint32_t frameSize() const
return the frame size (number of bytes per sample).
virtual status_t standby()=0
Put the audio hardware output into standby mode.