2009-03-04 03:31:44 +00:00
|
|
|
/* //device/servers/AudioFlinger/AudioDumpInterface.h
|
|
|
|
**
|
|
|
|
** Copyright 2008, The Android Open Source Project
|
|
|
|
**
|
|
|
|
** 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
|
|
|
|
**
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
**
|
|
|
|
** 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
|
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_AUDIO_DUMP_INTERFACE_H
|
|
|
|
#define ANDROID_AUDIO_DUMP_INTERFACE_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
2009-07-17 19:17:14 +00:00
|
|
|
#include <utils/String8.h>
|
|
|
|
#include <utils/SortedVector.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
#include <hardware_legacy/AudioHardwareBase.h>
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
#define AUDIO_DUMP_WAVE_HDR_SIZE 44
|
|
|
|
|
|
|
|
class AudioDumpInterface;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
class AudioStreamOutDump : public AudioStreamOut {
|
|
|
|
public:
|
2009-07-17 19:17:14 +00:00
|
|
|
AudioStreamOutDump(AudioDumpInterface *interface,
|
|
|
|
int id,
|
|
|
|
AudioStreamOut* finalStream,
|
|
|
|
uint32_t devices,
|
|
|
|
int format,
|
|
|
|
uint32_t channels,
|
|
|
|
uint32_t sampleRate);
|
2009-03-04 03:31:44 +00:00
|
|
|
~AudioStreamOutDump();
|
2009-07-17 19:17:14 +00:00
|
|
|
|
|
|
|
virtual ssize_t write(const void* buffer, size_t bytes);
|
|
|
|
virtual uint32_t sampleRate() const;
|
|
|
|
virtual size_t bufferSize() const;
|
|
|
|
virtual uint32_t channels() const;
|
|
|
|
virtual int format() const;
|
|
|
|
virtual uint32_t latency() const;
|
|
|
|
virtual status_t setVolume(float left, float right);
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual status_t standby();
|
2009-07-17 19:17:14 +00:00
|
|
|
virtual status_t setParameters(const String8& keyValuePairs);
|
|
|
|
virtual String8 getParameters(const String8& keys);
|
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
2009-03-04 03:31:44 +00:00
|
|
|
void Close(void);
|
2009-07-17 19:17:14 +00:00
|
|
|
AudioStreamOut* finalStream() { return mFinalStream; }
|
|
|
|
uint32_t device() { return mDevice; }
|
2009-08-04 14:29:18 +00:00
|
|
|
int getId() { return mId; }
|
2010-01-20 01:37:09 +00:00
|
|
|
virtual status_t getRenderPosition(uint32_t *dspFrames);
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
private:
|
2009-07-17 19:17:14 +00:00
|
|
|
AudioDumpInterface *mInterface;
|
|
|
|
int mId;
|
|
|
|
uint32_t mSampleRate; //
|
|
|
|
uint32_t mFormat; //
|
|
|
|
uint32_t mChannels; // output configuration
|
|
|
|
uint32_t mLatency; //
|
|
|
|
uint32_t mDevice; // current device this output is routed to
|
|
|
|
size_t mBufferSize;
|
2009-03-04 03:31:44 +00:00
|
|
|
AudioStreamOut *mFinalStream;
|
2009-07-17 19:17:14 +00:00
|
|
|
FILE *mOutFile; // output file
|
|
|
|
int mFileCount;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
class AudioStreamInDump : public AudioStreamIn {
|
|
|
|
public:
|
|
|
|
AudioStreamInDump(AudioDumpInterface *interface,
|
|
|
|
int id,
|
|
|
|
AudioStreamIn* finalStream,
|
|
|
|
uint32_t devices,
|
|
|
|
int format,
|
|
|
|
uint32_t channels,
|
|
|
|
uint32_t sampleRate);
|
|
|
|
~AudioStreamInDump();
|
|
|
|
|
|
|
|
virtual uint32_t sampleRate() const;
|
|
|
|
virtual size_t bufferSize() const;
|
|
|
|
virtual uint32_t channels() const;
|
|
|
|
virtual int format() const;
|
|
|
|
|
|
|
|
virtual status_t setGain(float gain);
|
|
|
|
virtual ssize_t read(void* buffer, ssize_t bytes);
|
|
|
|
virtual status_t standby();
|
|
|
|
virtual status_t setParameters(const String8& keyValuePairs);
|
|
|
|
virtual String8 getParameters(const String8& keys);
|
2010-02-26 10:47:27 +00:00
|
|
|
virtual unsigned int getInputFramesLost() const;
|
2009-07-17 19:17:14 +00:00
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
|
|
|
void Close(void);
|
|
|
|
AudioStreamIn* finalStream() { return mFinalStream; }
|
|
|
|
uint32_t device() { return mDevice; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
AudioDumpInterface *mInterface;
|
|
|
|
int mId;
|
|
|
|
uint32_t mSampleRate; //
|
|
|
|
uint32_t mFormat; //
|
|
|
|
uint32_t mChannels; // output configuration
|
|
|
|
uint32_t mDevice; // current device this output is routed to
|
|
|
|
size_t mBufferSize;
|
|
|
|
AudioStreamIn *mFinalStream;
|
|
|
|
FILE *mInFile; // output file
|
|
|
|
};
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
class AudioDumpInterface : public AudioHardwareBase
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
AudioDumpInterface(AudioHardwareInterface* hw);
|
|
|
|
virtual AudioStreamOut* openOutputStream(
|
2009-07-17 19:17:14 +00:00
|
|
|
uint32_t devices,
|
|
|
|
int *format=0,
|
|
|
|
uint32_t *channels=0,
|
|
|
|
uint32_t *sampleRate=0,
|
2009-03-04 03:31:44 +00:00
|
|
|
status_t *status=0);
|
2009-07-17 19:17:14 +00:00
|
|
|
virtual void closeOutputStream(AudioStreamOut* out);
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual ~AudioDumpInterface();
|
|
|
|
|
|
|
|
virtual status_t initCheck()
|
|
|
|
{return mFinalInterface->initCheck();}
|
|
|
|
virtual status_t setVoiceVolume(float volume)
|
|
|
|
{return mFinalInterface->setVoiceVolume(volume);}
|
|
|
|
virtual status_t setMasterVolume(float volume)
|
|
|
|
{return mFinalInterface->setMasterVolume(volume);}
|
|
|
|
|
|
|
|
// mic mute
|
|
|
|
virtual status_t setMicMute(bool state)
|
|
|
|
{return mFinalInterface->setMicMute(state);}
|
|
|
|
virtual status_t getMicMute(bool* state)
|
|
|
|
{return mFinalInterface->getMicMute(state);}
|
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
virtual status_t setParameters(const String8& keyValuePairs);
|
|
|
|
virtual String8 getParameters(const String8& keys);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
virtual AudioStreamIn* openInputStream(uint32_t devices, int *format, uint32_t *channels,
|
|
|
|
uint32_t *sampleRate, status_t *status, AudioSystem::audio_in_acoustics acoustics);
|
|
|
|
virtual void closeInputStream(AudioStreamIn* in);
|
2009-05-20 01:28:20 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args) { return mFinalInterface->dumpState(fd, args); }
|
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
String8 fileName() const { return mFileName; }
|
2009-03-04 03:31:44 +00:00
|
|
|
protected:
|
|
|
|
|
2009-07-17 19:17:14 +00:00
|
|
|
AudioHardwareInterface *mFinalInterface;
|
|
|
|
SortedVector<AudioStreamOutDump *> mOutputs;
|
|
|
|
bool mFirstHwOutput;
|
|
|
|
SortedVector<AudioStreamInDump *> mInputs;
|
|
|
|
Mutex mLock;
|
|
|
|
String8 mPolicyCommands;
|
|
|
|
String8 mFileName;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_AUDIO_DUMP_INTERFACE_H
|