IAudioFlingerClient.cpp revision 73e26b661af50be2c0a4ff6c9ac85f7347a8b235
127c174483a8ae9688d5d4897c19074f62c7f1701James Dong/*
227c174483a8ae9688d5d4897c19074f62c7f1701James Dong * Copyright (C) 2009 The Android Open Source Project
327c174483a8ae9688d5d4897c19074f62c7f1701James Dong *
427c174483a8ae9688d5d4897c19074f62c7f1701James Dong * Licensed under the Apache License, Version 2.0 (the "License");
527c174483a8ae9688d5d4897c19074f62c7f1701James Dong * you may not use this file except in compliance with the License.
627c174483a8ae9688d5d4897c19074f62c7f1701James Dong * You may obtain a copy of the License at
727c174483a8ae9688d5d4897c19074f62c7f1701James Dong *
827c174483a8ae9688d5d4897c19074f62c7f1701James Dong *      http://www.apache.org/licenses/LICENSE-2.0
927c174483a8ae9688d5d4897c19074f62c7f1701James Dong *
1027c174483a8ae9688d5d4897c19074f62c7f1701James Dong * Unless required by applicable law or agreed to in writing, software
1127c174483a8ae9688d5d4897c19074f62c7f1701James Dong * distributed under the License is distributed on an "AS IS" BASIS,
1227c174483a8ae9688d5d4897c19074f62c7f1701James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1327c174483a8ae9688d5d4897c19074f62c7f1701James Dong * See the License for the specific language governing permissions and
1427c174483a8ae9688d5d4897c19074f62c7f1701James Dong * limitations under the License.
1527c174483a8ae9688d5d4897c19074f62c7f1701James Dong */
1627c174483a8ae9688d5d4897c19074f62c7f1701James Dong
17f933441648ef6a71dee783d733aac17b9508b452Andreas Huber#define LOG_TAG "IAudioFlingerClient"
18f933441648ef6a71dee783d733aac17b9508b452Andreas Huber#include <utils/Log.h>
19f933441648ef6a71dee783d733aac17b9508b452Andreas Huber
20f87e30fe71752dc431d8e8d5682c38271c03265aAndy Hung#include <stdint.h>
21f87e30fe71752dc431d8e8d5682c38271c03265aAndy Hung#include <sys/types.h>
22f87e30fe71752dc431d8e8d5682c38271c03265aAndy Hung
23f87e30fe71752dc431d8e8d5682c38271c03265aAndy Hung#include <binder/Parcel.h>
24609b815a3131d22da38b2f452faa9f89daad4039Andy Hung
256fbc1afd36f514f8b8d36ce67f5e69776c690bd2Lajos Molnar#include <media/IAudioFlingerClient.h>
266fbc1afd36f514f8b8d36ce67f5e69776c690bd2Lajos Molnar#include <media/AudioSystem.h>
271de1e25cba872bd4c077c2e394f8ca9c70b65856Lajos Molnar
281de1e25cba872bd4c077c2e394f8ca9c70b65856Lajos Molnarnamespace android {
29f933441648ef6a71dee783d733aac17b9508b452Andreas Huber
30f933441648ef6a71dee783d733aac17b9508b452Andreas Huberenum {
31f933441648ef6a71dee783d733aac17b9508b452Andreas Huber    IO_CONFIG_CHANGED = IBinder::FIRST_CALL_TRANSACTION
32f933441648ef6a71dee783d733aac17b9508b452Andreas Huber};
33f933441648ef6a71dee783d733aac17b9508b452Andreas Huber
34f933441648ef6a71dee783d733aac17b9508b452Andreas Huberclass BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
35f933441648ef6a71dee783d733aac17b9508b452Andreas Huber{
36f933441648ef6a71dee783d733aac17b9508b452Andreas Huberpublic:
37a147b4f91143d9f2fb608e22f9fca14bbd029573Lajos Molnar    BpAudioFlingerClient(const sp<IBinder>& impl)
38f933441648ef6a71dee783d733aac17b9508b452Andreas Huber        : BpInterface<IAudioFlingerClient>(impl)
397cd58537932ef6f481f68be0b9c597a89cebdfecAndy McFadden    {
4090fcf68fd29f3cb695bd53a830ad984cb7d430c0Lajos Molnar    }
41afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber
42f933441648ef6a71dee783d733aac17b9508b452Andreas Huber    void ioConfigChanged(audio_io_config_event event, const sp<AudioIoDescriptor>& ioDesc)
43f933441648ef6a71dee783d733aac17b9508b452Andreas Huber    {
44d291c222357303b9611cab89d0c3b047584ef377Chong Zhang        Parcel data, reply;
45b2d0b487efd40700199852c9a18b369b1651f15bLajos Molnar        data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
463a0ef0dc71f3776d115f30d87f1d8867daefea88Andreas Huber        data.writeInt32(event);
473fd200feb657c157125e45e30c2a7262e3c0244dChong Zhang        data.writeInt32((int32_t)ioDesc->mIoHandle);
48ac7d4125516299b8a3e6f2b25822a692bdd96311Pawin Vongmasa        data.writeInt32(ioDesc->mSamplingRate);
493a0ef0dc71f3776d115f30d87f1d8867daefea88Andreas Huber        data.writeInt32(ioDesc->mFormat);
508a21c0191f974a0b9cbd5818052e2655e0aaa306Pawin Vongmasa        data.writeInt32(ioDesc->mChannelMask);
518a21c0191f974a0b9cbd5818052e2655e0aaa306Pawin Vongmasa        data.writeInt64(ioDesc->mFrameCount);
5297358c3e1adaf4a744cad78891a16d12e3e9c88eChangwan Ryu        data.writeInt32(ioDesc->mLatency);
534154795d5526750b7aec5f774831a9e1ba0a3f15Alex Glaznev        remote()->transact(IO_CONFIG_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
54f933441648ef6a71dee783d733aac17b9508b452Andreas Huber    }
5597358c3e1adaf4a744cad78891a16d12e3e9c88eChangwan Ryu};
56777cf6d2788b12bbd68f620cda94a128462a208dJinsuk Kim
57f933441648ef6a71dee783d733aac17b9508b452Andreas HuberIMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
58496238cc7551d414067dcbbb4fe3bd801f205f95Andreas Huber
59dff26e5f53b248fd8cc6605850240c7e7c5438dcWonsik Kim// ----------------------------------------------------------------------
605b4401b28990107bb797dc0d5f3904cf27417e98Lajos Molnar
614811923e80a8abefa278307ebf8cc9b0294ba67fWonsik Kimstatus_t BnAudioFlingerClient::onTransact(
627e34bf5af26f8752d4786d3098740cdf51e2438fWonsik Kim    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
6373dd808754c641fe798273d356ee38368715fa7bLajos Molnar{
64496238cc7551d414067dcbbb4fe3bd801f205f95Andreas Huber    switch (code) {
6513a926879249276771b0097538459c7550e2f5ceSteven Moreland    case IO_CONFIG_CHANGED: {
668a21c0191f974a0b9cbd5818052e2655e0aaa306Pawin Vongmasa            CHECK_INTERFACE(IAudioFlingerClient, data, reply);
678a21c0191f974a0b9cbd5818052e2655e0aaa306Pawin Vongmasa            audio_io_config_event event = (audio_io_config_event)data.readInt32();
68f933441648ef6a71dee783d733aac17b9508b452Andreas Huber            sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
69f933441648ef6a71dee783d733aac17b9508b452Andreas Huber            ioDesc->mIoHandle = (audio_io_handle_t) data.readInt32();
706d332d2cdf6e62c2c20ebff220868fe9e3ed7f44Chong Zhang            ioDesc->mSamplingRate = data.readInt32();
716d332d2cdf6e62c2c20ebff220868fe9e3ed7f44Chong Zhang            ioDesc->mFormat = (audio_format_t) data.readInt32();
726e6d429f8001e831b23c3505824e016a681fcf90Lajos Molnar            ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32();
736e6d429f8001e831b23c3505824e016a681fcf90Lajos Molnar            ioDesc->mFrameCount = data.readInt64();
746e6d429f8001e831b23c3505824e016a681fcf90Lajos Molnar            ioDesc->mLatency = data.readInt32();
756e6d429f8001e831b23c3505824e016a681fcf90Lajos Molnar            ioConfigChanged(event, ioDesc);
76251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung            return NO_ERROR;
77251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung        } break;
78251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung        default:
79251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung            return BBinder::onTransact(code, data, reply, flags);
80251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung    }
81251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung}
82251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung
83251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung// ----------------------------------------------------------------------------
84251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung
85251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung} // namespace android
86251d4be8aa5ab80bc915a82a2420233bdc62018eAndy Hung