Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be176522 authored by Sudhir Sharma's avatar Sudhir Sharma
Browse files

Merge tag 'AU_LINUX_ANDROID_LA.BF64.1.2.1.05.00.02.066.045' into HEAD

AU_LINUX_ANDROID_LA.BF64.1.2.1.05.00.02.066.045 based on quic/aosp/LA.BF64.1.2.1

* tag 'AU_LINUX_ANDROID_LA.BF64.1.2.1.05.00.02.066.045':
  audiopolicy: Do not route VoIP call to HDMI
  Camera: Revert max camera to 2 from 4
  soundpool: reuse channel for same sample if available
  mpeg2ts: Add support for parsing HEVC stream in MPEG2 TS container
  frameworks/av: Fix include dir for audio defs
  libstagefright: Add check for bits avail to read
  Revert "camera: Remove cameraservice dependencies from CameraHardwareInterface"
  libmediaplayerService: Handle error on Player start

Conflicts:
	media/libstagefright/include/ExtendedUtils.h

Change-Id: Icc47ab2552c1daea16668be90a25903e684a1c33
parents 27dba52d 348a473b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public:
    void nextEvent();
    int nextChannelID() { return mNextEvent.channelID(); }
    void dump();
    int getPrevSampleID(void) { return mPrevSampleID; }

private:
    static void callback(int event, void* user, void *info);
@@ -160,6 +161,7 @@ private:
    int                 mAudioBufferSize;
    unsigned long       mToggle;
    bool                mAutoPaused;
    int                 mPrevSampleID;
};

// application object for managing a pool of sounds
@@ -202,7 +204,7 @@ private:
    sp<Sample> findSample(int sampleID) { return mSamples.valueFor(sampleID); }
    SoundChannel* findChannel (int channelID);
    SoundChannel* findNextChannel (int channelID);
    SoundChannel* allocateChannel_l(int priority);
    SoundChannel* allocateChannel_l(int priority, int sampleID);
    void moveToFront_l(SoundChannel* channel);
    void notify(SoundPoolEvent event);
    void dump();
