AudioFlinger.h revision f5aafb209d01ba2ab6cb55d1a12cfc653e2b4be0
165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian/* //device/include/server/AudioFlinger/AudioFlinger.h
265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian**
365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** Copyright 2007, The Android Open Source Project
465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian**
565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** Licensed under the Apache License, Version 2.0 (the "License");
665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** you may not use this file except in compliance with the License.
765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** You may obtain a copy of the License at
865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian**
965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian**     http://www.apache.org/licenses/LICENSE-2.0
1065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian**
1165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** Unless required by applicable law or agreed to in writing, software
1265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** distributed under the License is distributed on an "AS IS" BASIS,
1365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** See the License for the specific language governing permissions and
1565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian** limitations under the License.
1665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian*/
1765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
1865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#ifndef ANDROID_AUDIO_FLINGER_H
1965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define ANDROID_AUDIO_FLINGER_H
2065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <stdint.h>
2265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <sys/types.h>
2365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <limits.h>
2465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
2565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <media/IAudioFlinger.h>
2665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <media/IAudioFlingerClient.h>
2765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <media/IAudioTrack.h>
2865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <media/IAudioRecord.h>
2965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <media/AudioTrack.h>
3065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
3165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/Atomic.h>
3265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/Errors.h>
3365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/threads.h>
3465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/SortedVector.h>
3565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <utils/Vector.h>
3665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
375462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian#include <binder/BinderService.h>
385462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian#include <binder/MemoryDealer.h>
395462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian
4065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include <hardware_legacy/AudioHardwareInterface.h>
4165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
4265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#include "AudioBufferProvider.h"
4365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
4465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopiannamespace android {
4565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
4665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass audio_track_cblk_t;
4765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass effect_param_cblk_t;
4865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass AudioMixer;
4965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass AudioBuffer;
5065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianclass AudioResampler;
5165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian// ----------------------------------------------------------------------------
5465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
5665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
5765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
5965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian// ----------------------------------------------------------------------------
6065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
6165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianstatic const nsecs_t kStandbyTimeInNsecs = seconds(3);
6265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
635462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopianclass AudioFlinger :
645462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian    public BinderService<AudioFlinger>,
655462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian    public BnAudioFlinger
6665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian{
675462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian    friend class BinderService<AudioFlinger>;
6865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianpublic:
695462fc9a38fa8c9dff434cd53fa5fb1782ae3042Mathias Agopian    static char const* getServiceName() { return "media.audio_flinger"; }
7065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
7165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    dump(int fd, const Vector<String16>& args);
7265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
7365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // IAudioFlinger interface
7465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual sp<IAudioTrack> createTrack(
7565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                pid_t pid,
7665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int streamType,
7765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t sampleRate,
7865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int format,
7965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int channelCount,
8065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int frameCount,
8165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t flags,
8265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                const sp<IMemory>& sharedBuffer,
8365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int output,
8465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int *sessionId,
8565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                status_t *status);
8665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
8765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     uint32_t    sampleRate(int output) const;
8865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     int         channelCount(int output) const;
8965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     int         format(int output) const;
9065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     size_t      frameCount(int output) const;
9165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     uint32_t    latency(int output) const;
9265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
9365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setMasterVolume(float value);
9465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setMasterMute(bool muted);
9565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
9665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     float       masterVolume() const;
9765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     bool        masterMute() const;
9865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
9965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setStreamVolume(int stream, float value, int output);
10065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setStreamMute(int stream, bool muted);
10165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
10265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     float       streamVolume(int stream, int output) const;
10365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     bool        streamMute(int stream) const;
10465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
10565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setMode(int mode);
10665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
10765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setMicMute(bool state);
10865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     bool        getMicMute() const;
10965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
11065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     bool        isStreamActive(int stream) const;
11165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
11265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    setParameters(int ioHandle, const String8& keyValuePairs);
11365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     String8     getParameters(int ioHandle, const String8& keys);
11465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
11565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     void        registerClient(const sp<IAudioFlingerClient>& client);
11665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
11765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     size_t      getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
11865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     unsigned int  getInputFramesLost(int ioHandle);
11965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
12065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual int openOutput(uint32_t *pDevices,
12165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t *pSamplingRate,
12265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t *pFormat,
12365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t *pChannels,
12465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t *pLatencyMs,
12565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t flags);
12665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
12765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual int openDuplicateOutput(int output1, int output2);
12865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
12965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t closeOutput(int output);
13065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
13165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t suspendOutput(int output);
13265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
13365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t restoreOutput(int output);
13465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
13565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual int openInput(uint32_t *pDevices,
13665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            uint32_t *pSamplingRate,
13765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            uint32_t *pFormat,
13865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            uint32_t *pChannels,
13965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            uint32_t acoustics);
14065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
14165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t closeInput(int input);
14265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
14365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t setStreamOutput(uint32_t stream, int output);
14465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
14565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t setVoiceVolume(float volume);
14665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
14765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output);
14865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
14965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual int newAudioSessionId();
15065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
15165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t loadEffectLibrary(const char *libPath, int *handle);
15265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
15365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t unloadEffectLibrary(int handle);
15465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
15565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t queryNumberEffects(uint32_t *numEffects);
15665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
15765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t queryEffect(uint32_t index, effect_descriptor_t *descriptor);
15865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
15965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual status_t getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *descriptor);
16065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
16165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual sp<IEffect> createEffect(pid_t pid,
16265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        effect_descriptor_t *pDesc,
16365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        const sp<IEffectClient>& effectClient,
16465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int32_t priority,
16565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int output,
16665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int sessionId,
16765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        status_t *status,
16865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int *id,
16965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int *enabled);
17065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
171de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t moveEffects(int session, int srcOutput, int dstOutput);
17265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
17365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    enum hardware_call_state {
17465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_IDLE = 0,
17565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_INIT,
17665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_OUTPUT_OPEN,
17765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_OUTPUT_CLOSE,
17865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_INPUT_OPEN,
17965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_INPUT_CLOSE,
18065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_STANDBY,
18165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_SET_MASTER_VOLUME,
18265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_GET_ROUTING,
18365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_SET_ROUTING,
18465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_GET_MODE,
18565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_SET_MODE,
18665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_GET_MIC_MUTE,
18765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_HW_SET_MIC_MUTE,
18865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_SET_VOICE_VOLUME,
18965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AUDIO_SET_PARAMETER,
19065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
19165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
19265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // record interface
19365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual sp<IAudioRecord> openRecord(
19465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                pid_t pid,
19565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int input,
19665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t sampleRate,
19765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int format,
19865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int channelCount,
19965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int frameCount,
20065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t flags,
20165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                int *sessionId,
20265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                status_t *status);
20365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
20465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual     status_t    onTransact(
20565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t code,
20665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                const Parcel& data,
20765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                Parcel* reply,
20865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                uint32_t flags);
20965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
21065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                uint32_t    getMode() { return mMode; }
21165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
21265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopianprivate:
21365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            AudioFlinger();
21465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    virtual                 ~AudioFlinger();
21565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
21665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
21765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // Internal dump utilites.
21865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    status_t dumpPermissionDenial(int fd, const Vector<String16>& args);
21965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    status_t dumpClients(int fd, const Vector<String16>& args);
22065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    status_t dumpInternals(int fd, const Vector<String16>& args);
22165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
22265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // --- Client ---
22365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class Client : public RefBase {
22465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
22565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            Client(const sp<AudioFlinger>& audioFlinger, pid_t pid);
22665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~Client();
22765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        const sp<MemoryDealer>&     heap() const;
22865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        pid_t               pid() const { return mPid; }
22965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<AudioFlinger>    audioFlinger() { return mAudioFlinger; }
23065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
23165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
23265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            Client(const Client&);
23365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            Client& operator = (const Client&);
23465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<AudioFlinger>    mAudioFlinger;
23565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<MemoryDealer>    mMemoryDealer;
23665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        pid_t               mPid;
23765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
23865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
23965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // --- Notification Client ---
24065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class NotificationClient : public IBinder::DeathRecipient {
24165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
24265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            NotificationClient(const sp<AudioFlinger>& audioFlinger,
24365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                                const sp<IAudioFlingerClient>& client,
24465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                                pid_t pid);
24565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~NotificationClient();
24665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
24765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                sp<IAudioFlingerClient>    client() { return mClient; }
24865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
24965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                // IBinder::DeathRecipient
25065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                virtual     void        binderDied(const wp<IBinder>& who);
25165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
25265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
25365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            NotificationClient(const NotificationClient&);
25465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            NotificationClient& operator = (const NotificationClient&);
25565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
25665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<AudioFlinger>        mAudioFlinger;
25765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        pid_t                   mPid;
25865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<IAudioFlingerClient> mClient;
25965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
26065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
26165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class TrackHandle;
26265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class RecordHandle;
26365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class RecordThread;
26465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class PlaybackThread;
26565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class MixerThread;
26665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class DirectOutputThread;
26765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class DuplicatingThread;
26865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class Track;
26965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class RecordTrack;
27065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectModule;
27165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectHandle;
27265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectChain;
27365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
27465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class ThreadBase : public Thread {
27565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
27665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        ThreadBase (const sp<AudioFlinger>& audioFlinger, int id);
27765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~ThreadBase();
27865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
27965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t dumpBase(int fd, const Vector<String16>& args);
28065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
28165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // base for record and playback
28265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        class TrackBase : public AudioBufferProvider, public RefBase {
28365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
28465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        public:
28565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            enum track_state {
28665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                IDLE,
28765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                TERMINATED,
28865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                STOPPED,
28965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                RESUMING,
29065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                ACTIVE,
29165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                PAUSING,
29265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                PAUSED
29365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            };
29465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
29565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            enum track_flags {
29665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                STEPSERVER_FAILED = 0x01, //  StepServer could not acquire cblk->lock mutex
29765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                SYSTEM_FLAGS_MASK = 0x0000ffffUL,
29865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                // The upper 16 bits are used for track-specific flags.
29965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            };
30065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
30165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                TrackBase(const wp<ThreadBase>& thread,
30265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<Client>& client,
30365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t sampleRate,
30465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int format,
30565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int channelCount,
30665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int frameCount,
30765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t flags,
30865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<IMemory>& sharedBuffer,
30965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int sessionId);
31065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                ~TrackBase();
31165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
31265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t    start() = 0;
31365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual void        stop() = 0;
31465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<IMemory> getCblk() const;
31565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    audio_track_cblk_t* cblk() const { return mCblk; }
31665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int         sessionId() { return mSessionId; }
31765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
31865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        protected:
31965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class ThreadBase;
32065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class RecordHandle;
32165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class PlaybackThread;
32265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class RecordThread;
32365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class MixerThread;
32465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class DirectOutputThread;
32565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
32665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                TrackBase(const TrackBase&);
32765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                TrackBase& operator = (const TrackBase&);
32865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
32965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer) = 0;
33065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
33165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
33265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int format() const {
33365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return mFormat;
33465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
33565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
33665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int channelCount() const ;
33765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
33865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int sampleRate() const;
33965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
34065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void* getBuffer(uint32_t offset, uint32_t frames) const;
34165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
34265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isStopped() const {
34365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return mState == STOPPED;
34465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
34565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
34665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isTerminated() const {
34765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return mState == TERMINATED;
34865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
34965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
35065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool step();
35165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void reset();
35265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
35365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            wp<ThreadBase>      mThread;
35465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            sp<Client>          mClient;
35565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            sp<IMemory>         mCblkMemory;
35665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            audio_track_cblk_t* mCblk;
35765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void*               mBuffer;
35865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void*               mBufferEnd;
35965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            uint32_t            mFrameCount;
36065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            // we don't really need a lock for these
36165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mState;
36265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mClientTid;
36365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            uint8_t             mFormat;
36465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            uint32_t            mFlags;
36565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mSessionId;
36665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
36765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
36865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        class ConfigEvent {
36965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        public:
37065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            ConfigEvent() : mEvent(0), mParam(0) {}
37165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
37265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int mEvent;
37365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int mParam;
37465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
37565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
37665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint32_t    sampleRate() const;
37765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int         channelCount() const;
37865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int         format() const;
37965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    size_t      frameCount() const;
38065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        wakeUp()    { mWaitWorkCV.broadcast(); }
38165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        exit();
38265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        checkForNewParameters_l() = 0;
38365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    setParameters(const String8& keyValuePairs);
38465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     String8     getParameters(const String8& keys) = 0;
38565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     void        audioConfigChanged_l(int event, int param = 0) = 0;
38665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        sendConfigEvent(int event, int param = 0);
38765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        sendConfigEvent_l(int event, int param = 0);
38865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        processConfigEvents();
38965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int         id() const { return mId;}
39065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        standby() { return mStandby; }
39165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
39265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        mutable     Mutex                   mLock;
39365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
39465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
39565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
39665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class Track;
39765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class TrackBase;
39865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class PlaybackThread;
39965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class MixerThread;
40065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class DirectOutputThread;
40165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class DuplicatingThread;
40265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class RecordThread;
40365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class RecordTrack;
40465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
40565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    Condition               mWaitWorkCV;
40665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<AudioFlinger>        mAudioFlinger;
40765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint32_t                mSampleRate;
40865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    size_t                  mFrameCount;
40965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint32_t                mChannels;
41065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint16_t                mChannelCount;
41165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint16_t                mFrameSize;
41265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int                     mFormat;
41365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    Condition               mParamCond;
41465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    Vector<String8>         mNewParameters;
41565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    status_t                mParamStatus;
41665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    Vector<ConfigEvent *>   mConfigEvents;
41765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool                    mStandby;
41865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int                     mId;
41965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool                    mExiting;
42065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
42165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
42265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // --- PlaybackThread ---
42365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class PlaybackThread : public ThreadBase {
42465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
42565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
42665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        enum type {
42765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            MIXER,
42865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            DIRECT,
42965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            DUPLICATING
43065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
43165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
43265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        enum mixer_state {
43365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            MIXER_IDLE,
43465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            MIXER_TRACKS_ENABLED,
43565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            MIXER_TRACKS_READY
43665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
43765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
43865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // playback track
43965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        class Track : public TrackBase {
44065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        public:
44165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                Track(  const wp<ThreadBase>& thread,
44265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<Client>& client,
44365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int streamType,
44465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t sampleRate,
44565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int format,
44665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int channelCount,
44765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int frameCount,
44865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<IMemory>& sharedBuffer,
44965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int sessionId);
45065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                ~Track();
45165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
45265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        dump(char* buffer, size_t size);
45365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t    start();
45465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual void        stop();
45565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        pause();
45665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
45765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        flush();
45865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        destroy();
45965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        mute(bool);
46065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        setVolume(float left, float right);
46165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int name() const {
46265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        return mName;
46365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    }
46465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
46565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int type() const {
46665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        return mStreamType;
46765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    }
46865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    status_t    attachAuxEffect(int EffectId);
46965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        setAuxBuffer(int EffectId, int32_t *buffer);
47065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int32_t     *auxBuffer() { return mAuxBuffer; }
47165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        setMainBuffer(int16_t *buffer) { mMainBuffer = buffer; }
47265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int16_t     *mainBuffer() { return mMainBuffer; }
47365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int         auxEffectId() { return mAuxEffectId; }
47465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
47565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
47665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        protected:
47765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class ThreadBase;
47865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class AudioFlinger;
47965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class TrackHandle;
48065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class PlaybackThread;
48165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class MixerThread;
48265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class DirectOutputThread;
48365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
48465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                Track(const Track&);
48565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                Track& operator = (const Track&);
48665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
48765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
48865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isMuted() { return mMute; }
48965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isPausing() const {
49065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return mState == PAUSING;
49165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
49265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isPaused() const {
49365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return mState == PAUSED;
49465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
49565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isReady() const;
49665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void setPaused() { mState = PAUSED; }
49765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void reset();
49865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
49965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool isOutputTrack() const {
50065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                return (mStreamType == AudioSystem::NUM_STREAM_TYPES);
50165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
50265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
50365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            // we don't really need a lock for these
50465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            float               mVolume[2];
50565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            volatile bool       mMute;
50665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            // FILLED state is used for suppressing volume ramp at begin of playing
50765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            enum {FS_FILLING, FS_FILLED, FS_ACTIVE};
50865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mutable uint8_t     mFillingUpStatus;
50965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int8_t              mRetryCount;
51065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            sp<IMemory>         mSharedBuffer;
51165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool                mResetDone;
51265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mStreamType;
51365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mName;
51465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int16_t             *mMainBuffer;
51565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int32_t             *mAuxBuffer;
51665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            int                 mAuxEffectId;
5178f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent            bool                mHasVolumeController;
51865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };  // end of Track
51965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
52065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
52165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // playback track
52265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        class OutputTrack : public Track {
52365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        public:
52465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
52565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            class Buffer: public AudioBufferProvider::Buffer {
52665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            public:
52765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int16_t *mBuffer;
52865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            };
52965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
53065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                OutputTrack(  const wp<ThreadBase>& thread,
53165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        DuplicatingThread *sourceThread,
53265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t sampleRate,
53365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int format,
53465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int channelCount,
53565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int frameCount);
53665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                ~OutputTrack();
53765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
53865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t    start();
53965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual void        stop();
54065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        write(int16_t* data, uint32_t frames);
54165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        bufferQueueEmpty() { return (mBufferQueue.size() == 0) ? true : false; }
54265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        isActive() { return mActive; }
54365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            wp<ThreadBase>&     thread()  { return mThread; }
54465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
54565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        private:
54665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
54765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            status_t            obtainBuffer(AudioBufferProvider::Buffer* buffer, uint32_t waitTimeMs);
54865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            void                clearBufferQueue();
54965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
55065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            // Maximum number of pending buffers allocated by OutputTrack::write()
55165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            static const uint8_t kMaxOverFlowBuffers = 10;
55265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
55365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            Vector < Buffer* >          mBufferQueue;
55465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            AudioBufferProvider::Buffer mOutBuffer;
55565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool                        mActive;
55665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            DuplicatingThread*          mSourceThread;
55765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };  // end of OutputTrack
55865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
55965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
56065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~PlaybackThread();
56165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
56265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    dump(int fd, const Vector<String16>& args);
56365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
56465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Thread virtuals
56565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    readyToRun();
56665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     void        onFirstRef();
56765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
56865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    latency() const;
56965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
57065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    setMasterVolume(float value);
57165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    setMasterMute(bool muted);
57265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
57365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     float       masterVolume() const;
57465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        masterMute() const;
57565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
57665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    setStreamVolume(int stream, float value);
57765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    setStreamMute(int stream, bool muted);
57865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
57965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     float       streamVolume(int stream) const;
58065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        streamMute(int stream) const;
58165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
58265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        isStreamActive(int stream) const;
58365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
58465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<Track>   createTrack_l(
58565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    const sp<AudioFlinger::Client>& client,
58665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    int streamType,
58765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    uint32_t sampleRate,
58865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    int format,
58965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    int channelCount,
59065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    int frameCount,
59165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    const sp<IMemory>& sharedBuffer,
59265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    int sessionId,
59365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                    status_t *status);
59465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
59565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    AudioStreamOut* getOutput() { return mOutput; }
59665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
59765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     int         type() const { return mType; }
59865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        suspend() { mSuspended++; }
59965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        restore() { if (mSuspended) mSuspended--; }
60065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        isSuspended() { return (mSuspended != 0); }
60165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     String8     getParameters(const String8& keys);
60265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     void        audioConfigChanged_l(int event, int param = 0);
60365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
60465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    int16_t     *mixBuffer() { return mMixBuffer; };
60565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
60665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<EffectHandle> createEffect_l(
60765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<AudioFlinger::Client>& client,
60865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<IEffectClient>& effectClient,
60965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int32_t priority,
61065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int sessionId,
61165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        effect_descriptor_t *desc,
61265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int *enabled,
61365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        status_t *status);
61465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void disconnectEffect(const sp< EffectModule>& effect,
61565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                          const wp<EffectHandle>& handle);
61665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
61739e94f8f723d445447fdee0822291e664b631f60Eric Laurent                    // return values for hasAudioSession (bit field)
61839e94f8f723d445447fdee0822291e664b631f60Eric Laurent                    enum effect_state {
61939e94f8f723d445447fdee0822291e664b631f60Eric Laurent                        EFFECT_SESSION = 0x1,   // the audio session corresponds to at least one
62039e94f8f723d445447fdee0822291e664b631f60Eric Laurent                                                // effect
62139e94f8f723d445447fdee0822291e664b631f60Eric Laurent                        TRACK_SESSION = 0x2     // the audio session corresponds to at least one
62239e94f8f723d445447fdee0822291e664b631f60Eric Laurent                                                // track
62339e94f8f723d445447fdee0822291e664b631f60Eric Laurent                    };
62439e94f8f723d445447fdee0822291e664b631f60Eric Laurent
62539e94f8f723d445447fdee0822291e664b631f60Eric Laurent                    uint32_t hasAudioSession(int sessionId);
62665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<EffectChain> getEffectChain(int sessionId);
62765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<EffectChain> getEffectChain_l(int sessionId);
62865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    status_t addEffectChain_l(const sp<EffectChain>& chain);
62965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    size_t removeEffectChain_l(const sp<EffectChain>& chain);
630de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    void lockEffectChains_l(Vector<sp <EffectChain> >& effectChains);
631de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    void unlockEffectChains(Vector<sp <EffectChain> >& effectChains);
63265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
63365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    sp<AudioFlinger::EffectModule> getEffect_l(int sessionId, int effectId);
63465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void detachAuxEffect_l(int effectId);
635de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
636de070137f11d346fba77605bd76a44c040a618fcEric Laurent                            int EffectId);
637de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
638de070137f11d346fba77605bd76a44c040a618fcEric Laurent                            int EffectId);
63965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void setMode(uint32_t mode);
64065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
641de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    status_t addEffect_l(const sp< EffectModule>& effect);
642de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    void removeEffect_l(const sp< EffectModule>& effect);
643de070137f11d346fba77605bd76a44c040a618fcEric Laurent
644de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    uint32_t getStrategyForSession_l(int sessionId);
645de070137f11d346fba77605bd76a44c040a618fcEric Laurent
64665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        struct  stream_type_t {
64765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            stream_type_t()
64865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                :   volume(1.0f),
64965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    mute(false)
65065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            {
65165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            }
65265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            float       volume;
65365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool        mute;
65465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
65565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
65665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
65765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                             mType;
65865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t*                        mMixBuffer;
65965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                             mSuspended;
66065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                             mBytesWritten;
66165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool                            mMasterMute;
66265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        SortedVector< wp<Track> >       mActiveTracks;
66365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
66465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual int             getTrackName_l() = 0;
66565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void            deleteTrackName_l(int name) = 0;
66665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual uint32_t        activeSleepTimeUs() = 0;
66765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual uint32_t        idleSleepTimeUs() = 0;
66825cbe0ecd6df8be7e40537c5d85c82f105038479Eric Laurent        virtual uint32_t        suspendSleepTimeUs() = 0;
66965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
67065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
67165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
67265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class AudioFlinger;
67365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class OutputTrack;
67465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class Track;
67565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class TrackBase;
67665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class MixerThread;
67765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class DirectOutputThread;
67865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        friend class DuplicatingThread;
67965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
68065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        PlaybackThread(const Client&);
68165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        PlaybackThread& operator = (const PlaybackThread&);
68265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
68365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t    addTrack_l(const sp<Track>& track);
68465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void        destroyTrack_l(const sp<Track>& track);
68565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
68665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void        readOutputParameters();
68765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
68865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t    device() { return mDevice; }
68965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
69065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    dumpInternals(int fd, const Vector<String16>& args);
69165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t    dumpTracks(int fd, const Vector<String16>& args);
69265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t    dumpEffectChains(int fd, const Vector<String16>& args);
69365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
69465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        SortedVector< sp<Track> >       mTracks;
69565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // mStreamTypes[] uses 1 additionnal stream type internally for the OutputTrack used by DuplicatingThread
69665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        stream_type_t                   mStreamTypes[AudioSystem::NUM_STREAM_TYPES + 1];
69765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AudioStreamOut*                 mOutput;
69865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        float                           mMasterVolume;
69965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        nsecs_t                         mLastWriteTime;
70065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                             mNumWrites;
70165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                             mNumDelayedWrites;
70265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool                            mInWrite;
70365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        Vector< sp<EffectChain> >       mEffectChains;
70465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t                        mDevice;
70565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
70665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
70765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class MixerThread : public PlaybackThread {
70865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
709de070137f11d346fba77605bd76a44c040a618fcEric Laurent        MixerThread (const sp<AudioFlinger>& audioFlinger,
710de070137f11d346fba77605bd76a44c040a618fcEric Laurent                     AudioStreamOut* output,
711de070137f11d346fba77605bd76a44c040a618fcEric Laurent                     int id,
712de070137f11d346fba77605bd76a44c040a618fcEric Laurent                     uint32_t device);
71365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~MixerThread();
71465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
71565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Thread virtuals
71665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        threadLoop();
71765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
71865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        invalidateTracks(int streamType);
71965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        checkForNewParameters_l();
72065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     status_t    dumpInternals(int fd, const Vector<String16>& args);
72165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
72265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
723de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    uint32_t    prepareTracks_l(const SortedVector< wp<Track> >& activeTracks,
724de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                Vector< sp<Track> > *tracksToRemove);
72565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     int         getTrackName_l();
72665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     void        deleteTrackName_l(int name);
72765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    activeSleepTimeUs();
72865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    idleSleepTimeUs();
72925cbe0ecd6df8be7e40537c5d85c82f105038479Eric Laurent        virtual     uint32_t    suspendSleepTimeUs();
73065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
73165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        AudioMixer*                     mAudioMixer;
73265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
73365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
73465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class DirectOutputThread : public PlaybackThread {
73565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
73665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
73765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
73865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        ~DirectOutputThread();
73965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
74065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Thread virtuals
74165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        threadLoop();
74265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
74365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        checkForNewParameters_l();
74465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
74565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
74665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     int         getTrackName_l();
74765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     void        deleteTrackName_l(int name);
74865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    activeSleepTimeUs();
74965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    idleSleepTimeUs();
75025cbe0ecd6df8be7e40537c5d85c82f105038479Eric Laurent        virtual     uint32_t    suspendSleepTimeUs();
75165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
75265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
75365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void applyVolume(uint16_t leftVol, uint16_t rightVol, bool ramp);
75465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
75565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        float mLeftVolFloat;
75665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        float mRightVolFloat;
75765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint16_t mLeftVolShort;
75865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint16_t mRightVolShort;
75965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
76065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
76165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class DuplicatingThread : public MixerThread {
76265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
76365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread, int id);
76465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        ~DuplicatingThread();
76565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
76665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Thread virtuals
76765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     bool        threadLoop();
76865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        addOutputTrack(MixerThread* thread);
76965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        removeOutputTrack(MixerThread* thread);
77065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint32_t    waitTimeMs() { return mWaitTimeMs; }
77165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
77265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual     uint32_t    activeSleepTimeUs();
77365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
77465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
77565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        outputsReady(SortedVector< sp<OutputTrack> > &outputTracks);
77665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        updateWaitTime();
77765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
77865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        SortedVector < sp<OutputTrack> >  mOutputTracks;
77965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    uint32_t    mWaitTimeMs;
78065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
78165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
78265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian              PlaybackThread *checkPlaybackThread_l(int output) const;
78365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian              MixerThread *checkMixerThread_l(int output) const;
78465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian              RecordThread *checkRecordThread_l(int input) const;
78565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian              float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; }
78665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian              void audioConfigChanged_l(int event, int ioHandle, void *param2);
78765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
788f5aafb209d01ba2ab6cb55d1a12cfc653e2b4be0Eric Laurent              int  nextUniqueId_l();
789de070137f11d346fba77605bd76a44c040a618fcEric Laurent              status_t moveEffectChain_l(int session,
790de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                     AudioFlinger::PlaybackThread *srcThread,
79139e94f8f723d445447fdee0822291e664b631f60Eric Laurent                                     AudioFlinger::PlaybackThread *dstThread,
79239e94f8f723d445447fdee0822291e664b631f60Eric Laurent                                     bool reRegister);
79365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
79465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    friend class AudioBuffer;
79565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
79665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class TrackHandle : public android::BnAudioTrack {
79765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
79865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                            TrackHandle(const sp<PlaybackThread::Track>& track);
79965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~TrackHandle();
80065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    start();
80165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        stop();
80265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        flush();
80365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        mute(bool);
80465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        pause();
80565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        setVolume(float left, float right);
80665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual sp<IMemory> getCblk() const;
80765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    attachAuxEffect(int effectId);
80865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t onTransact(
80965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
81065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
81165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<PlaybackThread::Track> mTrack;
81265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
81365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
81465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    friend class Client;
81565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    friend class PlaybackThread::Track;
81665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
81765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
81865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                void        removeClient_l(pid_t pid);
81965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                void        removeNotificationClient(pid_t pid);
82065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
82165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
82265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // record thread
82365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class RecordThread : public ThreadBase, public AudioBufferProvider
82465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    {
82565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
82665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
82765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // record track
82865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        class RecordTrack : public TrackBase {
82965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        public:
83065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                RecordTrack(const wp<ThreadBase>& thread,
83165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        const sp<Client>& client,
83265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t sampleRate,
83365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int format,
83465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int channelCount,
83565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int frameCount,
83665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        uint32_t flags,
83765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        int sessionId);
83865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                ~RecordTrack();
83965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
84065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t    start();
84165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual void        stop();
84265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
84365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        overflow() { bool tmp = mOverflow; mOverflow = false; return tmp; }
84465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    bool        setOverflow() { bool tmp = mOverflow; mOverflow = true; return tmp; }
84565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
84665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                    void        dump(char* buffer, size_t size);
84765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        private:
84865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class AudioFlinger;
84965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            friend class RecordThread;
85065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
85165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                RecordTrack(const RecordTrack&);
85265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                RecordTrack& operator = (const RecordTrack&);
85365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
85465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
85565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
85665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            bool                mOverflow;
85765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
85865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
85965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
86065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                RecordThread(const sp<AudioFlinger>& audioFlinger,
86165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        AudioStreamIn *input,
86265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        uint32_t sampleRate,
86365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        uint32_t channels,
86465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int id);
86565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                ~RecordThread();
86665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
86765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual bool        threadLoop();
86865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    readyToRun() { return NO_ERROR; }
86965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        onFirstRef();
87065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
87165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                status_t    start(RecordTrack* recordTrack);
87265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                void        stop(RecordTrack* recordTrack);
87365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                status_t    dump(int fd, const Vector<String16>& args);
87465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                AudioStreamIn* getInput() { return mInput; }
87565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
87665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    getNextBuffer(AudioBufferProvider::Buffer* buffer);
87765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        releaseBuffer(AudioBufferProvider::Buffer* buffer);
87865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual bool        checkForNewParameters_l();
87965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual String8     getParameters(const String8& keys);
88065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        audioConfigChanged_l(int event, int param = 0);
88165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                void        readInputParameters();
88265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual unsigned int  getInputFramesLost();
88365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
88465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
88565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                RecordThread();
88665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                AudioStreamIn                       *mInput;
88765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                sp<RecordTrack>                     mActiveTrack;
88865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                Condition                           mStartStopCond;
88965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                AudioResampler                      *mResampler;
89065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int32_t                             *mRsmpOutBuffer;
89165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int16_t                             *mRsmpInBuffer;
89265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                size_t                              mRsmpInIndex;
89365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                size_t                              mInputBytes;
89465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int                                 mReqChannelCount;
89565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                uint32_t                            mReqSampleRate;
89665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                ssize_t                             mBytesRead;
89765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
89865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
89965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class RecordHandle : public android::BnAudioRecord {
90065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
90165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
90265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual             ~RecordHandle();
90365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t    start();
90465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void        stop();
90565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual sp<IMemory> getCblk() const;
90665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t onTransact(
90765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
90865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    private:
90965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<RecordThread::RecordTrack> mRecordTrack;
91065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
91165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
91265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    //--- Audio Effect Management
91365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
91465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // EffectModule and EffectChain classes both have their own mutex to protect
91565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // state changes or resource modifications. Always respect the following order
91665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // if multiple mutexes must be acquired to avoid cross deadlock:
91765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // AudioFlinger -> ThreadBase -> EffectChain -> EffectModule
91865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
91965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // The EffectModule class is a wrapper object controlling the effect engine implementation
92065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // in the effect library. It prevents concurrent calls to process() and command() functions
92165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // from different client threads. It keeps a list of EffectHandle objects corresponding
92265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // to all client applications using this effect and notifies applications of effect state,
92365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // control or parameter changes. It manages the activation state machine to send appropriate
92465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // reset, enable, disable commands to effect engine and provide volume
92565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // ramping when effects are activated/deactivated.
92665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // When controlling an auxiliary effect, the EffectModule also provides an input buffer used by
92765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // the attached track(s) to accumulate their auxiliary channel.
92865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectModule: public RefBase {
92965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
93065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectModule(const wp<ThreadBase>& wThread,
93165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        const wp<AudioFlinger::EffectChain>& chain,
93265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        effect_descriptor_t *desc,
93365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int id,
93465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                        int sessionId);
93565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        ~EffectModule();
93665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
93765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        enum effect_state {
93865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            IDLE,
93965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            RESTART,
94065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            STARTING,
94165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            ACTIVE,
94265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            STOPPING,
94365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            STOPPED
94465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        };
94565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
94665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int         id() { return mId; }
94765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void process();
94865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void updateState();
94925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent        status_t command(uint32_t cmdCode,
95025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                         uint32_t cmdSize,
95125f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                         void *pCmdData,
95225f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                         uint32_t *replySize,
95325f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                         void *pReplyData);
95465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
95565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void reset_l();
95665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t configure();
95765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t init();
95865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t state() {
95965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            return mState;
96065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
96165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t status() {
96265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            return mStatus;
96365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
964de070137f11d346fba77605bd76a44c040a618fcEric Laurent        int sessionId() {
965de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return mSessionId;
966de070137f11d346fba77605bd76a44c040a618fcEric Laurent        }
96765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t    setEnabled(bool enabled);
96865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool isEnabled();
9698f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent        bool isProcessEnabled();
97065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
97165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void        setInBuffer(int16_t *buffer) { mConfig.inputCfg.buffer.s16 = buffer; }
97265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t     *inBuffer() { return mConfig.inputCfg.buffer.s16; }
97365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void        setOutBuffer(int16_t *buffer) { mConfig.outputCfg.buffer.s16 = buffer; }
97465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t     *outBuffer() { return mConfig.outputCfg.buffer.s16; }
975de070137f11d346fba77605bd76a44c040a618fcEric Laurent        void        setChain(const wp<EffectChain>& chain) { mChain = chain; }
976de070137f11d346fba77605bd76a44c040a618fcEric Laurent        void        setThread(const wp<ThreadBase>& thread) { mThread = thread; }
97765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
97865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t addHandle(sp<EffectHandle>& handle);
97965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void disconnect(const wp<EffectHandle>& handle);
98065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        size_t removeHandle (const wp<EffectHandle>& handle);
98165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
98265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        effect_descriptor_t& desc() { return mDescriptor; }
98365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        wp<EffectChain>&     chain() { return mChain; }
98465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
98565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t         setDevice(uint32_t device);
98665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t         setVolume(uint32_t *left, uint32_t *right, bool controller);
98765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t         setMode(uint32_t mode);
98865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
98965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t         dump(int fd, const Vector<String16>& args);
99065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
99165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
99265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
99365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Maximum time allocated to effect engines to complete the turn off sequence
99465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        static const uint32_t MAX_DISABLE_TIME_MS = 10000;
99565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
99665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectModule(const EffectModule&);
99765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectModule& operator = (const EffectModule&);
99865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
99965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t start_l();
100065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t stop_l();
100165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
100265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // update this table when AudioSystem::audio_devices or audio_device_e (in EffectApi.h) are modified
100365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        static const uint32_t sDeviceConvTable[];
100465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        static uint32_t deviceAudioSystemToEffectApi(uint32_t device);
100565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
100665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // update this table when AudioSystem::audio_mode or audio_mode_e (in EffectApi.h) are modified
100765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        static const uint32_t sModeConvTable[];
100865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        static int modeAudioSystemToEffectApi(uint32_t mode);
100965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
101065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        Mutex               mLock;      // mutex for process, commands and handles list protection
101165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        wp<ThreadBase>      mThread;    // parent thread
101265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        wp<EffectChain>     mChain;     // parent effect chain
101365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                 mId;        // this instance unique ID
101465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int                 mSessionId; // audio session ID
101565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        effect_descriptor_t mDescriptor;// effect descriptor received from effect engine
101665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        effect_config_t     mConfig;    // input and output audio configuration
101765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        effect_interface_t  mEffectInterface; // Effect module C API
101865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t mStatus;               // initialization status
101965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t mState;                // current activation state (effect_state)
102065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        Vector< wp<EffectHandle> > mHandles;    // list of client handles
102165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t mMaxDisableWaitCnt;    // maximum grace period before forcing an effect off after
102265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                                        // sending disable command.
102365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint32_t mDisableWaitCnt;       // current process() calls count during disable period.
102465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
102565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
102665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // The EffectHandle class implements the IEffect interface. It provides resources
102765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // to receive parameter updates, keeps track of effect control
102865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // ownership and state and has a pointer to the EffectModule object it is controlling.
102965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // There is one EffectHandle object for each application controlling (or using)
103065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // an effect module.
103165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // The EffectHandle is obtained by calling AudioFlinger::createEffect().
103265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectHandle: public android::BnEffect {
103365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
103465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
103565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectHandle(const sp<EffectModule>& effect,
103665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                const sp<AudioFlinger::Client>& client,
103765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                const sp<IEffectClient>& effectClient,
103865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int32_t priority);
103965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual ~EffectHandle();
104065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
104165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // IEffect
104265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t enable();
104365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t disable();
104425f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent        virtual status_t command(uint32_t cmdCode,
104525f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                                 uint32_t cmdSize,
104625f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                                 void *pCmdData,
104725f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                                 uint32_t *replySize,
104825f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                                 void *pReplyData);
104965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual void disconnect();
105065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual sp<IMemory> getCblk() const;
105165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        virtual status_t onTransact(uint32_t code, const Parcel& data,
105265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                Parcel* reply, uint32_t flags);
105365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
105465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
105565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Give or take control of effect module
105665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void setControl(bool hasControl, bool signal);
105725f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent        void commandExecuted(uint32_t cmdCode,
105825f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                             uint32_t cmdSize,
105925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                             void *pCmdData,
106025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                             uint32_t replySize,
106125f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent                             void *pReplyData);
106265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void setEnabled(bool enabled);
106365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
106465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        // Getters
106565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int id() { return mEffect->id(); }
106665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int priority() { return mPriority; }
106765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool hasControl() { return mHasControl; }
106865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<EffectModule> effect() { return mEffect; }
106965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
107065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void dump(char* buffer, size_t size);
107165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
107265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
107365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
107465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectHandle(const EffectHandle&);
107565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectHandle& operator =(const EffectHandle&);
107665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
107765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<EffectModule> mEffect;           // pointer to controlled EffectModule
107865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<IEffectClient> mEffectClient;    // callback interface for client notifications
107965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<Client>          mClient;        // client for shared memory allocation
108065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        sp<IMemory>         mCblkMemory;    // shared memory for control block
108165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        effect_param_cblk_t* mCblk;         // control block for deferred parameter setting via shared memory
108265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        uint8_t*            mBuffer;        // pointer to parameter area in shared memory
108365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int mPriority;                      // client application priority to control the effect
108465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool mHasControl;                   // true if this handle is controlling the effect
108565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
108665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
108765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // the EffectChain class represents a group of effects associated to one audio session.
108865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // There can be any number of EffectChain objects per output mixer thread (PlaybackThread).
108965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // The EffecChain with session ID 0 contains global effects applied to the output mix.
109065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // Effects in this chain can be insert or auxiliary. Effects in other chains (attached to tracks)
109165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // are insert only. The EffectChain maintains an ordered list of effect module, the order corresponding
109265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // in the effect process order. When attached to a track (session ID != 0), it also provide it's own
109365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    // input buffer used by the track as accumulation buffer.
109465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    class EffectChain: public RefBase {
109565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    public:
109665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectChain(const wp<ThreadBase>& wThread, int sessionId);
109765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        ~EffectChain();
109865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
109965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void process_l();
110065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
110165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void lock() {
110265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mLock.lock();
110365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
110465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void unlock() {
110565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mLock.unlock();
110665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
110765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
1108de070137f11d346fba77605bd76a44c040a618fcEric Laurent        status_t addEffect_l(const sp<EffectModule>& handle);
1109cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        size_t removeEffect_l(const sp<EffectModule>& handle);
111065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
111165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int sessionId() {
111265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            return mSessionId;
111365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
1114de070137f11d346fba77605bd76a44c040a618fcEric Laurent
1115cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
1116cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        sp<EffectModule> getEffectFromId_l(int id);
1117cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        bool setVolume_l(uint32_t *left, uint32_t *right);
1118cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        void setDevice_l(uint32_t device);
1119cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        void setMode_l(uint32_t mode);
112065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
112165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
112265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mInBuffer = buffer;
112365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mOwnInBuffer = ownsBuffer;
112465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
112565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t *inBuffer() {
112665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            return mInBuffer;
112765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
112865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void setOutBuffer(int16_t *buffer) {
112965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            mOutBuffer = buffer;
113065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
113165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t *outBuffer() {
113265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian            return mOutBuffer;
113365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        }
113465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
113565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void startTrack() {mActiveTrackCnt++;}
113665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        void stopTrack() {mActiveTrackCnt--;}
113765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int activeTracks() { return mActiveTrackCnt;}
113865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
1139de070137f11d346fba77605bd76a44c040a618fcEric Laurent        uint32_t strategy() { return mStrategy; }
1140de070137f11d346fba77605bd76a44c040a618fcEric Laurent        void setStrategy(uint32_t strategy)
1141de070137f11d346fba77605bd76a44c040a618fcEric Laurent                 { mStrategy = strategy; }
1142de070137f11d346fba77605bd76a44c040a618fcEric Laurent
114365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        status_t dump(int fd, const Vector<String16>& args);
114465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
114565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    protected:
114665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
114765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectChain(const EffectChain&);
114865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        EffectChain& operator =(const EffectChain&);
114965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
115065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        wp<ThreadBase> mThread;     // parent mixer thread
115165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        Mutex mLock;                // mutex protecting effect list
115265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        Vector<sp<EffectModule> > mEffects; // list of effect modules
115365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int mSessionId;             // audio session ID
115465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t *mInBuffer;         // chain input buffer
115565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int16_t *mOutBuffer;        // chain output buffer
115665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        int mActiveTrackCnt;        // number of active tracks connected
115765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian        bool mOwnInBuffer;          // true if the chain owns its input buffer
1158cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        int mVolumeCtrlIdx;         // index of insert effect having control over volume
1159cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        uint32_t mLeftVolume;       // previous volume on left channel
1160cab112421da6e8eac19ffddbbe3d76067cffee78Eric Laurent        uint32_t mRightVolume;      // previous volume on right channel
1161f997cabca292d70d078ae828e21c28e6df62995fEric Laurent        uint32_t mNewLeftVolume;       // new volume on left channel
1162f997cabca292d70d078ae828e21c28e6df62995fEric Laurent        uint32_t mNewRightVolume;      // new volume on right channel
1163de070137f11d346fba77605bd76a44c040a618fcEric Laurent        uint32_t mStrategy; // strategy for this effect chain
116465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    };
116565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
116665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    friend class RecordThread;
116765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    friend class PlaybackThread;
116865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
116965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
117065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    mutable     Mutex                               mLock;
117165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
117265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                DefaultKeyedVector< pid_t, wp<Client> >     mClients;
117365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
117465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                mutable     Mutex                   mHardwareLock;
117565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                AudioHardwareInterface*             mAudioHardware;
117665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian    mutable     int                                 mHardwareStatus;
117765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
117865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
117965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                DefaultKeyedVector< int, sp<PlaybackThread> >  mPlaybackThreads;
118065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                PlaybackThread::stream_type_t       mStreamTypes[AudioSystem::NUM_STREAM_TYPES];
118165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                float                               mMasterVolume;
118265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                bool                                mMasterMute;
118365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
118465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                DefaultKeyedVector< int, sp<RecordThread> >    mRecordThreads;
118565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
118665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                DefaultKeyedVector< pid_t, sp<NotificationClient> >    mNotificationClients;
118765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                volatile int32_t                    mNextUniqueId;
118865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#ifdef LVMX
118965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                int mLifeVibesClientPid;
119065ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#endif
119165ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian                uint32_t mMode;
119265ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
119365ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian};
119465ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
119565ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian// ----------------------------------------------------------------------------
119665ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
119765ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian}; // namespace android
119865ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian
119965ab47156e1c7dfcd8cc4266253a5ff30219e7f0Mathias Agopian#endif // ANDROID_AUDIO_FLINGER_H
1200