13a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen/*
289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Copyright 2007, The Android Open Source Project
489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License");
689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** you may not use this file except in compliance with the License.
789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** You may obtain a copy of the License at
889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**     http://www.apache.org/licenses/LICENSE-2.0
1089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
1189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Unless required by applicable law or agreed to in writing, software
1289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** distributed under the License is distributed on an "AS IS" BASIS,
1389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** See the License for the specific language governing permissions and
1589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** limitations under the License.
1689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project*/
1789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
1889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#define LOG_TAG "IAudioFlinger"
19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent//#define LOG_NDEBUG 0
2089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/Log.h>
2189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <stdint.h>
2389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <sys/types.h>
2489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
257562408b2261d38415453378b6188f74fda99d88Mathias Agopian#include <binder/Parcel.h>
2689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/IAudioFlinger.h>
2889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android {
3089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectenum {
3289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION,
3389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    OPEN_RECORD,
3489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SAMPLE_RATE,
35dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten    CHANNEL_COUNT,  // obsolete
3689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    FORMAT,
3789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    FRAME_COUNT,
3889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    LATENCY,
3989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_MASTER_VOLUME,
4089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_MASTER_MUTE,
4189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    MASTER_VOLUME,
4289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    MASTER_MUTE,
4389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_STREAM_VOLUME,
4489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_STREAM_MUTE,
4589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    STREAM_VOLUME,
4689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    STREAM_MUTE,
4789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_MODE,
4889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    SET_MIC_MUTE,
4989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    GET_MIC_MUTE,
50c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_PARAMETERS,
51c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_PARAMETERS,
5289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    REGISTER_CLIENT,
5389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    GET_INPUTBUFFERSIZE,
54c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    OPEN_OUTPUT,
55c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    OPEN_DUPLICATE_OUTPUT,
56c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    CLOSE_OUTPUT,
57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SUSPEND_OUTPUT,
58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RESTORE_OUTPUT,
59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    OPEN_INPUT,
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    CLOSE_INPUT,
61f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    SET_STREAM_OUTPUT,
62342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    SET_VOICE_VOLUME,
6305bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent    GET_RENDER_POSITION,
64be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    GET_INPUT_FRAMES_LOST,
65be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    NEW_AUDIO_SESSION_ID,
663a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    ACQUIRE_AUDIO_SESSION_ID,
673a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    RELEASE_AUDIO_SESSION_ID,
68be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    QUERY_NUM_EFFECTS,
69ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent    QUERY_EFFECT,
70be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    GET_EFFECT_DESCRIPTOR,
71de070137f11d346fba77605bd76a44c040a618fcEric Laurent    CREATE_EFFECT,
72a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent    MOVE_EFFECTS,
73cc0f1cfb69ce8b8985fc2c0984847a06a13ad22dGlenn Kasten    LOAD_HW_MODULE,
74cc0f1cfb69ce8b8985fc2c0984847a06a13ad22dGlenn Kasten    GET_PRIMARY_OUTPUT_SAMPLING_RATE,
75cc0f1cfb69ce8b8985fc2c0984847a06a13ad22dGlenn Kasten    GET_PRIMARY_OUTPUT_FRAME_COUNT,
7689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project};
7789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
7889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass BpAudioFlinger : public BpInterface<IAudioFlinger>
7989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{
8089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic:
8189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    BpAudioFlinger(const sp<IBinder>& impl)
8289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        : BpInterface<IAudioFlinger>(impl)
8389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
8489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
8589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
8689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual sp<IAudioTrack> createTrack(
8789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                pid_t pid,
88fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten                                audio_stream_type_t streamType,
8989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                uint32_t sampleRate,
9058f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                audio_format_t format,
91dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten                                audio_channel_mask_t channelMask,
9289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                int frameCount,
93a075db4ff9b086ac2885df77bb6da0869293df92Glenn Kasten                                track_flags_t flags,
9489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                const sp<IMemory>& sharedBuffer,
9572ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten                                audio_io_handle_t output,
963acbd053c842e76e1a40fc8a0bf62de87eebf00fGlenn Kasten                                pid_t tid,
97be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent                                int *sessionId,
9889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                status_t *status)
9989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
10089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
1015841db78dff14898538200287d246577b1fc37e2Eric Laurent        sp<IAudioTrack> track;
10289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
10389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(pid);
104fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) streamType);
10589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(sampleRate);
10689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(format);
1070d255b2d9061ba31f13ada3fc0f7e51916407176Jean-Michel Trivi        data.writeInt32(channelMask);
10889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(frameCount);
109a075db4ff9b086ac2885df77bb6da0869293df92Glenn Kasten        data.writeInt32((int32_t) flags);
11089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeStrongBinder(sharedBuffer->asBinder());
11172ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
1123acbd053c842e76e1a40fc8a0bf62de87eebf00fGlenn Kasten        data.writeInt32((int32_t) tid);
113be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        int lSessionId = 0;
114be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (sessionId != NULL) {
115be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            lSessionId = *sessionId;
116be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
117be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInt32(lSessionId);
11889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
11989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        if (lStatus != NO_ERROR) {
12029357bc2c0dd7c43ad3bd0c8e3efa4e6fd9bfd47Steve Block            ALOGE("createTrack error: %s", strerror(-lStatus));
1215841db78dff14898538200287d246577b1fc37e2Eric Laurent        } else {
122be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            lSessionId = reply.readInt32();
123be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            if (sessionId != NULL) {
124be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent                *sessionId = lSessionId;
125be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            }
1265841db78dff14898538200287d246577b1fc37e2Eric Laurent            lStatus = reply.readInt32();
1275841db78dff14898538200287d246577b1fc37e2Eric Laurent            track = interface_cast<IAudioTrack>(reply.readStrongBinder());
12889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        }
12989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        if (status) {
13089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project            *status = lStatus;
13189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        }
1325841db78dff14898538200287d246577b1fc37e2Eric Laurent        return track;
13389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
13489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
13589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual sp<IAudioRecord> openRecord(
13689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                pid_t pid,
13772ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten                                audio_io_handle_t input,
13889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                uint32_t sampleRate,
13958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                audio_format_t format,
14028b76b334f92a15a2be3cc9e2f7d229a3275d1acGlenn Kasten                                audio_channel_mask_t channelMask,
14189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                int frameCount,
142a075db4ff9b086ac2885df77bb6da0869293df92Glenn Kasten                                track_flags_t flags,
1431879fff068422852c1483dcf8365c2ff0e2fadfcGlenn Kasten                                pid_t tid,
144be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent                                int *sessionId,
14589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                status_t *status)
14689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
14789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
1485841db78dff14898538200287d246577b1fc37e2Eric Laurent        sp<IAudioRecord> record;
14989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
15089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(pid);
15172ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) input);
15289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(sampleRate);
15389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(format);
1540d255b2d9061ba31f13ada3fc0f7e51916407176Jean-Michel Trivi        data.writeInt32(channelMask);
15589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(frameCount);
15689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(flags);
1571879fff068422852c1483dcf8365c2ff0e2fadfcGlenn Kasten        data.writeInt32((int32_t) tid);
158be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        int lSessionId = 0;
159be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (sessionId != NULL) {
160be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            lSessionId = *sessionId;
161be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
162be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInt32(lSessionId);
1635841db78dff14898538200287d246577b1fc37e2Eric Laurent        status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
1645841db78dff14898538200287d246577b1fc37e2Eric Laurent        if (lStatus != NO_ERROR) {
16529357bc2c0dd7c43ad3bd0c8e3efa4e6fd9bfd47Steve Block            ALOGE("openRecord error: %s", strerror(-lStatus));
1665841db78dff14898538200287d246577b1fc37e2Eric Laurent        } else {
167be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            lSessionId = reply.readInt32();
168be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            if (sessionId != NULL) {
169be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent                *sessionId = lSessionId;
170be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            }
1715841db78dff14898538200287d246577b1fc37e2Eric Laurent            lStatus = reply.readInt32();
1725841db78dff14898538200287d246577b1fc37e2Eric Laurent            record = interface_cast<IAudioRecord>(reply.readStrongBinder());
1735841db78dff14898538200287d246577b1fc37e2Eric Laurent        }
17489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        if (status) {
17589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project            *status = lStatus;
17689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        }
1775841db78dff14898538200287d246577b1fc37e2Eric Laurent        return record;
17889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
17989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
18072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual uint32_t sampleRate(audio_io_handle_t output) const
18189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
18289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
18389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
18472ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
18589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(SAMPLE_RATE, data, &reply);
18689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
18789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
18889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
189dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten#if 0
19072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual int channelCount(audio_io_handle_t output) const
19189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
19289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
19389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
19472ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
19589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(CHANNEL_COUNT, data, &reply);
19689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
19789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
198dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten#endif
19989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
20072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual audio_format_t format(audio_io_handle_t output) const
20189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
20289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
20389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
20472ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
20589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(FORMAT, data, &reply);
20658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten        return (audio_format_t) reply.readInt32();
20789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
20889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
20972ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual size_t frameCount(audio_io_handle_t output) const
21089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
21189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
21289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
21372ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
21489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(FRAME_COUNT, data, &reply);
21589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
21689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
21789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
21872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual uint32_t latency(audio_io_handle_t output) const
21989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
22089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
22189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
22272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
22389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(LATENCY, data, &reply);
22489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
22589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
22689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
22789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual status_t setMasterVolume(float value)
22889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
22989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
23089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
23189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeFloat(value);
23289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(SET_MASTER_VOLUME, data, &reply);
23389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
23489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
23589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
23689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual status_t setMasterMute(bool muted)
23789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
23889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
23989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
24089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(muted);
24189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(SET_MASTER_MUTE, data, &reply);
24289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
24389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
24489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
24589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual float masterVolume() const
24689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
24789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
24889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
24989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(MASTER_VOLUME, data, &reply);
25089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readFloat();
25189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
25289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
25389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual bool masterMute() const
25489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
25589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
25689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
25789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(MASTER_MUTE, data, &reply);
25889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
25989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
26089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
26172ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
26272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten            audio_io_handle_t output)
26389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
26489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
26589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
266fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
26789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeFloat(value);
26872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
26989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(SET_STREAM_VOLUME, data, &reply);
27089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
27189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
27289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
273fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
27489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
27589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
27689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
277fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
27889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(muted);
27989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(SET_STREAM_MUTE, data, &reply);
28089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
28189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
28289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
28372ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
28489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
28589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
28689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
287fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
28872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
28989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(STREAM_VOLUME, data, &reply);
29089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readFloat();
29189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
29289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
293fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual bool streamMute(audio_stream_type_t stream) const
29489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
29589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
29689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
297fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
29889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        remote()->transact(STREAM_MUTE, data, &reply);
29989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
30089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
30189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
302f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setMode(audio_mode_t mode)
30389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
30489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
30589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
30689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(mode);
307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_MODE, data, &reply);
30889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
30989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
31089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
311c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setMicMute(bool state)
31289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
31389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
31489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
315c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
316c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_MIC_MUTE, data, &reply);
31789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
31889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
31989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
320c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual bool getMicMute() const
32189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
32289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
32389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
324c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_MIC_MUTE, data, &reply);
32589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
32689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
32789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
32872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
32989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
33089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
33189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
33272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) ioHandle);
333c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeString8(keyValuePairs);
334c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PARAMETERS, data, &reply);
33589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
33689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
33789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
33872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
33989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
34089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
34189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
34272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) ioHandle);
343c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeString8(keys);
344c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_PARAMETERS, data, &reply);
345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return reply.readString8();
346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void registerClient(const sp<IAudioFlingerClient>& client)
349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
350c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
351c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
352c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeStrongBinder(client->asBinder());
353c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(REGISTER_CLIENT, data, &reply);
354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
356dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten    virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
357dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten            audio_channel_mask_t channelMask) const
358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(sampleRate);
362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(format);
363dd8104cc5367262f0e5f13df4e79f131e8d560bbGlenn Kasten        data.writeInt32(channelMask);
364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
36589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
36689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
36789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
368a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent    virtual audio_io_handle_t openOutput(audio_module_handle_t module,
369a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                         audio_devices_t *pDevices,
370a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                         uint32_t *pSamplingRate,
371a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                         audio_format_t *pFormat,
372a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                         audio_channel_mask_t *pChannelMask,
373a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                         uint32_t *pLatencyMs,
3740ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent                                         audio_output_flags_t flags)
37589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
37689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
377a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        audio_devices_t devices = pDevices ? *pDevices : (audio_devices_t)0;
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0;
37958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten        audio_format_t format = pFormat ? *pFormat : AUDIO_FORMAT_DEFAULT;
380a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        audio_channel_mask_t channelMask = pChannelMask ? *pChannelMask : (audio_channel_mask_t)0;
381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t latency = pLatencyMs ? *pLatencyMs : 0;
382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
38389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
384a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        data.writeInt32(module);
385c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(devices);
386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(format);
388a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        data.writeInt32(channelMask);
389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(latency);
39018868c5db2f90309c6d11e5837822135e4a0c0faGlenn Kasten        data.writeInt32((int32_t) flags);
391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(OPEN_OUTPUT, data, &reply);
39272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        audio_io_handle_t output = (audio_io_handle_t) reply.readInt32();
39372ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        ALOGV("openOutput() returned output, %d", output);
394a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        devices = (audio_devices_t)reply.readInt32();
395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pDevices) *pDevices = devices;
396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        samplingRate = reply.readInt32();
397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pSamplingRate) *pSamplingRate = samplingRate;
39858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten        format = (audio_format_t) reply.readInt32();
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pFormat) *pFormat = format;
400a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        channelMask = (audio_channel_mask_t)reply.readInt32();
401a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        if (pChannelMask) *pChannelMask = channelMask;
402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        latency = reply.readInt32();
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pLatencyMs) *pLatencyMs = latency;
404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return output;
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
40772ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
40872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten            audio_io_handle_t output2)
409c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
41272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output1);
41372ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output2);
414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
41572ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        return (audio_io_handle_t) reply.readInt32();
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
41872ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t closeOutput(audio_io_handle_t output)
419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
42272ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(CLOSE_OUTPUT, data, &reply);
42489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
42589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
42689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
42772ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t suspendOutput(audio_io_handle_t output)
42889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
42989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
43089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
43172ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SUSPEND_OUTPUT, data, &reply);
43389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        return reply.readInt32();
43489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
43672ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t restoreOutput(audio_io_handle_t output)
43789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
43889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
43989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
44072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RESTORE_OUTPUT, data, &reply);
442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return reply.readInt32();
44389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
445a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent    virtual audio_io_handle_t openInput(audio_module_handle_t module,
446a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                        audio_devices_t *pDevices,
447a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                        uint32_t *pSamplingRate,
448a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                        audio_format_t *pFormat,
449a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent                                        audio_channel_mask_t *pChannelMask)
45089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
45189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
452a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        audio_devices_t devices = pDevices ? *pDevices : (audio_devices_t)0;
453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0;
45458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten        audio_format_t format = pFormat ? *pFormat : AUDIO_FORMAT_DEFAULT;
455a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        audio_channel_mask_t channelMask = pChannelMask ? *pChannelMask : (audio_channel_mask_t)0;
456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
45789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
458a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        data.writeInt32(module);
459c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(devices);
460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
46189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInt32(format);
462a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        data.writeInt32(channelMask);
463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(OPEN_INPUT, data, &reply);
46472ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
465a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        devices = (audio_devices_t)reply.readInt32();
466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pDevices) *pDevices = devices;
467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        samplingRate = reply.readInt32();
468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pSamplingRate) *pSamplingRate = samplingRate;
46958f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten        format = (audio_format_t) reply.readInt32();
470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (pFormat) *pFormat = format;
471a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        channelMask = (audio_channel_mask_t)reply.readInt32();
472a4c5a550e2a3bc237179b8684e51718e05894492Eric Laurent        if (pChannelMask) *pChannelMask = channelMask;
473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return input;
47489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
476fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent    virtual status_t closeInput(int input)
47789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
47889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
47989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
480fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
481c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(CLOSE_INPUT, data, &reply);
482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return reply.readInt32();
48389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
48489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
48572ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
48689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
48789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Parcel data, reply;
48889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
489fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
49072ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_OUTPUT, data, &reply);
492c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return reply.readInt32();
49389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    }
494f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent
495f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    virtual status_t setVoiceVolume(float volume)
496f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    {
497f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent        Parcel data, reply;
498f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
499f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent        data.writeFloat(volume);
500f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent        remote()->transact(SET_VOICE_VOLUME, data, &reply);
501f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent        return reply.readInt32();
502f0ee6f4055e26fb35d9c526a596668a4dc9da5baEric Laurent    }
503342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent
50472ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
50572ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten            audio_io_handle_t output) const
506342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    {
507342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        Parcel data, reply;
508342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
50972ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) output);
510342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        remote()->transact(GET_RENDER_POSITION, data, &reply);
511342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        status_t status = reply.readInt32();
512342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        if (status == NO_ERROR) {
513342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            uint32_t tmp = reply.readInt32();
514342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            if (halFrames) {
515342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent                *halFrames = tmp;
516342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            }
517342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            tmp = reply.readInt32();
518342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            if (dspFrames) {
519342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent                *dspFrames = tmp;
520342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent            }
521342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        }
522342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent        return status;
523342e9cf388cceb807def720e40e8b0a217f4bcaaEric Laurent    }
52405bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent
52572ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten    virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const
52605bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent    {
52705bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent        Parcel data, reply;
52805bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
52972ef00de10fa95bfcb948ed88ab9b7a177ed0b48Glenn Kasten        data.writeInt32((int32_t) ioHandle);
53005bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent        remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
53105bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent        return reply.readInt32();
53205bca2fde53bfe3063d2a0a877f2b6bfdd6052cfEric Laurent    }
533be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
534be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    virtual int newAudioSessionId()
535be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    {
536be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        Parcel data, reply;
537be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
538be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
539be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        int id = 0;
540be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status == NO_ERROR) {
541be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            id = reply.readInt32();
542be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
543be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        return id;
544be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    }
545be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
5463a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    virtual void acquireAudioSessionId(int audioSession)
5473a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    {
5483a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        Parcel data, reply;
5493a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
5503a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        data.writeInt32(audioSession);
5513a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
5523a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    }
5533a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen
5543a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    virtual void releaseAudioSessionId(int audioSession)
5553a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    {
5563a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        Parcel data, reply;
5573a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
5583a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        data.writeInt32(audioSession);
5593a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen        remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
5603a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen    }
5613a34befc6fb04a4945a849e8bda8b84e4bf973feMarco Nelissen
562f587ba5b991c7cd91e4df093d0d796bd419e5d67Glenn Kasten    virtual status_t queryNumberEffects(uint32_t *numEffects) const
563be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    {
564be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        Parcel data, reply;
565be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
566be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
567be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
568be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
569be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
570be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status = reply.readInt32();
571be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
572be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
573be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
5749d1f02d74fd395ec4de6861147da289423f0ab6fGlenn Kasten        if (numEffects != NULL) {
575be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            *numEffects = (uint32_t)reply.readInt32();
576be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
577be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        return NO_ERROR;
578be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    }
579be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
580f587ba5b991c7cd91e4df093d0d796bd419e5d67Glenn Kasten    virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
581be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    {
582be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (pDescriptor == NULL) {
583be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return BAD_VALUE;
584be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
585be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        Parcel data, reply;
586be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
587ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent        data.writeInt32(index);
588ffe9c25ce85e1af55d58ec025adc6367d70db7e8Eric Laurent        status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
589be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
590be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
591be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
592be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status = reply.readInt32();
593be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
594be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
595be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
596be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        reply.read(pDescriptor, sizeof(effect_descriptor_t));
597be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        return NO_ERROR;
598be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    }
599be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent
6005e92a7861196ddae14638d4b7a63fc4892b7ef59Glenn Kasten    virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
601f587ba5b991c7cd91e4df093d0d796bd419e5d67Glenn Kasten            effect_descriptor_t *pDescriptor) const
602be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent    {
603be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (pUuid == NULL || pDescriptor == NULL) {
604be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return BAD_VALUE;
605be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
606be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        Parcel data, reply;
607be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
608be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        data.write(pUuid, sizeof(effect_uuid_t));
609be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
610be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
611be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
612be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
613be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        status = reply.readInt32();
614be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        if (status != NO_ERROR) {
615be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent            return status;
616be916aa1267e2e6b1c148f51d11bcbbc79cb864cEric Laurent        }
617