1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/* //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>
#include <utils/String8.h>
#include <utils/SortedVector.h>
#include <hardware_legacy/AudioHardwareBase.h>
namespace android {
#define AUDIO_DUMP_WAVE_HDR_SIZE 44
class AudioDumpInterface;
class AudioStreamOutDump : public AudioStreamOut {
public:
AudioStreamOutDump(AudioDumpInterface *interface,
int id,
AudioStreamOut* finalStream,
uint32_t devices,
int format,
uint32_t channels,
uint32_t sampleRate);
~AudioStreamOutDump();
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);
virtual status_t standby();
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys);
virtual status_t dump(int fd, const Vector<String16>& args);
void Close(void);
AudioStreamOut* finalStream() { return mFinalStream; }
uint32_t device() { return mDevice; }
int getId() { return mId; }
virtual status_t getRenderPosition(uint32_t *dspFrames);
private:
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;
AudioStreamOut *mFinalStream;
FILE *mFile; // output file
int mFileCount;
};
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);
virtual unsigned int getInputFramesLost() const;
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 *mFile; // output file
int mFileCount;
};
class AudioDumpInterface : public AudioHardwareBase
{
public:
AudioDumpInterface(AudioHardwareInterface* hw);
virtual AudioStreamOut* openOutputStream(
uint32_t devices,
int *format=0,
uint32_t *channels=0,
uint32_t *sampleRate=0,
status_t *status=0);
virtual void closeOutputStream(AudioStreamOut* out);
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);}
virtual status_t setMode(int mode);
// mic mute
virtual status_t setMicMute(bool state)
{return mFinalInterface->setMicMute(state);}
virtual status_t getMicMute(bool* state)
{return mFinalInterface->getMicMute(state);}
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys);
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
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);
virtual status_t dump(int fd, const Vector<String16>& args) { return mFinalInterface->dumpState(fd, args); }
String8 fileName() const { return mFileName; }
protected:
AudioHardwareInterface *mFinalInterface;
SortedVector<AudioStreamOutDump *> mOutputs;
SortedVector<AudioStreamInDump *> mInputs;
Mutex mLock;
String8 mPolicyCommands;
String8 mFileName;
};
}; // namespace android
#endif // ANDROID_AUDIO_DUMP_INTERFACE_H
|