IAudioFlingerClient.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2009 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #define LOG_TAG "IAudioFlingerClient"
  17. #include <utils/Log.h>
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <binder/Parcel.h>
  21. #include <media/IAudioFlingerClient.h>
  22. #include <media/AudioSystem.h>
  23. namespace android {
  24. enum {
  25. IO_CONFIG_CHANGED = IBinder::FIRST_CALL_TRANSACTION
  26. };
  27. class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
  28. {
  29. public:
  30. explicit BpAudioFlingerClient(const sp<IBinder>& impl)
  31. : BpInterface<IAudioFlingerClient>(impl)
  32. {
  33. }
  34. void ioConfigChanged(audio_io_config_event event, const sp<AudioIoDescriptor>& ioDesc)
  35. {
  36. Parcel data, reply;
  37. data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
  38. data.writeInt32(event);
  39. data.writeInt32((int32_t)ioDesc->mIoHandle);
  40. data.write(&ioDesc->mPatch, sizeof(struct audio_patch));
  41. data.writeInt32(ioDesc->mSamplingRate);
  42. data.writeInt32(ioDesc->mFormat);
  43. data.writeInt32(ioDesc->mChannelMask);
  44. data.writeInt64(ioDesc->mFrameCount);
  45. data.writeInt64(ioDesc->mFrameCountHAL);
  46. data.writeInt32(ioDesc->mLatency);
  47. data.writeInt32(ioDesc->mPortId);
  48. remote()->transact(IO_CONFIG_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
  49. }
  50. };
  51. IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
  52. // ----------------------------------------------------------------------
  53. status_t BnAudioFlingerClient::onTransact(
  54. uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
  55. {
  56. switch (code) {
  57. case IO_CONFIG_CHANGED: {
  58. CHECK_INTERFACE(IAudioFlingerClient, data, reply);
  59. audio_io_config_event event = (audio_io_config_event)data.readInt32();
  60. sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
  61. ioDesc->mIoHandle = (audio_io_handle_t) data.readInt32();
  62. data.read(&ioDesc->mPatch, sizeof(struct audio_patch));
  63. ioDesc->mSamplingRate = data.readInt32();
  64. ioDesc->mFormat = (audio_format_t) data.readInt32();
  65. ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32();
  66. ioDesc->mFrameCount = data.readInt64();
  67. ioDesc->mFrameCountHAL = data.readInt64();
  68. ioDesc->mLatency = data.readInt32();
  69. ioDesc->mPortId = data.readInt32();
  70. ioConfigChanged(event, ioDesc);
  71. return NO_ERROR;
  72. } break;
  73. default:
  74. return BBinder::onTransact(code, data, reply, flags);
  75. }
  76. }
  77. // ----------------------------------------------------------------------------
  78. } // namespace android