diff options
27 files changed, 307 insertions, 114 deletions
diff --git a/camera/tests/Android.mk b/camera/tests/Android.mk index 61385e5..2db4c14 100644 --- a/camera/tests/Android.mk +++ b/camera/tests/Android.mk @@ -14,16 +14,15 @@  LOCAL_PATH:= $(call my-dir)  include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk  LOCAL_SRC_FILES:= \ -	main.cpp \  	ProCameraTests.cpp \  	VendorTagDescriptorTests.cpp  LOCAL_SHARED_LIBRARIES := \  	libutils \  	libcutils \ -	libstlport \  	libcamera_metadata \  	libcamera_client \  	libgui \ @@ -32,14 +31,7 @@ LOCAL_SHARED_LIBRARIES := \  	libdl \  	libbinder -LOCAL_STATIC_LIBRARIES := \ -	libgtest -  LOCAL_C_INCLUDES += \ -	bionic \ -	bionic/libstdc++/include \ -	external/gtest/include \ -	external/stlport/stlport \  	system/media/camera/include \  	system/media/private/camera/include \  	system/media/camera/tests \ diff --git a/camera/tests/main.cpp b/camera/tests/main.cpp deleted file mode 100644 index 8c8c515..0000000 --- a/camera/tests/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - *      http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <gtest/gtest.h> - - -int main(int argc, char **argv) { - -    ::testing::InitGoogleTest(&argc, argv); - -    int ret = RUN_ALL_TESTS(); - -    return ret; -} diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp index db41e0b..36cb612 100644 --- a/drm/common/IDrmManagerService.cpp +++ b/drm/common/IDrmManagerService.cpp @@ -148,7 +148,8 @@ status_t BpDrmManagerService::setDrmServiceListener(      data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());      data.writeInt32(uniqueId); -    data.writeStrongBinder(drmServiceListener->asBinder()); +    data.writeStrongBinder( +        drmServiceListener != NULL ? drmServiceListener->asBinder() : NULL);      remote()->transact(SET_DRM_SERVICE_LISTENER, data, &reply);      return reply.readInt32();  } diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk index aa0ab9b..48ea385 100644 --- a/drm/drmserver/Android.mk +++ b/drm/drmserver/Android.mk @@ -26,7 +26,8 @@ LOCAL_SHARED_LIBRARIES := \      libutils \      liblog \      libbinder \ -    libdl +    libdl \ +    libselinux  LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 63341e0..857d73e 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -29,20 +29,68 @@  #include "DrmManagerService.h"  #include "DrmManager.h" +#include <selinux/android.h> +  using namespace android; +static int selinux_enabled; +static char *drmserver_context;  static Vector<uid_t> trustedUids; -static bool isProtectedCallAllowed() { +const char *const DrmManagerService::drm_perm_labels[] = { +    "consumeRights", +    "setPlaybackStatus", +    "openDecryptSession", +    "closeDecryptSession", +    "initializeDecryptUnit", +    "decrypt", +    "finalizeDecryptUnit", +    "pread" +}; + +const char *DrmManagerService::get_perm_label(drm_perm_t perm) { +    unsigned int index = perm; + +    if (index < 0 || +            index >= (sizeof(drm_perm_labels) / sizeof(drm_perm_labels[0]))) { +        ALOGE("SELinux: Failed to retrieve permission label(perm=%d).\n", perm); +        abort(); +    } +    return drm_perm_labels[index]; +} + +bool DrmManagerService::selinuxIsProtectedCallAllowed(pid_t spid, drm_perm_t perm) { +    if (selinux_enabled <= 0) { +        return true; +    } + +    char *sctx; +    const char *selinux_class = "drmservice"; +    const char *str_perm = get_perm_label(perm); + +    if (getpidcon(spid, &sctx) != 0) { +        ALOGE("SELinux: getpidcon(pid=%d) failed.\n", spid); +        return false; +    } + +    bool allowed = (selinux_check_access(sctx, drmserver_context, selinux_class, +            str_perm, NULL) == 0); +    freecon(sctx); + +    return allowed; +} + +bool DrmManagerService::isProtectedCallAllowed(drm_perm_t perm) {      // TODO      // Following implementation is just for reference.      // Each OEM manufacturer should implement/replace with their own solutions.      IPCThreadState* ipcState = IPCThreadState::self();      uid_t uid = ipcState->getCallingUid(); +    pid_t spid = ipcState->getCallingPid();      for (unsigned int i = 0; i < trustedUids.size(); ++i) {          if (trustedUids[i] == uid) { -            return true; +            return selinuxIsProtectedCallAllowed(spid, perm);          }      }      return false; @@ -60,6 +108,16 @@ void DrmManagerService::instantiate() {          // Add trusted uids here          trustedUids.push(AID_MEDIA);      } + +    selinux_enabled = is_selinux_enabled(); +    if (selinux_enabled > 0 && getcon(&drmserver_context) != 0) { +        ALOGE("SELinux: DrmManagerService failed to get context for DrmManagerService. Aborting.\n"); +        abort(); +    } + +    union selinux_callback cb; +    cb.func_log = selinux_log_callback; +    selinux_set_callback(SELINUX_CB_LOG, cb);  }  DrmManagerService::DrmManagerService() : @@ -151,7 +209,7 @@ int DrmManagerService::checkRightsStatus(  status_t DrmManagerService::consumeRights(              int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {      ALOGV("Entering consumeRights"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(CONSUME_RIGHTS)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve); @@ -160,7 +218,7 @@ status_t DrmManagerService::consumeRights(  status_t DrmManagerService::setPlaybackStatus(              int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {      ALOGV("Entering setPlaybackStatus"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(SET_PLAYBACK_STATUS)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); @@ -208,7 +266,7 @@ status_t DrmManagerService::getAllSupportInfo(  DecryptHandle* DrmManagerService::openDecryptSession(              int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {      ALOGV("Entering DrmManagerService::openDecryptSession"); -    if (isProtectedCallAllowed()) { +    if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) {          return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime);      } @@ -218,7 +276,7 @@ DecryptHandle* DrmManagerService::openDecryptSession(  DecryptHandle* DrmManagerService::openDecryptSession(              int uniqueId, const char* uri, const char* mime) {      ALOGV("Entering DrmManagerService::openDecryptSession with uri"); -    if (isProtectedCallAllowed()) { +    if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) {          return mDrmManager->openDecryptSession(uniqueId, uri, mime);      } @@ -228,7 +286,7 @@ DecryptHandle* DrmManagerService::openDecryptSession(  DecryptHandle* DrmManagerService::openDecryptSession(              int uniqueId, const DrmBuffer& buf, const String8& mimeType) {      ALOGV("Entering DrmManagerService::openDecryptSession for streaming"); -    if (isProtectedCallAllowed()) { +    if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) {          return mDrmManager->openDecryptSession(uniqueId, buf, mimeType);      } @@ -237,7 +295,7 @@ DecryptHandle* DrmManagerService::openDecryptSession(  status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {      ALOGV("Entering closeDecryptSession"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(CLOSE_DECRYPT_SESSION)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->closeDecryptSession(uniqueId, decryptHandle); @@ -246,7 +304,7 @@ status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* dec  status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,              int decryptUnitId, const DrmBuffer* headerInfo) {      ALOGV("Entering initializeDecryptUnit"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(INITIALIZE_DECRYPT_UNIT)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo); @@ -256,7 +314,7 @@ status_t DrmManagerService::decrypt(              int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,              const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {      ALOGV("Entering decrypt"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(DECRYPT)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); @@ -265,7 +323,7 @@ status_t DrmManagerService::decrypt(  status_t DrmManagerService::finalizeDecryptUnit(              int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {      ALOGV("Entering finalizeDecryptUnit"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(FINALIZE_DECRYPT_UNIT)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); @@ -274,7 +332,7 @@ status_t DrmManagerService::finalizeDecryptUnit(  ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,              void* buffer, ssize_t numBytes, off64_t offset) {      ALOGV("Entering pread"); -    if (!isProtectedCallAllowed()) { +    if (!isProtectedCallAllowed(PREAD)) {          return DRM_ERROR_NO_PERMISSION;      }      return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset); diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h index 8bc59b4..45cee2e 100644 --- a/drm/libdrmframework/include/DrmManagerService.h +++ b/drm/libdrmframework/include/DrmManagerService.h @@ -42,9 +42,28 @@ public:      static void instantiate();  private: +    enum drm_perm_t { +        CONSUME_RIGHTS          = 0, +        SET_PLAYBACK_STATUS     = 1, +        OPEN_DECRYPT_SESSION    = 2, +        CLOSE_DECRYPT_SESSION   = 3, +        INITIALIZE_DECRYPT_UNIT = 4, +        DECRYPT                 = 5, +        FINALIZE_DECRYPT_UNIT   = 6, +        PREAD                   = 7, +    }; + +    static const char *const drm_perm_labels[]; +      DrmManagerService();      virtual ~DrmManagerService(); +    static const char *get_perm_label(drm_perm_t perm); + +    static bool selinuxIsProtectedCallAllowed(pid_t spid, drm_perm_t perm); + +    static bool isProtectedCallAllowed(drm_perm_t perm); +  public:      int addUniqueId(bool isNative); diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/libdrmframework/include/PlugInManager.h index c1d019a..466844d 100644 --- a/drm/libdrmframework/include/PlugInManager.h +++ b/drm/libdrmframework/include/PlugInManager.h @@ -234,14 +234,6 @@ private:      }      /** -     * True if the input entry is "." or ".." -     */ -    bool isDotOrDDot(const struct dirent* pEntry) const { -        String8 sName(pEntry->d_name); -        return "." == sName || ".." == sName; -    } - -    /**       * True if input entry is directory       */      bool isDirectory(const struct dirent* pEntry) const { diff --git a/include/media/stagefright/AACWriter.h b/include/media/stagefright/AACWriter.h index df1b053..d22707a 100644 --- a/include/media/stagefright/AACWriter.h +++ b/include/media/stagefright/AACWriter.h @@ -17,6 +17,7 @@  #ifndef AAC_WRITER_H_  #define AAC_WRITER_H_ +#include "foundation/ABase.h"  #include <media/stagefright/MediaWriter.h>  #include <utils/threads.h> diff --git a/include/media/stagefright/ClockEstimator.h b/include/media/stagefright/ClockEstimator.h index 2fd6e75..1455b7f 100644 --- a/include/media/stagefright/ClockEstimator.h +++ b/include/media/stagefright/ClockEstimator.h @@ -19,7 +19,7 @@  #define CLOCK_ESTIMATOR_H_ - +#include "foundation/ABase.h"  #include <utils/RefBase.h>  #include <utils/Vector.h> diff --git a/include/media/stagefright/MediaMuxer.h b/include/media/stagefright/MediaMuxer.h index bbe4303..9da98d9 100644 --- a/include/media/stagefright/MediaMuxer.h +++ b/include/media/stagefright/MediaMuxer.h @@ -22,6 +22,8 @@  #include <utils/Vector.h>  #include <utils/threads.h> +#include "foundation/ABase.h" +  namespace android {  struct ABuffer; diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h index 43b75fd..ffe4f4c 100644 --- a/include/media/stagefright/SurfaceMediaSource.h +++ b/include/media/stagefright/SurfaceMediaSource.h @@ -25,6 +25,8 @@  #include <media/stagefright/MediaSource.h>  #include <media/stagefright/MediaBuffer.h> +#include "foundation/ABase.h" +  namespace android {  // ---------------------------------------------------------------------------- @@ -233,7 +235,7 @@ private:      Condition mMediaBuffersAvailableCondition;      // Avoid copying and equating and default constructor -    DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource); +    DISALLOW_EVIL_CONSTRUCTORS(SurfaceMediaSource);  };  // ---------------------------------------------------------------------------- diff --git a/media/libeffects/loudness/Android.mk b/media/libeffects/loudness/Android.mk index edf964e..70d7984 100644 --- a/media/libeffects/loudness/Android.mk +++ b/media/libeffects/loudness/Android.mk @@ -12,16 +12,12 @@ LOCAL_CFLAGS+= -O2 -fvisibility=hidden  LOCAL_SHARED_LIBRARIES := \  	libcutils \  	liblog \ -	libstlport  LOCAL_MODULE_RELATIVE_PATH := soundfx  LOCAL_MODULE:= libldnhncr  LOCAL_C_INCLUDES := \  	$(call include-path-for, audio-effects) \ -	bionic \ -	bionic/libstdc++/include \ -	external/stlport/stlport - +include external/stlport/libstlport.mk  include $(BUILD_SHARED_LIBRARY) diff --git a/media/libeffects/proxy/Android.mk b/media/libeffects/proxy/Android.mk index b438796..2ba452e 100644 --- a/media/libeffects/proxy/Android.mk +++ b/media/libeffects/proxy/Android.mk @@ -28,7 +28,6 @@ LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libdl libeffects  LOCAL_C_INCLUDES := \          system/media/audio_effects/include \ -        bionic/libc/include \          frameworks/av/media/libeffects/factory  include $(BUILD_SHARED_LIBRARY) diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 0e9d734..4c8a199 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -4557,7 +4557,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {          componentName = matchingCodecs.itemAt(matchIndex).mName.string();          quirks = matchingCodecs.itemAt(matchIndex).mQuirks; -        pid_t tid = androidGetTid(); +        pid_t tid = gettid();          int prevPriority = androidGetThreadPriority(tid);          androidSetThreadPriority(tid, ANDROID_PRIORITY_FOREGROUND);          status_t err = omx->allocateNode(componentName.c_str(), observer, &node); diff --git a/media/libstagefright/codecs/amrnb/dec/Android.mk b/media/libstagefright/codecs/amrnb/dec/Android.mk index b067456..4aa8c17 100644 --- a/media/libstagefright/codecs/amrnb/dec/Android.mk +++ b/media/libstagefright/codecs/amrnb/dec/Android.mk @@ -83,3 +83,24 @@ LOCAL_MODULE := libstagefright_soft_amrdec  LOCAL_MODULE_TAGS := optional  include $(BUILD_SHARED_LIBRARY) + +################################################################################ +include $(CLEAR_VARS) +LOCAL_SRC_FILES := \ +        test/amrnbdec_test.cpp + +LOCAL_C_INCLUDES := \ +        $(LOCAL_PATH)/src \ +        $(LOCAL_PATH)/../common/include \ +        $(call include-path-for, audio-utils) + +LOCAL_STATIC_LIBRARIES := \ +        libstagefright_amrnbdec libsndfile + +LOCAL_SHARED_LIBRARIES := \ +        libstagefright_amrnb_common libaudioutils + +LOCAL_MODULE := libstagefright_amrnbdec_test +LOCAL_MODULE_TAGS := optional + +include $(BUILD_EXECUTABLE) diff --git a/media/libstagefright/codecs/amrnb/dec/test/amrnbdec_test.cpp b/media/libstagefright/codecs/amrnb/dec/test/amrnbdec_test.cpp new file mode 100755 index 0000000..521fe2b --- /dev/null +++ b/media/libstagefright/codecs/amrnb/dec/test/amrnbdec_test.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *  * Redistributions of source code must retain the above copyright + *    notice, this list of conditions and the following disclaimer. + *  * Redistributions in binary form must reproduce the above copyright + *    notice, this list of conditions and the following disclaimer in + *    the documentation and/or other materials provided with the + *    distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <assert.h> + +#include "gsmamr_dec.h" +#include <audio_utils/sndfile.h> + +// Constants for AMR-NB +enum { +    kInputBufferSize = 64, +    kSamplesPerFrame = 160, +    kBitsPerSample = 16, +    kOutputBufferSize = kSamplesPerFrame * kBitsPerSample/8, +    kSampleRate = 8000, +    kChannels = 1, +    kFileHeaderSize = 6 +}; +const uint32_t kFrameSizes[] = {12, 13, 15, 17, 19, 20, 26, 31}; + + +int main(int argc, char *argv[]) { + +    if(argc != 3) { +        fprintf(stderr, "Usage %s <input file> <output file>\n", argv[0]); +        return 1; +    } + +    // Open the input file +    FILE* fpInput = fopen(argv[1], "rb"); +    if (!fpInput) { +        fprintf(stderr, "Could not open %s\n", argv[1]); +        return 1; +    } + +    // Validate the input AMR file +    char header[kFileHeaderSize]; +    int bytesRead = fread(header, 1, kFileHeaderSize, fpInput); +    if (bytesRead != kFileHeaderSize || memcmp(header, "#!AMR\n", kFileHeaderSize)) { +        fprintf(stderr, "Invalid AMR-NB file\n"); +        return 1; +    } + +    // Open the output file +    SF_INFO sfInfo; +    memset(&sfInfo, 0, sizeof(SF_INFO)); +    sfInfo.channels = kChannels; +    sfInfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; +    sfInfo.samplerate = kSampleRate; +    SNDFILE *handle = sf_open(argv[2], SFM_WRITE, &sfInfo); +    if(!handle){ +        fprintf(stderr, "Could not create %s\n", argv[2]); +        return 1; +    } + +    // Create AMR-NB decoder instance +    void* amrHandle; +    int err = GSMInitDecode(&amrHandle, (Word8*)"AMRNBDecoder"); +    if(err != 0){ +        fprintf(stderr, "Error creating AMR-NB decoder instance\n"); +        return 1; +    } + +    //Allocate input buffer +    void *inputBuf = malloc(kInputBufferSize); +    assert(inputBuf != NULL); + +    //Allocate output buffer +    void *outputBuf = malloc(kOutputBufferSize); +    assert(outputBuf != NULL); + + +    // Decode loop +    uint32_t retVal = 0; +    while (1) { +        // Read mode +        uint8_t mode; +        bytesRead = fread(&mode, 1, 1, fpInput); +        if (bytesRead != 1) break; + +        // Find frame type +        Frame_Type_3GPP frameType = (Frame_Type_3GPP)((mode >> 3) & 0x0f); +        if (frameType >= AMR_SID){ +            fprintf(stderr, "Frame type %d not supported\n",frameType); +            retVal = 1; +            break; +        } + +        // Find frame type +        int32_t frameSize = kFrameSizes[frameType]; +        bytesRead = fread(inputBuf, 1, frameSize, fpInput); +        if (bytesRead != frameSize) break; + +        //Decode frame +        int32_t decodeStatus; +        decodeStatus = AMRDecode(amrHandle, frameType, (uint8_t*)inputBuf, +                                 (int16_t*)outputBuf, MIME_IETF); +        if(decodeStatus == -1) { +            fprintf(stderr, "Decoder encountered error\n"); +            retVal = 1; +            break; +        } + +        //Write output to wav +        sf_writef_short(handle, (int16_t*)outputBuf, kSamplesPerFrame); + +    } + +    // Close input and output file +    fclose(fpInput); +    sf_close(handle); + +    //Free allocated memory +    free(inputBuf); +    free(outputBuf); + +    // Close decoder instance +    GSMDecodeFrameExit(&amrHandle); + +    return retVal; +} diff --git a/media/libstagefright/codecs/amrwbenc/Android.mk b/media/libstagefright/codecs/amrwbenc/Android.mk index 64fe8d1..024a292 100644 --- a/media/libstagefright/codecs/amrwbenc/Android.mk +++ b/media/libstagefright/codecs/amrwbenc/Android.mk @@ -86,6 +86,9 @@ LOCAL_SRC_FILES += \  endif +# ARMV5E/Filt_6k_7k_opt.s does not compile with Clang. +LOCAL_CLANG_ASFLAGS_arm += -no-integrated-as +  LOCAL_MODULE := libstagefright_amrwbenc  LOCAL_ARM_MODE := arm diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp index bb55871..cfc37b7 100644 --- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp +++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp @@ -794,13 +794,6 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 /* portIndex */) {                  videoInput.coding_timestamp = (inHeader->nTimeStamp + 500) / 1000;  // in ms                  const uint8_t *inputData = NULL;                  if (mStoreMetaDataInBuffers) { -                    if (inHeader->nFilledLen != 8) { -                        ALOGE("MetaData buffer is wrong size! " -                                "(got %u bytes, expected 8)", inHeader->nFilledLen); -                        mSignalledError = true; -                        notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); -                        return; -                    }                      inputData =                          extractGraphicBuffer(                                  mInputFrameData, (mVideoWidth * mVideoHeight * 3) >> 1, diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp index 400f320..1d0a2f0 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp +++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp @@ -664,13 +664,6 @@ void SoftMPEG4Encoder::onQueueFilled(OMX_U32 /* portIndex */) {          if (inHeader->nFilledLen > 0) {              const uint8_t *inputData = NULL;              if (mStoreMetaDataInBuffers) { -                if (inHeader->nFilledLen != 8) { -                    ALOGE("MetaData buffer is wrong size! " -                            "(got %u bytes, expected 8)", inHeader->nFilledLen); -                    mSignalledError = true; -                    notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); -                    return; -                }                  inputData =                      extractGraphicBuffer(                              mInputFrameData, (mVideoWidth * mVideoHeight * 3) >> 1, diff --git a/media/libstagefright/codecs/on2/h264dec/Android.mk b/media/libstagefright/codecs/on2/h264dec/Android.mk index bf03ad9..e63b6b1 100644 --- a/media/libstagefright/codecs/on2/h264dec/Android.mk +++ b/media/libstagefright/codecs/on2/h264dec/Android.mk @@ -94,6 +94,8 @@ ifeq ($(TARGET_ARCH),arm)      LOCAL_C_INCLUDES += $(LOCAL_PATH)/./omxdl/arm_neon/api \                          $(LOCAL_PATH)/./omxdl/arm_neon/vc/api \                          $(LOCAL_PATH)/./omxdl/arm_neon/vc/m4p10/api +    # h264bsdWriteMacroblock.S does not compile with Clang. +    LOCAL_CLANG_ASFLAGS_arm += -no-integrated-as    endif  endif diff --git a/media/libstagefright/omx/SoftVideoEncoderOMXComponent.cpp b/media/libstagefright/omx/SoftVideoEncoderOMXComponent.cpp index 8bff142..70ec6e4 100644 --- a/media/libstagefright/omx/SoftVideoEncoderOMXComponent.cpp +++ b/media/libstagefright/omx/SoftVideoEncoderOMXComponent.cpp @@ -195,12 +195,12 @@ const uint8_t *SoftVideoEncoderOMXComponent::extractGraphicBuffer(      size_t srcStride;      size_t srcVStride;      if (usingGraphicBuffer) { -        if (srcSize < 4 + sizeof(GraphicBuffer *)) { -            ALOGE("Metadata is too small (%zu vs %zu)", srcSize, 4 + sizeof(GraphicBuffer *)); +        if (srcSize < sizeof(OMX_U32) + sizeof(GraphicBuffer *)) { +            ALOGE("Metadata is too small (%zu vs %zu)", srcSize, sizeof(OMX_U32) + sizeof(GraphicBuffer *));              return NULL;          } -        GraphicBuffer *buffer = *(GraphicBuffer **)(src + 4); +        GraphicBuffer *buffer = *(GraphicBuffer **)(src + sizeof(OMX_U32));          handle = buffer->handle;          format = buffer->format;          srcStride = buffer->stride; @@ -214,12 +214,12 @@ const uint8_t *SoftVideoEncoderOMXComponent::extractGraphicBuffer(      } else {          // TODO: remove this part.  Check if anyone uses this. -        if (srcSize < 4 + sizeof(buffer_handle_t)) { -            ALOGE("Metadata is too small (%zu vs %zu)", srcSize, 4 + sizeof(buffer_handle_t)); +        if (srcSize < sizeof(OMX_U32) + sizeof(buffer_handle_t)) { +            ALOGE("Metadata is too small (%zu vs %zu)", srcSize, sizeof(OMX_U32) + sizeof(buffer_handle_t));              return NULL;          } -        handle = *(buffer_handle_t *)(src + 4); +        handle = *(buffer_handle_t *)(src + sizeof(OMX_U32));          // assume HAL_PIXEL_FORMAT_RGBA_8888          // there is no way to get the src stride without the graphic buffer          format = HAL_PIXEL_FORMAT_RGBA_8888; diff --git a/media/libstagefright/tests/Android.mk b/media/libstagefright/tests/Android.mk index 99b480ad..8d6ff5b 100644 --- a/media/libstagefright/tests/Android.mk +++ b/media/libstagefright/tests/Android.mk @@ -1,8 +1,7 @@  # Build the unit tests.  LOCAL_PATH:= $(call my-dir)  include $(CLEAR_VARS) - -ifneq ($(TARGET_SIMULATOR),true) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk  LOCAL_MODULE := SurfaceMediaSource_test @@ -22,33 +21,23 @@ LOCAL_SHARED_LIBRARIES := \  	libstagefright \  	libstagefright_foundation \  	libstagefright_omx \ -	libstlport \  	libsync \  	libui \  	libutils \  	liblog -LOCAL_STATIC_LIBRARIES := \ -	libgtest \ -	libgtest_main \ -  LOCAL_C_INCLUDES := \ -	bionic \ -	bionic/libstdc++/include \ -	external/gtest/include \ -	external/stlport/stlport \  	frameworks/av/media/libstagefright \  	frameworks/av/media/libstagefright/include \  	$(TOP)/frameworks/native/include/media/openmax \  LOCAL_32_BIT_ONLY := true -include $(BUILD_EXECUTABLE) - -endif +include $(BUILD_NATIVE_TEST)  include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk  LOCAL_MODULE := Utils_test @@ -64,23 +53,14 @@ LOCAL_SHARED_LIBRARIES := \  	libstagefright \  	libstagefright_foundation \  	libstagefright_omx \ -	libstlport \ - -LOCAL_STATIC_LIBRARIES := \ -	libgtest \ -	libgtest_main \  LOCAL_C_INCLUDES := \ -	bionic \ -	bionic/libstdc++/include \ -	external/gtest/include \ -	external/stlport/stlport \  	frameworks/av/include \  	frameworks/av/media/libstagefright \  	frameworks/av/media/libstagefright/include \  	$(TOP)/frameworks/native/include/media/openmax \ -include $(BUILD_EXECUTABLE) +include $(BUILD_NATIVE_TEST)  # Include subdirectory makefiles  # ============================================================ diff --git a/media/libstagefright/timedtext/TimedTextPlayer.h b/media/libstagefright/timedtext/TimedTextPlayer.h index ec8ed25..9cb49ec 100644 --- a/media/libstagefright/timedtext/TimedTextPlayer.h +++ b/media/libstagefright/timedtext/TimedTextPlayer.h @@ -27,7 +27,7 @@  namespace android { -class AMessage; +struct AMessage;  class MediaPlayerBase;  class TimedTextDriver;  class TimedTextSource; diff --git a/media/libstagefright/timedtext/TimedTextSRTSource.h b/media/libstagefright/timedtext/TimedTextSRTSource.h index 598c200..232675e 100644 --- a/media/libstagefright/timedtext/TimedTextSRTSource.h +++ b/media/libstagefright/timedtext/TimedTextSRTSource.h @@ -25,7 +25,7 @@  namespace android { -class AString; +struct AString;  class DataSource;  class MediaBuffer;  class Parcel; diff --git a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp index da405e2..0c39ccf 100644 --- a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp +++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp @@ -43,6 +43,10 @@  namespace android {  // static +const int64_t WifiDisplaySource::kReaperIntervalUs; +const int64_t WifiDisplaySource::kTeardownTriggerTimeouSecs; +const int64_t WifiDisplaySource::kPlaybackSessionTimeoutSecs; +const int64_t WifiDisplaySource::kPlaybackSessionTimeoutUs;  const AString WifiDisplaySource::sUserAgent = MakeUserAgent();  WifiDisplaySource::WifiDisplaySource( diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp index d6d5dd5..96331b5 100644 --- a/media/mtp/MtpDevice.cpp +++ b/media/mtp/MtpDevice.cpp @@ -131,13 +131,22 @@ MtpDevice* MtpDevice::open(const char* deviceName, int fd) {              struct usb_endpoint_descriptor *ep_in_desc = NULL;              struct usb_endpoint_descriptor *ep_out_desc = NULL;              struct usb_endpoint_descriptor *ep_intr_desc = NULL; +            //USB3 add USB_DT_SS_ENDPOINT_COMP as companion descriptor; +            struct usb_ss_ep_comp_descriptor *ep_ss_ep_comp_desc = NULL;              for (int i = 0; i < 3; i++) {                  ep = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter); +                if (ep && ep->bDescriptorType == USB_DT_SS_ENDPOINT_COMP) { +                    ALOGD("Descriptor type is USB_DT_SS_ENDPOINT_COMP for USB3 \n"); +                    ep_ss_ep_comp_desc = (usb_ss_ep_comp_descriptor*)ep; +                    ep = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter); +                 } +                  if (!ep || ep->bDescriptorType != USB_DT_ENDPOINT) {                      ALOGE("endpoints not found\n");                      usb_device_close(device);                      return NULL;                  } +                  if (ep->bmAttributes == USB_ENDPOINT_XFER_BULK) {                      if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)                          ep_in_desc = ep; diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp index d03e578..e6fb76c 100644 --- a/services/audioflinger/AudioResamplerSinc.cpp +++ b/services/audioflinger/AudioResamplerSinc.cpp @@ -31,7 +31,10 @@  #include "AudioResamplerSinc.h" - +#if defined(__clang__) && !__has_builtin(__builtin_assume_aligned) +#define __builtin_assume_aligned(p, a) \ +	(((uintptr_t(p) % (a)) == 0) ? (p) : (__builtin_unreachable(), (p))) +#endif  #if defined(__arm__) && !defined(__thumb__)  #define USE_INLINE_ASSEMBLY (true)  | 
