  // =========================================================================
  
  AudioTrack::AudioTrackThread::AudioTrackThread(AudioTrack& receiver, bool bCanCallJava)
-diff --git a/frameworks/av/media/libmedia/IAudioFlinger.cpp b/frameworks/av/media/libmedia/IAudioFlinger.cpp
-index 448a82e..bad1250 100644
---- a/frameworks/av/media/libmedia/IAudioFlinger.cpp
-+++ b/frameworks/av/media/libmedia/IAudioFlinger.cpp
-@@ -56,6 +56,10 @@ enum {
-     CLOSE_OUTPUT,
-     SUSPEND_OUTPUT,
-     RESTORE_OUTPUT,
-+#ifdef STE_AUDIO
-+    ADD_INPUT_CLIENT,
-+    REMOVE_INPUT_CLIENT,
-+#endif
-     OPEN_INPUT,
-     CLOSE_INPUT,
-     SET_STREAM_OUTPUT,
-@@ -74,6 +78,9 @@ enum {
-     GET_PRIMARY_OUTPUT_SAMPLING_RATE,
-     GET_PRIMARY_OUTPUT_FRAME_COUNT,
-     SET_LOW_RAM_DEVICE,
-+#ifdef STE_AUDIO
-+    READ_INPUT,
-+#endif
- };
- 
- class BpAudioFlinger : public BpInterface<IAudioFlinger>
-@@ -463,11 +470,36 @@ public:
-         return reply.readInt32();
-     }
- 
-+#ifdef STE_AUDIO
-+    virtual uint32_t *addInputClient(uint32_t clientId)
-+    {
-+        Parcel data, reply;
-+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
-+        data.writeInt32(clientId);
-+        remote()->transact(ADD_INPUT_CLIENT, data, &reply);
-+        return (uint32_t*) reply.readIntPtr();
-+    }
-+
-+    virtual status_t removeInputClient(uint32_t *pClientId)
-+    {
-+        Parcel data, reply;
-+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
-+        data.writeIntPtr((intptr_t)pClientId);
-+        remote()->transact(REMOVE_INPUT_CLIENT, data, &reply);
-+        return reply.readInt32();
-+    }
-+#endif
-+
-     virtual audio_io_handle_t openInput(audio_module_handle_t module,
-                                         audio_devices_t *pDevices,
-                                         uint32_t *pSamplingRate,
-                                         audio_format_t *pFormat,
-+#ifdef STE_AUDIO
-+                                        audio_channel_mask_t *pChannelMask,
-+                                        audio_input_clients *pInputClientId)
-+#else
-                                         audio_channel_mask_t *pChannelMask)
-+#endif
-     {
-         Parcel data, reply;
-         audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
-@@ -482,6 +514,9 @@ public:
-         data.writeInt32(samplingRate);
-         data.writeInt32(format);
-         data.writeInt32(channelMask);
-+#ifdef STE_AUDIO
-+        data.writeIntPtr((intptr_t)pInputClientId);
-+#endif
-         remote()->transact(OPEN_INPUT, data, &reply);
-         audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
-         devices = (audio_devices_t)reply.readInt32();
-@@ -495,7 +530,11 @@ public:
-         return input;
-     }
- 
-+#ifdef STE_AUDIO
-+    virtual status_t closeInput(int input, audio_input_clients *inputClientId)
-+#else
-     virtual status_t closeInput(int input)
-+#endif
-     {
-         Parcel data, reply;
-         data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
-@@ -553,6 +592,22 @@ public:
-         return reply.readInt32();
-     }
- 
-+#ifdef STE_AUDIO
-+    virtual size_t readInput(audio_io_handle_t input, audio_input_clients inputClientId,
-+            void *buffer, uint32_t bytes, uint32_t *pOverwrittenBytes)
-+    {
-+        Parcel data, reply;
-+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
-+        data.writeInt32(input);
-+        data.writeInt32((uint32_t) inputClientId);
-+        data.writeIntPtr((intptr_t) buffer);
-+        data.writeInt32(bytes);
-+        data.writeIntPtr((intptr_t) pOverwrittenBytes);
-+        remote()->transact(READ_INPUT, data, &reply);
-+        return reply.readInt32();
-+    }
-+#endif
-+
-     virtual int newAudioSessionId()
-     {
-         Parcel data, reply;
-@@ -969,6 +1024,20 @@ status_t BnAudioFlinger::onTransact(
-             reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
-             return NO_ERROR;
-         } break;
-+#ifdef STE_AUDIO
-+        case ADD_INPUT_CLIENT: {
-+            CHECK_INTERFACE(IAudioFlinger, data, reply);
-+            uint32_t clientId = data.readInt32();
-+            reply->writeIntPtr((intptr_t)addInputClient(clientId));
-+            return NO_ERROR;
-+        } break;
-+        case REMOVE_INPUT_CLIENT: {
-+            CHECK_INTERFACE(IAudioFlinger, data, reply);
-+            uint32_t *pClientId = (uint32_t*) data.readIntPtr();
-+            reply->writeInt32(removeInputClient(pClientId));
-+            return NO_ERROR;
-+        } break;
-+#endif
-         case OPEN_INPUT: {
-             CHECK_INTERFACE(IAudioFlinger, data, reply);
-             audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
-@@ -976,12 +1045,20 @@ status_t BnAudioFlinger::onTransact(
-             uint32_t samplingRate = data.readInt32();
-             audio_format_t format = (audio_format_t) data.readInt32();
-             audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
-+#ifdef STE_AUDIO
-+            audio_input_clients *inputClientId = (audio_input_clients*) data.readIntPtr();
-+#endif
- 
-             audio_io_handle_t input = openInput(module,
-                                              &devices,
-                                              &samplingRate,
-                                              &format,
-+#ifdef STE_AUDIO
-+                                             &channelMask,
-+                                             inputClientId);
-+#else
-                                              &channelMask);
-+#endif
-             reply->writeInt32((int32_t) input);
-             reply->writeInt32(devices);
-             reply->writeInt32(samplingRate);
-@@ -991,7 +1068,13 @@ status_t BnAudioFlinger::onTransact(
-         } break;
-         case CLOSE_INPUT: {
-             CHECK_INTERFACE(IAudioFlinger, data, reply);
-+#ifdef STE_AUDIO
-+            uint32_t input = data.readInt32();
-+            audio_input_clients *inputClientId = (audio_input_clients*) data.readIntPtr();
-+            reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32(), inputClientId));
-+#else
-             reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
-+#endif
-             return NO_ERROR;
-         } break;
-         case SET_STREAM_OUTPUT: {
-@@ -1125,6 +1208,18 @@ status_t BnAudioFlinger::onTransact(
-             reply->writeInt32(setLowRamDevice(isLowRamDevice));
-             return NO_ERROR;
-         } break;
-+#ifdef STE_AUDIO
-+        case READ_INPUT: {
-+            CHECK_INTERFACE(IAudioFlinger, data, reply);
-+            audio_io_handle_t input = data.readInt32();
-+            audio_input_clients inputClientId = (audio_input_clients) data.readInt32();
-+            void* buffer = (void*) data.readIntPtr();
-+            uint32_t bytes = data.readInt32();
-+            uint32_t *pOverwrittenBytes = (uint32_t*) data.readIntPtr();
-+            reply->writeInt32(readInput(input, inputClientId, buffer, bytes, pOverwrittenBytes));
-+            return NO_ERROR;
-+        } break;
-+#endif
-         default:
-             return BBinder::onTransact(code, data, reply, flags);
-     }
+
 diff --git a/frameworks/av/media/libmedia/IAudioPolicyService.cpp b/frameworks/av/media/libmedia/IAudioPolicyService.cpp
 index 4be3c09..5397875 100644
 --- a/frameworks/av/media/libmedia/IAudioPolicyService.cpp

     volatile    int32_t     mFlags;         // combinations of CBLK_*
 
                 // Cache line boundary (32 bytes)
