2008-10-21 14:00:00 +00:00
|
|
|
/*
|
|
|
|
**
|
|
|
|
** Copyright 2007, The Android Open Source Project
|
|
|
|
**
|
2008-12-18 02:05:43 +00:00
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
2008-10-21 14:00:00 +00:00
|
|
|
**
|
2008-12-18 02:05:43 +00:00
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
2008-10-21 14:00:00 +00:00
|
|
|
**
|
2008-12-18 02:05:43 +00:00
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
2008-10-21 14:00:00 +00:00
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_AUDIO_HARDWARE_GENERIC_H
|
|
|
|
#define ANDROID_AUDIO_HARDWARE_GENERIC_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <utils/threads.h>
|
|
|
|
|
2009-01-16 00:12:10 +00:00
|
|
|
#include <hardware_legacy/AudioHardwareBase.h>
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class AudioHardwareGeneric;
|
|
|
|
|
|
|
|
class AudioStreamOutGeneric : public AudioStreamOut {
|
|
|
|
public:
|
|
|
|
AudioStreamOutGeneric() : mAudioHardware(0), mFd(-1) {}
|
|
|
|
virtual ~AudioStreamOutGeneric();
|
|
|
|
|
|
|
|
virtual status_t set(
|
|
|
|
AudioHardwareGeneric *hw,
|
|
|
|
int mFd,
|
|
|
|
int format,
|
|
|
|
int channelCount,
|
|
|
|
uint32_t sampleRate);
|
|
|
|
|
|
|
|
virtual uint32_t sampleRate() const { return 44100; }
|
|
|
|
virtual size_t bufferSize() const { return 4096; }
|
|
|
|
virtual int channelCount() const { return 2; }
|
|
|
|
virtual int format() const { return AudioSystem::PCM_16_BIT; }
|
2008-12-18 02:05:43 +00:00
|
|
|
virtual uint32_t latency() const { return 0; }
|
2008-10-21 14:00:00 +00:00
|
|
|
virtual status_t setVolume(float volume) { return INVALID_OPERATION; }
|
|
|
|
virtual ssize_t write(const void* buffer, size_t bytes);
|
2009-01-10 01:51:23 +00:00
|
|
|
virtual status_t standby();
|
2008-10-21 14:00:00 +00:00
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AudioHardwareGeneric *mAudioHardware;
|
|
|
|
Mutex mLock;
|
|
|
|
int mFd;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AudioStreamInGeneric : public AudioStreamIn {
|
|
|
|
public:
|
|
|
|
AudioStreamInGeneric() : mAudioHardware(0), mFd(-1) {}
|
|
|
|
virtual ~AudioStreamInGeneric();
|
|
|
|
|
|
|
|
virtual status_t set(
|
|
|
|
AudioHardwareGeneric *hw,
|
|
|
|
int mFd,
|
|
|
|
int format,
|
|
|
|
int channelCount,
|
|
|
|
uint32_t sampleRate);
|
|
|
|
|
|
|
|
uint32_t sampleRate() const { return 8000; }
|
|
|
|
virtual size_t bufferSize() const { return 320; }
|
|
|
|
virtual int channelCount() const { return 1; }
|
|
|
|
virtual int format() const { return AudioSystem::PCM_16_BIT; }
|
|
|
|
virtual status_t setGain(float gain) { return INVALID_OPERATION; }
|
|
|
|
virtual ssize_t read(void* buffer, ssize_t bytes);
|
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
2008-12-18 02:05:43 +00:00
|
|
|
virtual status_t standby() { return NO_ERROR; }
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
AudioHardwareGeneric *mAudioHardware;
|
|
|
|
Mutex mLock;
|
|
|
|
int mFd;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-18 02:05:43 +00:00
|
|
|
class AudioHardwareGeneric : public AudioHardwareBase
|
2008-10-21 14:00:00 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AudioHardwareGeneric();
|
|
|
|
virtual ~AudioHardwareGeneric();
|
|
|
|
virtual status_t initCheck();
|
|
|
|
virtual status_t setVoiceVolume(float volume);
|
|
|
|
virtual status_t setMasterVolume(float volume);
|
|
|
|
|
|
|
|
// mic mute
|
|
|
|
virtual status_t setMicMute(bool state);
|
|
|
|
virtual status_t getMicMute(bool* state);
|
|
|
|
|
|
|
|
virtual status_t setParameter(const char* key, const char* value)
|
|
|
|
{ return NO_ERROR; }
|
|
|
|
|
|
|
|
// create I/O streams
|
|
|
|
virtual AudioStreamOut* openOutputStream(
|
|
|
|
int format=0,
|
|
|
|
int channelCount=0,
|
2008-12-18 02:05:43 +00:00
|
|
|
uint32_t sampleRate=0,
|
|
|
|
status_t *status=0);
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
virtual AudioStreamIn* openInputStream(
|
|
|
|
int format,
|
|
|
|
int channelCount,
|
2008-12-18 02:05:43 +00:00
|
|
|
uint32_t sampleRate,
|
|
|
|
status_t *status);
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
void closeOutputStream(AudioStreamOutGeneric* out);
|
|
|
|
void closeInputStream(AudioStreamInGeneric* in);
|
|
|
|
protected:
|
|
|
|
virtual status_t doRouting() { return NO_ERROR; }
|
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
|
|
|
|
|
|
|
private:
|
|
|
|
status_t dumpInternals(int fd, const Vector<String16>& args);
|
2008-12-18 02:05:43 +00:00
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
Mutex mLock;
|
|
|
|
AudioStreamOutGeneric *mOutput;
|
|
|
|
AudioStreamInGeneric *mInput;
|
|
|
|
int mFd;
|
|
|
|
bool mMicMute;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_AUDIO_HARDWARE_GENERIC_H
|