+44 −25
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ int SoundPool::play(int sampleID, float leftVolume, float rightVolume,
    dump();

    // allocate a channel
    channel = allocateChannel_l(priority);
    channel = allocateChannel_l(priority, sampleID);

    // no channel allocated - return 0
    if (!channel) {
@@ -277,13 +277,25 @@ int SoundPool::play(int sampleID, float leftVolume, float rightVolume,
    return channelID;
}

SoundChannel* SoundPool::allocateChannel_l(int priority)
SoundChannel* SoundPool::allocateChannel_l(int priority, int sampleID)
{
    List<SoundChannel*>::iterator iter;
    SoundChannel* channel = NULL;

    // allocate a channel
    // check if channel for given sampleID still available
    if (!mChannels.empty()) {
        for (iter = mChannels.begin(); iter != mChannels.end(); ++iter) {
            if (sampleID == (*iter)->getPrevSampleID() && (*iter)->state() == SoundChannel::IDLE) {
                channel = *iter;
                mChannels.erase(iter);
                ALOGV("Allocated recycled channel for same sampleID");
                break;
            }
        }
    }

    // allocate any channel
    if (!channel && !mChannels.empty()) {
        iter = mChannels.begin();
        if (priority >= (*iter)->priority()) {
            channel = *iter;
@@ -551,6 +563,7 @@ error:
void SoundChannel::init(SoundPool* soundPool)
{
    mSoundPool = soundPool;
    mPrevSampleID = -1;
}

// call with sound pool lock held
@@ -559,7 +572,7 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
{
    sp<AudioTrack> oldTrack;
    sp<AudioTrack> newTrack;
    status_t status;
    status_t status = NO_ERROR;

    { // scope for the lock
        Mutex::Autolock lock(&mLock);
@@ -605,6 +618,7 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
        }
#endif

        if (!mAudioTrack.get() || mPrevSampleID != sample->sampleID()) {
            // mToggle toggles each time a track is started on a given channel.
            // The toggle is concatenated with the SoundChannel address and passed to AudioTrack
            // as callback user data. This enables the detection of callbacks received from the old
@@ -629,13 +643,17 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
                ALOGE("Error creating AudioTrack");
                goto exit;
            }
        ALOGV("setVolume %p", newTrack.get());
        newTrack->setVolume(leftVolume, rightVolume);
        newTrack->setLoop(0, frameCount, loop);

            // From now on, AudioTrack callbacks received with previous toggle value will be ignored.
            mToggle = toggle;
            mAudioTrack = newTrack;
            ALOGV("using new track %p for sample %d", newTrack.get(), sample->sampleID());
        } else {
            newTrack = mAudioTrack;
            ALOGV("reusing track %p for sample %d", mAudioTrack.get(), sample->sampleID());
        }
        newTrack->setVolume(leftVolume, rightVolume);
        newTrack->setLoop(0, frameCount, loop);

        mPos = 0;
        mSample = sample;
        mChannelID = nextChannelID;
@@ -777,6 +795,7 @@ bool SoundChannel::doStop_l()
        setVolume_l(0, 0);
        ALOGV("stop");
        mAudioTrack->stop();
        mPrevSampleID = mSample->sampleID();
        mSample.clear();
        mState = IDLE;
        mPriority = IDLE_PRIORITY;
+3 −2
Original line number Diff line number Diff line
@@ -1355,7 +1355,7 @@ status_t MediaPlayerService::decode(
    if (cache->wait() != NO_ERROR) goto Exit;

    ALOGV("start");
    player->start();
    if (player->start() != NO_ERROR) goto Exit;

    ALOGV("wait for playback complete");
    cache->wait();
@@ -1410,7 +1410,7 @@ status_t MediaPlayerService::decode(int fd, int64_t offset, int64_t length,
    if (cache->wait() != NO_ERROR) goto Exit;

    ALOGV("start");
    player->start();
    if (player->start() != NO_ERROR) goto Exit;

    ALOGV("wait for playback complete");
    cache->wait();
@@ -2099,6 +2099,7 @@ status_t MediaPlayerService::AudioCache::open(
{
    ALOGV("open(%u, %d, 0x%x, %d, %d)", sampleRate, channelCount, channelMask, format, bufferCount);
    if (mHeap->getHeapID() < 0) {
        ALOGE("Invalid heap Id");
        return NO_INIT;
    }

+1 −1
Original line number Diff line number Diff line
@@ -125,10 +125,10 @@ LOCAL_SHARED_LIBRARIES := \

#QTI FLAC Decoder
ifeq ($(call is-vendor-board-platform,QCOM),true)
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
LOCAL_SRC_FILES += FLACDecoder.cpp
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-flac
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio
LOCAL_CFLAGS := -DQTI_FLAC_DECODER
endif
endif
+64 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include <sys/socket.h>
#include <netdb.h>

#include "include/avc_utils.h"
#include "include/ExtendedUtils.h"

static const int64_t kDefaultAVSyncLateMargin =  40000;
@@ -63,6 +64,10 @@ static const unsigned kMinRtpPort = 1024;
static const unsigned kMaxRtpPort = 65535;

#define ARG_TOUCH(x) (void)x

static const uint8_t kHEVCNalUnitTypeIDR         = 0x13;
static const uint8_t kHEVCNalUnitTypeIDRNoLP     = 0x14;
static const uint8_t kHEVCNalUnitTypeCRA         = 0x15;
static const uint8_t kHEVCNalUnitTypeVidParamSet = 0x20;
static const uint8_t kHEVCNalUnitTypeSeqParamSet = 0x21;
static const uint8_t kHEVCNalUnitTypePicParamSet = 0x22;
@@ -713,6 +718,55 @@ status_t ExtendedUtils::HEVCMuxer::makeHEVCCodecSpecificData(
    return OK;
}

sp<MetaData> ExtendedUtils::MakeHEVCCodecSpecificData(const sp<ABuffer> &accessUnit) {
    const uint8_t *data = accessUnit->data();
    size_t size = accessUnit->size();

    if (data == NULL || size == 0) {
        ALOGE("Invalid HEVC CSD");
        return NULL;
    }

    sp<MetaData> meta = new MetaData;
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_HEVC);
    meta->setData(kKeyHVCC, kTypeHVCC, data, size);

    // Set width & height to minimum (QCIF). This will trigger a port reconfig &
    // the decoder will find the correct dimensions.
    meta->setInt32(kKeyWidth, (int32_t)177);
    meta->setInt32(kKeyHeight, (int32_t)144);

    return meta;
}

bool ExtendedUtils::IsHevcIDR(const sp<ABuffer> &buffer) {
    const uint8_t *data = buffer->data();
    size_t size = buffer->size();

    bool foundRef = false;
    const uint8_t *nalStart;
    size_t nalSize;
    while (!foundRef && getNextNALUnit(&data, &size, &nalStart, &nalSize, true) == OK) {
        if (nalSize == 0) {
            ALOGW("Encountered zero-length HEVC NAL", nalSize);
            return false;
        }

        uint8_t nalType;
        getHEVCNalUnitType(nalStart[0], &nalType);

        switch(nalType) {
        case kHEVCNalUnitTypeIDR:
        case kHEVCNalUnitTypeIDRNoLP:
        case kHEVCNalUnitTypeCRA:
            foundRef = true;
            break;
        }
    }

    return foundRef;
}

bool ExtendedUtils::ShellProp::isAudioDisabled(bool isEncoder) {
    bool retVal = false;
    char disableAudio[PROPERTY_VALUE_MAX];
@@ -1958,6 +2012,16 @@ int32_t ExtendedUtils::HFR::getHFRCapabilities(
    return -1;
}

sp<MetaData> ExtendedUtils::MakeHEVCCodecSpecificData(const sp<ABuffer> &accessUnit) {
    ARG_TOUCH(accessUnit);
    return NULL;
}

bool ExtendedUtils::IsHevcIDR(const sp<ABuffer> &buffer) {
    ARG_TOUCH(buffer);
    return false;
}

bool ExtendedUtils::ShellProp::isAudioDisabled(bool isEncoder) {
    ARG_TOUCH(isEncoder);
    return false;
Loading