diff options
| -rw-r--r-- | core/jni/android_view_InputEventReceiver.cpp | 2 | ||||
| -rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 4 | ||||
| -rw-r--r-- | libs/rs/rs.h (renamed from libs/rs/RenderScript.h) | 2 | ||||
| -rw-r--r-- | libs/rs/rsDefines.h (renamed from libs/rs/RenderScriptDefines.h) | 0 | ||||
| -rw-r--r-- | libs/rs/rsEnv.h (renamed from libs/rs/RenderScriptEnv.h) | 0 | ||||
| -rw-r--r-- | libs/rs/rsFileA3D.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsFont.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsMesh.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsPath.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsSampler.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsScriptC.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsThreadIO.cpp | 37 | ||||
| -rw-r--r-- | libs/rs/rsThreadIO.h | 17 | ||||
| -rw-r--r-- | libs/rs/rsUtils.h | 2 | ||||
| -rw-r--r-- | libs/rs/rs_hal.h | 2 | ||||
| -rw-r--r-- | libs/rs/rsg_generator.c | 163 | ||||
| -rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 22 | ||||
| -rw-r--r-- | services/audioflinger/AudioMixer.cpp | 3 | ||||
| -rw-r--r-- | services/audioflinger/AudioMixer.h | 28 | ||||
| -rw-r--r-- | services/java/com/android/server/wm/WindowManagerService.java | 17 |
20 files changed, 195 insertions, 116 deletions
diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index ee41398bfa22..9df280d3a0ab 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -264,7 +264,7 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr, sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); status_t status = receiver->finishInputEvent(seq, handled); - if (status) { + if (status && status != DEAD_OBJECT) { String8 message; message.appendFormat("Failed to finish input event. status=%d", status); jniThrowRuntimeException(env, message.string()); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 2d8c416d8054..9fcd3cebd854 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -41,8 +41,8 @@ #include "android_runtime/android_view_Surface.h" #include "android_runtime/android_util_AssetManager.h" -#include <RenderScript.h> -#include <RenderScriptEnv.h> +#include <rs.h> +#include <rsEnv.h> #include <gui/SurfaceTexture.h> #include <gui/SurfaceTextureClient.h> #include <android_runtime/android_graphics_SurfaceTexture.h> diff --git a/libs/rs/RenderScript.h b/libs/rs/rs.h index 6d5426882bda..fbcaf4a2e413 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/rs.h @@ -24,7 +24,7 @@ extern "C" { #endif -#include "RenderScriptDefines.h" +#include "rsDefines.h" // // A3D loading and object update code. diff --git a/libs/rs/RenderScriptDefines.h b/libs/rs/rsDefines.h index 990ef266f7ec..990ef266f7ec 100644 --- a/libs/rs/RenderScriptDefines.h +++ b/libs/rs/rsDefines.h diff --git a/libs/rs/RenderScriptEnv.h b/libs/rs/rsEnv.h index b82eaf1d6c59..b82eaf1d6c59 100644 --- a/libs/rs/RenderScriptEnv.h +++ b/libs/rs/rsEnv.h diff --git a/libs/rs/rsFileA3D.h b/libs/rs/rsFileA3D.h index 056b5af4c1d5..b0d7509aa7d6 100644 --- a/libs/rs/rsFileA3D.h +++ b/libs/rs/rsFileA3D.h @@ -17,7 +17,7 @@ #ifndef ANDROID_RS_FILE_A3D_H #define ANDROID_RS_FILE_A3D_H -#include "RenderScript.h" +#include "rs.h" #include "rsMesh.h" #include <utils/String8.h> diff --git a/libs/rs/rsFont.h b/libs/rs/rsFont.h index 4ca794dcee1c..88c479534096 100644 --- a/libs/rs/rsFont.h +++ b/libs/rs/rsFont.h @@ -17,7 +17,7 @@ #ifndef ANDROID_RS_FONT_H #define ANDROID_RS_FONT_H -#include "RenderScript.h" +#include "rs.h" #include "rsStream.h" #include <utils/String8.h> #include <utils/Vector.h> diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h index 166b5d3e27c2..8eea4279e3f7 100644 --- a/libs/rs/rsMesh.h +++ b/libs/rs/rsMesh.h @@ -18,7 +18,7 @@ #define ANDROID_RS_MESH_H -#include "RenderScript.h" +#include "rs.h" // --------------------------------------------------------------------------- namespace android { diff --git a/libs/rs/rsPath.h b/libs/rs/rsPath.h index dac795ef44b3..7c055037d5ab 100644 --- a/libs/rs/rsPath.h +++ b/libs/rs/rsPath.h @@ -18,7 +18,7 @@ #define ANDROID_RS_PATH_H -#include "RenderScript.h" +#include "rs.h" // --------------------------------------------------------------------------- namespace android { diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index 654cd9ce1a06..013e4ca32370 100644 --- a/libs/rs/rsSampler.h +++ b/libs/rs/rsSampler.h @@ -18,7 +18,7 @@ #define ANDROID_RS_SAMPLER_H #include "rsAllocation.h" -#include "RenderScript.h" +#include "rs.h" // --------------------------------------------------------------------------- namespace android { diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h index c65a5bf7a06b..fc4df5132c23 100644 --- a/libs/rs/rsScriptC.h +++ b/libs/rs/rsScriptC.h @@ -19,7 +19,7 @@ #include "rsScript.h" -#include "RenderScriptEnv.h" +#include "rsEnv.h" #ifndef ANDROID_RS_SERIALIZE #include "bcinfo/BitcodeTranslator.h" diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index 4f3057317ab9..7182f53a9517 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -31,6 +31,8 @@ using namespace android::renderscript; ThreadIO::ThreadIO() { mRunning = true; + mPureFifo = false; + mMaxInlineSize = 1024; } ThreadIO::~ThreadIO() { @@ -65,6 +67,16 @@ void ThreadIO::clientShutdown() { mToClient.shutdown(); } +void ThreadIO::coreWrite(const void *data, size_t len) { + //ALOGV("core write %p %i", data, (int)len); + mToCore.writeAsync(data, len, true); +} + +void ThreadIO::coreRead(void *data, size_t len) { + //ALOGV("core read %p %i", data, (int)len); + mToCore.read(data, len); +} + void ThreadIO::coreSetReturn(const void *data, size_t dataLen) { uint32_t buf; if (data == NULL) { @@ -91,6 +103,7 @@ void ThreadIO::setTimeoutCallback(void (*cb)(void *), void *dat, uint64_t timeou bool ThreadIO::playCoreCommands(Context *con, int waitFd) { bool ret = false; + const bool isLocal = !isPureFifo(); uint8_t buf[2 * 1024]; const CoreCmdHeader *cmd = (const CoreCmdHeader *)&buf[0]; @@ -120,14 +133,19 @@ bool ThreadIO::playCoreCommands(Context *con, int waitFd) { } if (p[0].revents) { - size_t r = mToCore.read(&buf[0], sizeof(CoreCmdHeader)); - mToCore.read(&buf[sizeof(CoreCmdHeader)], cmd->bytes); - - if (r != sizeof(CoreCmdHeader)) { - // exception or timeout occurred. - break; + size_t r = 0; + if (isLocal) { + r = mToCore.read(&buf[0], sizeof(CoreCmdHeader)); + mToCore.read(&buf[sizeof(CoreCmdHeader)], cmd->bytes); + if (r != sizeof(CoreCmdHeader)) { + // exception or timeout occurred. + break; + } + } else { + r = mToCore.read((void *)&cmd->cmdID, sizeof(cmd->cmdID)); } + ret = true; if (con->props.mLogTimes) { con->timerSet(Context::RS_TIMER_INTERNAL); @@ -138,7 +156,12 @@ bool ThreadIO::playCoreCommands(Context *con, int waitFd) { rsAssert(cmd->cmdID < (sizeof(gPlaybackFuncs) / sizeof(void *))); ALOGE("playCoreCommands error con %p, cmd %i", con, cmd->cmdID); } - gPlaybackFuncs[cmd->cmdID](con, data, cmd->bytes); + + if (isLocal) { + gPlaybackFuncs[cmd->cmdID](con, data, cmd->bytes); + } else { + gPlaybackRemoteFuncs[cmd->cmdID](con, this); + } if (con->props.mLogTimes) { con->timerSet(Context::RS_TIMER_IDLE); diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h index 62e3e33efb60..cb7d4abca5c5 100644 --- a/libs/rs/rsThreadIO.h +++ b/libs/rs/rsThreadIO.h @@ -34,6 +34,13 @@ public: void init(); void shutdown(); + size_t getMaxInlineSize() { + return mMaxInlineSize; + } + bool isPureFifo() { + return mPureFifo; + } + // Plays back commands from the client. // Returns true if any commands were processed. bool playCoreCommands(Context *con, int waitFd); @@ -42,8 +49,16 @@ public: void * coreHeader(uint32_t, size_t dataLen); void coreCommit(); + void coreSetReturn(const void *data, size_t dataLen); void coreGetReturn(void *data, size_t dataLen); + void coreWrite(const void *data, size_t len); + void coreRead(void *data, size_t len); + + void asyncSetReturn(const void *data, size_t dataLen); + void asyncGetReturn(void *data, size_t dataLen); + void asyncWrite(const void *data, size_t len); + void asyncRead(void *data, size_t len); RsMessageToClientType getClientHeader(size_t *receiveLen, uint32_t *usrID); @@ -65,6 +80,8 @@ protected: ClientCmdHeader mLastClientHeader; bool mRunning; + bool mPureFifo; + size_t mMaxInlineSize; FifoSocket mToClient; FifoSocket mToCore; diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h index db6f59204d12..a9a992a773ec 100644 --- a/libs/rs/rsUtils.h +++ b/libs/rs/rsUtils.h @@ -34,7 +34,7 @@ #include <math.h> -#include "RenderScript.h" +#include "rs.h" namespace android { namespace renderscript { diff --git a/libs/rs/rs_hal.h b/libs/rs/rs_hal.h index 120112819d8c..e4bf17f3be2a 100644 --- a/libs/rs/rs_hal.h +++ b/libs/rs/rs_hal.h @@ -17,7 +17,7 @@ #ifndef RS_HAL_H #define RS_HAL_H -#include <RenderScriptDefines.h> +#include <rsDefines.h> struct ANativeWindow; diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c index 385c8b58935b..99c305e0702c 100644 --- a/libs/rs/rsg_generator.c +++ b/libs/rs/rsg_generator.c @@ -238,7 +238,7 @@ void printApiCpp(FILE *f) { //fprintf(f, " ALOGE(\"add command %s\\n\");\n", api->name); if (hasInlineDataPointers(api)) { fprintf(f, " RS_CMD_%s *cmd = NULL;\n", api->name); - fprintf(f, " if (dataSize < 1024) {;\n"); + fprintf(f, " if (dataSize < io->getMaxInlineSize()) {;\n"); fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, dataSize + size));\n", api->name, api->name); fprintf(f, " } else {\n"); fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->name, api->name); @@ -252,7 +252,7 @@ void printApiCpp(FILE *f) { const VarType *vt = &api->params[ct2]; needFlush += vt->ptrLevel; if (vt->ptrLevel && hasInlineDataPointers(api)) { - fprintf(f, " if (dataSize < 1024) {\n"); + fprintf(f, " if (dataSize < io->getMaxInlineSize()) {\n"); fprintf(f, " memcpy(payload, %s, %s_length);\n", vt->name, vt->name); fprintf(f, " cmd->%s = (", vt->name); printVarType(f, vt); @@ -272,7 +272,7 @@ void printApiCpp(FILE *f) { fprintf(f, " io->coreCommit();\n"); if (hasInlineDataPointers(api)) { - fprintf(f, " if (dataSize >= 1024) {\n"); + fprintf(f, " if (dataSize >= io->getMaxInlineSize()) {\n"); fprintf(f, " io->coreGetReturn(NULL, 0);\n"); fprintf(f, " }\n"); } else if (api->ret.typeName[0]) { @@ -288,81 +288,71 @@ void printApiCpp(FILE *f) { fprintf(f, "};\n\n"); + // Generate a remote sender function + const char * str = "core"; + if (api->direct) { + str = "async"; + } + fprintf(f, "static "); printFuncDecl(f, api, "RF_", 0, 0); fprintf(f, "\n{\n"); - fprintf(f, " Fifo *f = NULL;\n"); - fprintf(f, " RS_CMD_%s cmd;\n", api->name); - fprintf(f, " const uint32_t cmdSize = sizeof(cmd);\n"); + fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n"); fprintf(f, " const uint32_t cmdID = RS_CMD_ID_%s;\n", api->name); - fprintf(f, " f->writeAsync(&cmdID, sizeof(cmdID));\n"); - fprintf(f, " intptr_t offset = cmdSize;\n"); - fprintf(f, " uint32_t dataSize = 0;\n"); + fprintf(f, " io->%sWrite(&cmdID, sizeof(cmdID));\n\n", str); + for (ct2=0; ct2 < api->paramCount; ct2++) { const VarType *vt = &api->params[ct2]; - if (vt->isConst && vt->ptrLevel) { - switch(vt->ptrLevel) { - case 1: - fprintf(f, " dataSize += %s_length;\n", vt->name); - break; - case 2: - fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name); - fprintf(f, " dataSize += %s_length[ct];\n", vt->name); - fprintf(f, " }\n"); - break; - default: - printf("pointer level not handled!!"); - } + if (vt->ptrLevel == 0) { + fprintf(f, " io->%sWrite(& %s, sizeof(%s));\n", str, vt->name, vt->name); } } fprintf(f, "\n"); for (ct2=0; ct2 < api->paramCount; ct2++) { const VarType *vt = &api->params[ct2]; - switch(vt->ptrLevel) { - case 0: - fprintf(f, " cmd.%s = %s;\n", vt->name, vt->name); - break; - case 1: - fprintf(f, " cmd.%s = (", vt->name); - printVarType(f, vt); - fprintf(f, ")offset;\n"); - fprintf(f, " offset += %s_length;\n", vt->name); - break; - case 2: - fprintf(f, " cmd.%s = (", vt->name); - printVarType(f, vt); - fprintf(f, ")offset;\n"); + if ((vt->ptrLevel == 1) && (vt->isConst)) { + fprintf(f, " io->%sWrite(%s, %s_length);\n", str, vt->name, vt->name); + } + } + fprintf(f, "\n"); + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if ((vt->ptrLevel == 2) && (vt->isConst)) { fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name); - fprintf(f, " offset += %s_length[ct];\n", vt->name); + fprintf(f, " io->%sWrite(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name); fprintf(f, " }\n"); - break; - default: - fprintf(stderr, "pointer level not handled!!"); } } fprintf(f, "\n"); - fprintf(f, " f->writeAsync(&cmd, cmdSize);\n"); for (ct2=0; ct2 < api->paramCount; ct2++) { const VarType *vt = &api->params[ct2]; - if (vt->ptrLevel == 1) { - fprintf(f, " f->writeAsync(%s, %s_length);\n", vt->name, vt->name); + if ((vt->ptrLevel == 1) && (!vt->isConst)) { + fprintf(f, " io->%sGetReturn(%s, %s_length);\n", str, vt->name, vt->name); } - if (vt->ptrLevel == 2) { + } + fprintf(f, "\n"); + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if ((vt->ptrLevel == 2) && (!vt->isConst)) { fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name); - fprintf(f, " f->writeAsync(%s, %s_length[ct]);\n", vt->name, vt->name); - fprintf(f, " offset += %s_length[ct];\n", vt->name); + fprintf(f, " io->%sGetReturn(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name); fprintf(f, " }\n"); } } + fprintf(f, "\n"); if (api->ret.typeName[0]) { fprintf(f, " "); printVarType(f, &api->ret); fprintf(f, " retValue;\n"); - fprintf(f, " f->writeWaitReturn(&retValue, sizeof(retValue));\n"); + fprintf(f, " io->%sGetReturn(&retValue, sizeof(retValue));\n", str); fprintf(f, " return retValue;\n"); + } else /*if (api->sync)*/ { + fprintf(f, " io->%sGetReturn(NULL, 0);\n", str); } fprintf(f, "}\n\n"); } @@ -418,7 +408,6 @@ void printPlaybackCpp(FILE *f) { fprintf(f, "#include \"rsDevice.h\"\n"); fprintf(f, "#include \"rsContext.h\"\n"); fprintf(f, "#include \"rsThreadIO.h\"\n"); - //fprintf(f, "#include \"rsgApiStructs.h\"\n"); fprintf(f, "#include \"rsgApiFuncDecl.h\"\n"); fprintf(f, "\n"); fprintf(f, "namespace android {\n"); @@ -434,8 +423,6 @@ void printPlaybackCpp(FILE *f) { } fprintf(f, "void rsp_%s(Context *con, const void *vp, size_t cmdSizeBytes) {\n", api->name); - - //fprintf(f, " ALOGE(\"play command %s\\n\");\n", api->name); fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name); if (hasInlineDataPointers(api)) { @@ -488,30 +475,40 @@ void printPlaybackCpp(FILE *f) { const ApiEntry * api = &apis[ct]; int needFlush = 0; - fprintf(f, "void rspr_%s(Context *con, Fifo *f, uint8_t *scratch, size_t scratchSize) {\n", api->name); - - //fprintf(f, " ALOGE(\"play command %s\\n\");\n", api->name); + fprintf(f, "void rspr_%s(Context *con, ThreadIO *io) {\n", api->name); fprintf(f, " RS_CMD_%s cmd;\n", api->name); - fprintf(f, " f->read(&cmd, sizeof(cmd));\n"); for (ct2=0; ct2 < api->paramCount; ct2++) { const VarType *vt = &api->params[ct2]; - needFlush += vt->ptrLevel; + if (vt->ptrLevel == 0) { + fprintf(f, " io->coreRead(&cmd.%s, sizeof(cmd.%s));\n", vt->name, vt->name); + } + } + fprintf(f, "\n"); + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; if (vt->ptrLevel == 1) { fprintf(f, " cmd.%s = (", vt->name); printVarType(f, vt); - fprintf(f, ")scratch;\n"); - fprintf(f, " f->read(scratch, cmd.%s_length);\n", vt->name); - fprintf(f, " scratch += cmd.%s_length;\n", vt->name); + fprintf(f, ")malloc(cmd.%s_length);\n", vt->name); + + if (vt->isConst) { + fprintf(f, " if (cmd.%s_length) io->coreRead((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name, vt->name); + } } + } + fprintf(f, "\n"); + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; if (vt->ptrLevel == 2) { - fprintf(f, " size_t sum_%s = 0;\n", vt->name); fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name); - fprintf(f, " ((size_t *)scratch)[ct] = cmd.%s_length[ct];\n", vt->name); - fprintf(f, " sum_%s += cmd.%s_length[ct];\n", vt->name, vt->name); + fprintf(f, " cmd.%s = (", vt->name); + printVarType(f, vt); + fprintf(f, ")malloc(cmd.%s_length[ct]);\n", vt->name); + fprintf(f, " io->coreRead(& cmd.%s, cmd.%s_length[ct]);\n", vt->name, vt->name); fprintf(f, " }\n"); - fprintf(f, " f->read(scratch, sum_%s);\n", vt->name); - fprintf(f, " scratch += sum_%s;\n", vt->name); } } fprintf(f, "\n"); @@ -535,10 +532,42 @@ void printPlaybackCpp(FILE *f) { } fprintf(f, ");\n"); + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if ((vt->ptrLevel == 1) && (!vt->isConst)) { + fprintf(f, " io->coreSetReturn((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name); + } + } + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if ((vt->ptrLevel == 2) && (!vt->isConst)) { + fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name); + fprintf(f, " io->coreSetReturn((void *)cmd.%s[ct], cmd.%s_length[ct]);\n", vt->name, vt->name); + fprintf(f, " }\n"); + } + } + fprintf(f, "\n"); + if (api->ret.typeName[0]) { - fprintf(f, " f->readReturn(&ret, sizeof(ret));\n"); - } else if (needFlush) { - fprintf(f, " f->readReturn(NULL, 0);\n"); + fprintf(f, " io->coreSetReturn(&ret, sizeof(ret));\n"); + } else /*if (needFlush)*/ { + fprintf(f, " io->coreSetReturn(NULL, 0);\n"); + } + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if (vt->ptrLevel == 1) { + fprintf(f, " free((void *)cmd.%s);\n", vt->name); + } + } + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if (vt->ptrLevel == 2) { + fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name); + fprintf(f, " free((void *)cmd.%s);\n", vt->name); + fprintf(f, " }\n"); + } } fprintf(f, "};\n\n"); @@ -608,7 +637,7 @@ int main(int argc, char **argv) { fprintf(f, " uint32_t size;\n"); fprintf(f, "} RsPlaybackRemoteHeader;\n\n"); fprintf(f, "typedef void (*RsPlaybackLocalFunc)(Context *, const void *, size_t sizeBytes);\n"); - fprintf(f, "typedef void (*RsPlaybackRemoteFunc)(Context *, Fifo *, uint8_t *scratch, size_t scratchSize);\n"); + fprintf(f, "typedef void (*RsPlaybackRemoteFunc)(Context *, ThreadIO *);\n"); fprintf(f, "extern RsPlaybackLocalFunc gPlaybackFuncs[%i];\n", apiCount + 1); fprintf(f, "extern RsPlaybackRemoteFunc gPlaybackRemoteFuncs[%i];\n", apiCount + 1); diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 0292bc3eb575..2e2834c3c7f6 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2295,7 +2295,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac uint16_t sendLevel = cblk->getSendLevel_U4_12(); // send level comes from shared memory and so may be corrupt - if (sendLevel >= MAX_GAIN_INT) { + if (sendLevel > MAX_GAIN_INT) { ALOGV("Track send level out of range: %04X", sendLevel); sendLevel = MAX_GAIN_INT; } @@ -2316,25 +2316,21 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac } // Convert volumes from 8.24 to 4.12 format - int16_t left, right, aux; // This additional clamping is needed in case chain->setVolume_l() overshot - uint32_t v_clamped = (vl + (1 << 11)) >> 12; - if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT; - left = int16_t(v_clamped); - v_clamped = (vr + (1 << 11)) >> 12; - if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT; - right = int16_t(v_clamped); + vl = (vl + (1 << 11)) >> 12; + if (vl > MAX_GAIN_INT) vl = MAX_GAIN_INT; + vr = (vr + (1 << 11)) >> 12; + if (vr > MAX_GAIN_INT) vr = MAX_GAIN_INT; - if (va > MAX_GAIN_INT) va = MAX_GAIN_INT; - aux = int16_t(va); + if (va > MAX_GAIN_INT) va = MAX_GAIN_INT; // va is uint32_t, so no need to check for - // XXX: these things DON'T need to be done each time mAudioMixer->setBufferProvider(name, track); mAudioMixer->enable(name); - mAudioMixer->setParameter(name, param, AudioMixer::VOLUME0, (void *)left); - mAudioMixer->setParameter(name, param, AudioMixer::VOLUME1, (void *)right); - mAudioMixer->setParameter(name, param, AudioMixer::AUXLEVEL, (void *)aux); + mAudioMixer->setParameter(name, param, AudioMixer::VOLUME0, (void *)vl); + mAudioMixer->setParameter(name, param, AudioMixer::VOLUME1, (void *)vr); + mAudioMixer->setParameter(name, param, AudioMixer::AUXLEVEL, (void *)va); mAudioMixer->setParameter( name, AudioMixer::TRACK, diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index f3bf9531bcf8..020d62afd99b 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -257,6 +257,7 @@ void AudioMixer::setParameter(int name, int target, int param, void *value) } break; case AUXLEVEL: + //assert(0 <= valueInt && valueInt <= MAX_GAIN_INT); if (track.auxLevel != valueInt) { ALOGV("setParameter(VOLUME, AUXLEVEL: %04x)", valueInt); track.prevAuxLevel = track.auxLevel << 16; @@ -565,7 +566,7 @@ void AudioMixer::volumeStereo(track_t* t, int32_t* out, size_t frameCount, int32 const int16_t vr = t->volume[1]; if (CC_UNLIKELY(aux != NULL)) { - const int16_t va = (int16_t)t->auxLevel; + const int16_t va = t->auxLevel; do { int16_t l = (int16_t)(*temp++ >> 12); int16_t r = (int16_t)(*temp++ >> 12); diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index c3174ae62089..b2102123646e 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -127,32 +127,46 @@ private: int32_t prevVolume[MAX_NUM_CHANNELS]; + // 16-byte boundary + int32_t volumeInc[MAX_NUM_CHANNELS]; - int32_t auxLevel; int32_t auxInc; int32_t prevAuxLevel; + // 16-byte boundary + + int16_t auxLevel; // 0 <= auxLevel <= MAX_GAIN_INT, but signed for mul performance uint16_t frameCount; - uint8_t channelCount : 4; - uint8_t enabled : 1; - uint8_t reserved0 : 3; - uint8_t format; - uint32_t channelMask; + uint8_t channelCount; // 1 or 2, redundant with (needs & NEEDS_CHANNEL_COUNT__MASK) + uint8_t format; // always 16 + uint16_t enabled; // actually bool + uint32_t channelMask; // currently under-used AudioBufferProvider* bufferProvider; - mutable AudioBufferProvider::Buffer buffer; + + // 16-byte boundary + + mutable AudioBufferProvider::Buffer buffer; // 8 bytes hook_t hook; const void* in; // current location in buffer + // 16-byte boundary + AudioResampler* resampler; uint32_t sampleRate; int32_t* mainBuffer; int32_t* auxBuffer; + // 16-byte boundary + uint64_t localTimeFreq; + int64_t padding; + + // 16-byte boundary + bool setResampler(uint32_t sampleRate, uint32_t devSampleRate); bool doesResample() const { return resampler != NULL; } void resetResampler() { if (resampler != NULL) resampler->reset(); } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 1c81bb1debcf..80ef0e602200 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -6377,7 +6377,7 @@ public class WindowManagerService extends IWindowManager.Stub INJECTION_TIMEOUT_MILLIS); Binder.restoreCallingIdentity(ident); - return reportInjectionResult(result); + return reportInjectionResult(result, pid); } /** @@ -6407,7 +6407,7 @@ public class WindowManagerService extends IWindowManager.Stub INJECTION_TIMEOUT_MILLIS); Binder.restoreCallingIdentity(ident); - return reportInjectionResult(result); + return reportInjectionResult(result, pid); } /** @@ -6437,7 +6437,7 @@ public class WindowManagerService extends IWindowManager.Stub INJECTION_TIMEOUT_MILLIS); Binder.restoreCallingIdentity(ident); - return reportInjectionResult(result); + return reportInjectionResult(result, pid); } /** @@ -6458,24 +6458,23 @@ public class WindowManagerService extends IWindowManager.Stub INJECTION_TIMEOUT_MILLIS); Binder.restoreCallingIdentity(ident); - return reportInjectionResult(result); + return reportInjectionResult(result, pid); } - private boolean reportInjectionResult(int result) { + private boolean reportInjectionResult(int result, int pid) { switch (result) { case InputManager.INPUT_EVENT_INJECTION_PERMISSION_DENIED: - Slog.w(TAG, "Input event injection permission denied."); + Slog.w(TAG, "Input event injection from pid " + pid + " permission denied."); throw new SecurityException( "Injecting to another application requires INJECT_EVENTS permission"); case InputManager.INPUT_EVENT_INJECTION_SUCCEEDED: - //Slog.v(TAG, "Input event injection succeeded."); return true; case InputManager.INPUT_EVENT_INJECTION_TIMED_OUT: - Slog.w(TAG, "Input event injection timed out."); + Slog.w(TAG, "Input event injection from pid " + pid + " timed out."); return false; case InputManager.INPUT_EVENT_INJECTION_FAILED: default: - Slog.w(TAG, "Input event injection failed."); + Slog.w(TAG, "Input event injection from pid " + pid + " failed."); return false; } } |