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

Commit 9a2a1069 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5652708 from e81a326d to qt-release

Change-Id: I944f676abccd040178d011df77c2367a4152fbb2
parents 329075b7 e81a326d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1512,6 +1512,13 @@ status_t AudioSystem::getVolumeGroupFromAudioAttributes(const AudioAttributes &a
    return aps->getVolumeGroupFromAudioAttributes(aa, volumeGroup);
}

status_t AudioSystem::setRttEnabled(bool enabled)
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return PERMISSION_DENIED;
    return aps->setRttEnabled(enabled);
}

// ---------------------------------------------------------------------------

int AudioSystem::AudioPolicyServiceClient::addAudioPortCallback(
+23 −1
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ enum {
    GET_VOLUME_GROUP_FOR_ATTRIBUTES,
    SET_ALLOWED_CAPTURE_POLICY,
    MOVE_EFFECTS_TO_IO,
    SET_RTT_ENABLED
};

#define MAX_ITEMS_PER_LIST 1024
@@ -1271,6 +1272,18 @@ public:
        volumeGroup = static_cast<volume_group_t>(reply.readInt32());
        return NO_ERROR;
    }

    virtual status_t setRttEnabled(bool enabled)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        data.writeInt32(static_cast<int32_t>(enabled));
        status_t status = remote()->transact(SET_RTT_ENABLED, data, &reply);
        if (status != NO_ERROR) {
           return status;
        }
        return static_cast<status_t>(reply.readInt32());
    }
};

IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
@@ -1332,7 +1345,8 @@ status_t BnAudioPolicyService::onTransact(
        case REMOVE_UID_DEVICE_AFFINITY:
        case GET_OFFLOAD_FORMATS_A2DP:
        case LIST_AUDIO_VOLUME_GROUPS:
        case GET_VOLUME_GROUP_FOR_ATTRIBUTES: {
        case GET_VOLUME_GROUP_FOR_ATTRIBUTES:
        case SET_RTT_ENABLED: {
            if (!isServiceUid(IPCThreadState::self()->getCallingUid())) {
                ALOGW("%s: transaction %d received from PID %d unauthorized UID %d",
                      __func__, code, IPCThreadState::self()->getCallingPid(),
@@ -2347,6 +2361,14 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        }

        case SET_RTT_ENABLED: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            bool enabled = static_cast<bool>(data.readInt32());
            status_t status = setRttEnabled(enabled);
            reply->writeInt32(status);
            return NO_ERROR;
        }

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+2 −0
Original line number Diff line number Diff line
@@ -394,6 +394,8 @@ public:
    static status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa,
                                                      volume_group_t &volumeGroup);

    static status_t setRttEnabled(bool enabled);

    // ----------------------------------------------------------------------------

    class AudioVolumeGroupCallback : public RefBase
+2 −0
Original line number Diff line number Diff line
@@ -220,6 +220,8 @@ public:
    virtual status_t listAudioVolumeGroups(AudioVolumeGroupVector &groups) = 0;
    virtual status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa,
                                                       volume_group_t &volumeGroup) = 0;

    virtual status_t setRttEnabled(bool enabled) = 0;
};


+41 −8
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ namespace android {

OggWriter::OggWriter(int fd)
      : mFd(dup(fd)),
        mHaveAllCodecSpecificData(false),
        mInitCheck(mFd < 0 ? NO_INIT : OK) {
    // empty
}
@@ -115,17 +116,26 @@ status_t OggWriter::addSource(const sp<MediaSource>& source) {

    mSampleRate = sampleRate;
    uint32_t type;
    const void *header_data;
    size_t packet_size;
    const void *header_data = NULL;
    size_t packet_size = 0;

    if (!source->getFormat()->findData(kKeyOpusHeader, &type, &header_data, &packet_size)) {
        ALOGE("opus header not found");
        return UNKNOWN_ERROR;
        ALOGV("opus header not found in format");
    } else if (header_data && packet_size) {
        writeOggHeaderPackets((unsigned char *)header_data, packet_size);
    } else {
        ALOGD("ignoring incomplete opus header data in format");
    }

    mSource = source;
    return OK;
}

status_t OggWriter::writeOggHeaderPackets(unsigned char *buf, size_t size) {
    ogg_packet op;
    ogg_page og;
    op.packet = (unsigned char *)header_data;
    op.bytes = packet_size;
    op.packet = buf;
    op.bytes = size;
    op.b_o_s = 1;
    op.e_o_s = 0;
    op.granulepos = 0;
@@ -169,8 +179,8 @@ status_t OggWriter::addSource(const sp<MediaSource>& source) {
        write(mFd, og.body, og.body_len);
    }

    mSource = source;
    free(comments);
    mHaveAllCodecSpecificData = true;
    return OK;
}

@@ -301,12 +311,35 @@ status_t OggWriter::threadFunc() {
             && isCodecSpecific)
            || IsOpusHeader((uint8_t*)buffer->data() + buffer->range_offset(),
                         buffer->range_length())) {
            ALOGV("Drop codec specific info buffer");
            if (mHaveAllCodecSpecificData == false) {
                size_t opusHeadSize = 0;
                size_t codecDelayBufSize = 0;
                size_t seekPreRollBufSize = 0;
                void *opusHeadBuf = NULL;
                void *codecDelayBuf = NULL;
                void *seekPreRollBuf = NULL;
                GetOpusHeaderBuffers((uint8_t*)buffer->data() + buffer->range_offset(),
                                    buffer->range_length(), &opusHeadBuf,
                                    &opusHeadSize, &codecDelayBuf,
                                    &codecDelayBufSize, &seekPreRollBuf,
                                    &seekPreRollBufSize);
                writeOggHeaderPackets((unsigned char *)opusHeadBuf, opusHeadSize);
            } else {
                ALOGV("ignoring later copy of CSD contained in info buffer");
            }
            buffer->release();
            buffer = nullptr;
            continue;
        }

        if (mHaveAllCodecSpecificData == false) {
            ALOGE("Did not get valid opus header before first sample data");
            buffer->release();
            buffer = nullptr;
            err = ERROR_MALFORMED;
            break;
        }

        int64_t timestampUs;
        CHECK(buffer->meta_data().findInt64(kKeyTime, &timestampUs));
        if (timestampUs > mEstimatedDurationUs) {
Loading