diff --git a/frameworks/av/media/libmedia/AudioParameter.cpp b/frameworks/av/media/libmedia/AudioParameter.cpp
index e3fea77..6c84355 100644
--- a/frameworks/av/media/libmedia/AudioParameter.cpp
+++ b/frameworks/av/media/libmedia/AudioParameter.cpp
@@ -32,6 +32,9 @@ const char * const AudioParameter::keyChannels = AUDIO_PARAMETER_STREAM_CHANNELS
 const char * const AudioParameter::keyFrameCount = AUDIO_PARAMETER_STREAM_FRAME_COUNT;
 const char * const AudioParameter::keyInputSource = AUDIO_PARAMETER_STREAM_INPUT_SOURCE;
 const char * const AudioParameter::keyScreenState = AUDIO_PARAMETER_KEY_SCREEN_STATE;
+#ifdef STE_AUDIO
+const char *AudioParameter::keySinkLatency = "sink_latency";
+#endif
 
 AudioParameter::AudioParameter(const String8& keyValuePairs)
 {
diff --git a/frameworks/av/media/libmedia/AudioRecord.cpp b/frameworks/av/media/libmedia/AudioRecord.cpp
index 666fafa..0a15c5b 100644
--- a/frameworks/av/media/libmedia/AudioRecord.cpp

 
 status_t AudioFlinger::closeInput_nonvirtual(audio_io_handle_t input)
 {

diff --git a/frameworks/av/services/audioflinger/AudioPolicyService.cpp b/frameworks/av/services/audioflinger/AudioPolicyService.cpp
index 7f40812..352ba8b 100644
--- a/frameworks/av/services/audioflinger/AudioPolicyService.cpp
