Add AudioSystem::getFrameCountHAL()
And add comments about declaring methods in binder opcode order.
Bug: 28117362
Change-Id: I3c4426fa4bb3ce9c4a207a44d3bb1103d7fef160
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 3a5dee6..bbdf65e 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -104,6 +104,8 @@
return DEAD_OBJECT;
}
+// FIXME Declare in binder opcode order, similarly to IAudioFlinger.h and IAudioFlinger.cpp
+
status_t AudioSystem::muteMicrophone(bool state)
{
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -429,6 +431,27 @@
return af->systemReady();
}
+status_t AudioSystem::getFrameCountHAL(audio_io_handle_t ioHandle,
+ size_t* frameCount)
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return PERMISSION_DENIED;
+ sp<AudioIoDescriptor> desc = getIoDescriptor(ioHandle);
+ if (desc == 0) {
+ *frameCount = af->frameCountHAL(ioHandle);
+ } else {
+ *frameCount = desc->mFrameCountHAL;
+ }
+ if (*frameCount == 0) {
+ ALOGE("AudioSystem::getFrameCountHAL failed for ioHandle %d", ioHandle);
+ return BAD_VALUE;
+ }
+
+ ALOGV("getFrameCountHAL() ioHandle %d, frameCount %zu", ioHandle, *frameCount);
+
+ return NO_ERROR;
+}
+
// ---------------------------------------------------------------------------
@@ -528,10 +551,10 @@
}
}
ALOGV("ioConfigChanged() new config for %s %d samplingRate %u, format %#x "
- "channel mask %#x frameCount %zu deviceId %d",
+ "channel mask %#x frameCount %zu frameCountHAL %zu deviceId %d",
event == AUDIO_OUTPUT_CONFIG_CHANGED ? "output" : "input",
ioDesc->mIoHandle, ioDesc->mSamplingRate, ioDesc->mFormat,
- ioDesc->mChannelMask, ioDesc->mFrameCount, ioDesc->getDeviceId());
+ ioDesc->mChannelMask, ioDesc->mFrameCount, ioDesc->mFrameCountHAL, ioDesc->getDeviceId());
} break;
}
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 7543b60..aa75188 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -81,7 +81,8 @@
LIST_AUDIO_PATCHES,
SET_AUDIO_PORT_CONFIG,
GET_AUDIO_HW_SYNC,
- SYSTEM_READY
+ SYSTEM_READY,
+ FRAME_COUNT_HAL,
};
#define MAX_ITEMS_PER_LIST 1024
@@ -274,6 +275,8 @@
return reply.readInt32();
}
+ // RESERVED for channelCount()
+
virtual audio_format_t format(audio_io_handle_t output) const
{
Parcel data, reply;
@@ -911,6 +914,18 @@
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
return remote()->transact(SYSTEM_READY, data, &reply, IBinder::FLAG_ONEWAY);
}
+ virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ data.writeInt32((int32_t) ioHandle);
+ status_t status = remote()->transact(FRAME_COUNT_HAL, data, &reply);
+ if (status != NO_ERROR) {
+ return 0;
+ }
+ return reply.readInt64();
+ }
+
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -993,6 +1008,9 @@
reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
+
+ // RESERVED for channelCount()
+
case FORMAT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
@@ -1419,6 +1437,11 @@
systemReady();
return NO_ERROR;
} break;
+ case FRAME_COUNT_HAL: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt64( frameCountHAL((audio_io_handle_t) data.readInt32()) );
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index 3429d36..8dca9e9 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -50,6 +50,7 @@
data.writeInt32(ioDesc->mFormat);
data.writeInt32(ioDesc->mChannelMask);
data.writeInt64(ioDesc->mFrameCount);
+ data.writeInt64(ioDesc->mFrameCountHAL);
data.writeInt32(ioDesc->mLatency);
remote()->transact(IO_CONFIG_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
}
@@ -73,6 +74,7 @@
ioDesc->mFormat = (audio_format_t) data.readInt32();
ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32();
ioDesc->mFrameCount = data.readInt64();
+ ioDesc->mFrameCountHAL = data.readInt64();
ioDesc->mLatency = data.readInt32();
ioConfigChanged(event, ioDesc);
return NO_ERROR;