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

Commit 56e61323 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13010426 from 93eb398d to 25Q2-release

Change-Id: I81f4bf6cc96cc05b46c0d2c0fe337784f1569e64
parents 64556bdb 93eb398d
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,6 @@ cc_binary {
        "libaaudioservice",
        "libaaudioservice",
        "libaudioflinger",
        "libaudioflinger",
        "libaudiopolicyservice",
        "libaudiopolicyservice",
        "libmedialogservice",
    ],
    ],


    shared_libs: [
    shared_libs: [
+65 −152
Original line number Original line Diff line number Diff line
@@ -40,7 +40,6 @@
#include "AudioPolicyService.h"
#include "AudioPolicyService.h"
#include "AAudioService.h"
#include "AAudioService.h"
#include "utility/AAudioUtilities.h"
#include "utility/AAudioUtilities.h"
#include "MediaLogService.h"


using namespace android;
using namespace android;


@@ -48,7 +47,7 @@ using android::media::audio::common::AudioMMapPolicy;
using android::media::audio::common::AudioMMapPolicyInfo;
using android::media::audio::common::AudioMMapPolicyInfo;
using android::media::audio::common::AudioMMapPolicyType;
using android::media::audio::common::AudioMMapPolicyType;


int main(int argc __unused, char **argv)
int main(int argc __unused, char **argv __unused)
{
{
    ALOGD("%s: starting", __func__);
    ALOGD("%s: starting", __func__);
    const auto startTime = std::chrono::steady_clock::now();
    const auto startTime = std::chrono::steady_clock::now();
@@ -60,91 +59,6 @@ int main(int argc __unused, char **argv)


    signal(SIGPIPE, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);


#if 1
    // FIXME See bug 165702394 and bug 168511485
    const bool doLog = false;
#else
    bool doLog = (bool) property_get_bool("ro.test_harness", 0);
#endif

    pid_t childPid;
    // FIXME The advantage of making the process containing media.log service the parent process of
    // the process that contains the other audio services, is that it allows us to collect more
    // detailed information such as signal numbers, stop and continue, resource usage, etc.
    // But it is also more complex.  Consider replacing this by independent processes, and using
    // binder on death notification instead.
    if (doLog && (childPid = fork()) != 0) {
        // media.log service
        //prctl(PR_SET_NAME, (unsigned long) "media.log", 0, 0, 0);
        // unfortunately ps ignores PR_SET_NAME for the main thread, so use this ugly hack
        strcpy(argv[0], "media.log");
        sp<ProcessState> proc(ProcessState::self());
        MediaLogService::instantiate();
        ProcessState::self()->startThreadPool();
        IPCThreadState::self()->joinThreadPool();
        for (;;) {
            siginfo_t info;
            int ret = TEMP_FAILURE_RETRY(waitid(P_PID, childPid, &info,
                                                WEXITED | WSTOPPED | WCONTINUED));
            if (ret < 0) {
                break;
            }
            char buffer[32];
            const char *code;
            switch (info.si_code) {
            case CLD_EXITED:
                code = "CLD_EXITED";
                break;
            case CLD_KILLED:
                code = "CLD_KILLED";
                break;
            case CLD_DUMPED:
                code = "CLD_DUMPED";
                break;
            case CLD_STOPPED:
                code = "CLD_STOPPED";
                break;
            case CLD_TRAPPED:
                code = "CLD_TRAPPED";
                break;
            case CLD_CONTINUED:
                code = "CLD_CONTINUED";
                break;
            default:
                snprintf(buffer, sizeof(buffer), "unknown (%d)", info.si_code);
                code = buffer;
                break;
            }
            struct rusage usage;
            getrusage(RUSAGE_CHILDREN, &usage);
            ALOG(LOG_ERROR, "media.log", "pid %d status %d code %s user %ld.%03lds sys %ld.%03lds",
                    info.si_pid, info.si_status, code,
                    usage.ru_utime.tv_sec, usage.ru_utime.tv_usec / 1000,
                    usage.ru_stime.tv_sec, usage.ru_stime.tv_usec / 1000);
            sp<IServiceManager> sm = defaultServiceManager();
            sp<IBinder> binder = sm->getService(String16("media.log"));
            if (binder != 0) {
                Vector<String16> args;
                binder->dump(-1, args);
            }
            switch (info.si_code) {
            case CLD_EXITED:
            case CLD_KILLED:
            case CLD_DUMPED: {
                ALOG(LOG_INFO, "media.log", "exiting");
                _exit(0);
                // not reached
                }
            default:
                break;
            }
        }
    } else {
        // all other services
        if (doLog) {
            prctl(PR_SET_PDEATHSIG, SIGKILL);   // if parent media.log dies before me, kill me also
            setpgid(0, 0);                      // but if I die first, don't kill my parent
        }
    android::hardware::configureRpcThreadpool(4, false /*callerWillJoin*/);
    android::hardware::configureRpcThreadpool(4, false /*callerWillJoin*/);


    // Ensure threads for possible callbacks.  Note that get_audio_flinger() does
    // Ensure threads for possible callbacks.  Note that get_audio_flinger() does
@@ -212,4 +126,3 @@ int main(int argc __unused, char **argv)
    ALOGI("%s: initialization done in %.3f ms, joining thread pool", __func__, timeTaken);
    ALOGI("%s: initialization done in %.3f ms, joining thread pool", __func__, timeTaken);
    IPCThreadState::self()->joinThreadPool();
    IPCThreadState::self()->joinThreadPool();
}
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -651,7 +651,7 @@ status_t CCodecBufferChannel::attachEncryptedBuffers(
            return -ENOSYS;
            return -ENOSYS;
        }
        }
        // we are dealing with just one cryptoInfo or descrambler.
        // we are dealing with just one cryptoInfo or descrambler.
        std::unique_ptr<CodecCryptoInfo> info = std::move(cryptoInfos->value[0]);
        std::unique_ptr<CodecCryptoInfo> &info = cryptoInfos->value[0];
        if (info == nullptr) {
        if (info == nullptr) {
            ALOGE("Cannot decrypt, CryptoInfos are null.");
            ALOGE("Cannot decrypt, CryptoInfos are null.");
            return -ENOSYS;
            return -ENOSYS;
@@ -700,7 +700,7 @@ status_t CCodecBufferChannel::attachEncryptedBuffers(
            mDecryptDestination, mHeapSeqNum, &dst.nonsecureMemory);
            mDecryptDestination, mHeapSeqNum, &dst.nonsecureMemory);
    for (int i = 0; i < bufferInfos->value.size(); i++) {
    for (int i = 0; i < bufferInfos->value.size(); i++) {
        if (bufferInfos->value[i].mSize > 0) {
        if (bufferInfos->value[i].mSize > 0) {
            std::unique_ptr<CodecCryptoInfo> info = std::move(cryptoInfos->value[cryptoInfoIdx++]);
            std::unique_ptr<CodecCryptoInfo> &info = cryptoInfos->value[cryptoInfoIdx++];
            src.offset = srcOffset;
            src.offset = srcOffset;
            src.size = bufferInfos->value[i].mSize;
            src.size = bufferInfos->value[i].mSize;
            result = mCrypto->decrypt(
            result = mCrypto->decrypt(
+0 −92
Original line number Original line Diff line number Diff line
@@ -271,46 +271,6 @@ AudioTrack::AudioTrack(
        doNotReconnect, maxRequiredSpeed, selectedDeviceId);
        doNotReconnect, maxRequiredSpeed, selectedDeviceId);
}
}


namespace {
    class LegacyCallbackWrapper : public AudioTrack::IAudioTrackCallback {
      const AudioTrack::legacy_callback_t mCallback;
      void * const mData;
      public:
        LegacyCallbackWrapper(AudioTrack::legacy_callback_t callback, void* user)
            : mCallback(callback), mData(user) {}
        size_t onMoreData(const AudioTrack::Buffer & buffer) override {
          AudioTrack::Buffer copy = buffer;
          mCallback(AudioTrack::EVENT_MORE_DATA, mData, static_cast<void*>(&copy));
          return copy.size();
        }
        void onUnderrun() override {
            mCallback(AudioTrack::EVENT_UNDERRUN, mData, nullptr);
        }
        void onLoopEnd(int32_t loopsRemaining) override {
            mCallback(AudioTrack::EVENT_LOOP_END, mData, &loopsRemaining);
        }
        void onMarker(uint32_t markerPosition) override {
            mCallback(AudioTrack::EVENT_MARKER, mData, &markerPosition);
        }
        void onNewPos(uint32_t newPos) override {
            mCallback(AudioTrack::EVENT_NEW_POS, mData, &newPos);
        }
        void onBufferEnd() override {
            mCallback(AudioTrack::EVENT_BUFFER_END, mData, nullptr);
        }
        void onNewIAudioTrack() override {
            mCallback(AudioTrack::EVENT_NEW_IAUDIOTRACK, mData, nullptr);
        }
        void onStreamEnd() override {
            mCallback(AudioTrack::EVENT_STREAM_END, mData, nullptr);
        }
        size_t onCanWriteMoreData(const AudioTrack::Buffer & buffer) override {
          AudioTrack::Buffer copy = buffer;
          mCallback(AudioTrack::EVENT_CAN_WRITE_MORE_DATA, mData, static_cast<void*>(&copy));
          return copy.size();
        }
    };
}
AudioTrack::AudioTrack(
AudioTrack::AudioTrack(
        audio_stream_type_t streamType,
        audio_stream_type_t streamType,
        uint32_t sampleRate,
        uint32_t sampleRate,
@@ -718,58 +678,6 @@ status_t AudioTrack::set(
    return logIfErrorAndReturnStatus(status, "");
    return logIfErrorAndReturnStatus(status, "");
}
}



status_t AudioTrack::set(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
        audio_format_t format,
        uint32_t channelMask,
        size_t frameCount,
        audio_output_flags_t flags,
        legacy_callback_t callback,
        void* user,
        int32_t notificationFrames,
        const sp<IMemory>& sharedBuffer,
        bool threadCanCallJava,
        audio_session_t sessionId,
        transfer_type transferType,
        const audio_offload_info_t *offloadInfo,
        uid_t uid,
        pid_t pid,
        const audio_attributes_t* pAttributes,
        bool doNotReconnect,
        float maxRequiredSpeed,
        audio_port_handle_t selectedDeviceId)
{
    AttributionSourceState attributionSource;
    auto attributionSourceUid = legacy2aidl_uid_t_int32_t(uid);
    if (!attributionSourceUid.ok()) {
        return logIfErrorAndReturnStatus(
                BAD_VALUE,
                StringPrintf("%s: received invalid attribution source uid, uid: %d, session id: %d",
                             __func__, uid, sessionId));
    }
    attributionSource.uid = attributionSourceUid.value();
    auto attributionSourcePid = legacy2aidl_pid_t_int32_t(pid);
    if (!attributionSourcePid.ok()) {
        return logIfErrorAndReturnStatus(
                BAD_VALUE,
                StringPrintf("%s: received invalid attribution source pid, pid: %d, sessionId: %d",
                             __func__, pid, sessionId));
    }
    attributionSource.pid = attributionSourcePid.value();
    attributionSource.token = sp<BBinder>::make();
    if (callback) {
        mLegacyCallbackWrapper = sp<LegacyCallbackWrapper>::make(callback, user);
    } else if (user) {
        LOG_ALWAYS_FATAL("Callback data provided without callback pointer!");
    }
    return set(streamType, sampleRate, format, static_cast<audio_channel_mask_t>(channelMask),
               frameCount, flags, mLegacyCallbackWrapper, notificationFrames, sharedBuffer,
               threadCanCallJava, sessionId, transferType, offloadInfo, attributionSource,
               pAttributes, doNotReconnect, maxRequiredSpeed, selectedDeviceId);
}

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


status_t AudioTrack::start()
status_t AudioTrack::start()
+0 −1
Original line number Original line Diff line number Diff line
@@ -698,7 +698,6 @@ private:
    // for client callback handler
    // for client callback handler


    wp<IAudioRecordCallback> mCallback;
    wp<IAudioRecordCallback> mCallback;
    sp<IAudioRecordCallback> mLegacyCallbackWrapper;


    bool                    mInitialized = false;   // Protect against double set
    bool                    mInitialized = false;   // Protect against double set
    // for notification APIs
    // for notification APIs
Loading