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

Commit c7abac43 authored by Phil Burk's avatar Phil Burk
Browse files

audio: reduce logspam from MMAP mode

Bug: 63760826
Test: run CTS nativemedia/aaudio and notice less logging
Change-Id: I04564963f85577a53f40f1bad064f5e79723ac76
parent af842eb7
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -57,7 +57,7 @@ AAudioBinderClient::AAudioBinderClient()
        , Singleton<AAudioBinderClient>() {
        , Singleton<AAudioBinderClient>() {


    mAAudioClient = new AAudioClient(this);
    mAAudioClient = new AAudioClient(this);
    ALOGD("AAudioBinderClient() created mAAudioClient = %p", mAAudioClient.get());
    ALOGV("AAudioBinderClient() created mAAudioClient = %p", mAAudioClient.get());
}
}


AAudioBinderClient::~AAudioBinderClient() {
AAudioBinderClient::~AAudioBinderClient() {
@@ -90,8 +90,11 @@ const sp<IAAudioService> AAudioBinderClient::getAAudioService() {
            if (binder != 0) {
            if (binder != 0) {
                // Ask for notification if the service dies.
                // Ask for notification if the service dies.
                status_t status = binder->linkToDeath(mAAudioClient);
                status_t status = binder->linkToDeath(mAAudioClient);
                ALOGD("getAAudioService: linkToDeath(mAAudioClient = %p) returned %d",
                // TODO review what we should do if this fails
                if (status != NO_ERROR) {
                    ALOGE("getAAudioService: linkToDeath(mAAudioClient = %p) returned %d",
                          mAAudioClient.get(), status);
                          mAAudioClient.get(), status);
                }
                mAAudioService = interface_cast<IAAudioService>(binder);
                mAAudioService = interface_cast<IAAudioService>(binder);
                needToRegister = true;
                needToRegister = true;
                // Make sure callbacks can be received by mAAudioClient
                // Make sure callbacks can be received by mAAudioClient
+6 −12
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ std::string AAudioClientTracker::dump() const {
// Create a tracker for the client.
// Create a tracker for the client.
aaudio_result_t AAudioClientTracker::registerClient(pid_t pid,
aaudio_result_t AAudioClientTracker::registerClient(pid_t pid,
                                         const sp<IAAudioClient>& client) {
                                         const sp<IAAudioClient>& client) {
    ALOGD("AAudioClientTracker::registerClient(), calling pid = %d, getpid() = %d\n",
    ALOGV("AAudioClientTracker::registerClient(), calling pid = %d, getpid() = %d\n",
          pid, getpid());
          pid, getpid());


    std::lock_guard<std::mutex> lock(mLock);
    std::lock_guard<std::mutex> lock(mLock);
@@ -84,7 +84,7 @@ aaudio_result_t AAudioClientTracker::registerClient(pid_t pid,
}
}


void AAudioClientTracker::unregisterClient(pid_t pid) {
void AAudioClientTracker::unregisterClient(pid_t pid) {
    ALOGD("AAudioClientTracker::unregisterClient(), calling pid = %d, getpid() = %d\n",
    ALOGV("AAudioClientTracker::unregisterClient(), calling pid = %d, getpid() = %d\n",
          pid, getpid());
          pid, getpid());
    std::lock_guard<std::mutex> lock(mLock);
    std::lock_guard<std::mutex> lock(mLock);
    mNotificationClients.erase(pid);
    mNotificationClients.erase(pid);
@@ -103,12 +103,12 @@ int32_t AAudioClientTracker::getStreamCount(pid_t pid) {
aaudio_result_t
aaudio_result_t
AAudioClientTracker::registerClientStream(pid_t pid, sp<AAudioServiceStreamBase> serviceStream) {
AAudioClientTracker::registerClientStream(pid_t pid, sp<AAudioServiceStreamBase> serviceStream) {
    aaudio_result_t result = AAUDIO_OK;
    aaudio_result_t result = AAUDIO_OK;
    ALOGD("AAudioClientTracker::registerClientStream(%d, %p)\n", pid, serviceStream.get());
    ALOGV("AAudioClientTracker::registerClientStream(%d, %p)\n", pid, serviceStream.get());
    std::lock_guard<std::mutex> lock(mLock);
    std::lock_guard<std::mutex> lock(mLock);
    sp<NotificationClient> notificationClient = mNotificationClients[pid];
    sp<NotificationClient> notificationClient = mNotificationClients[pid];
    if (notificationClient == 0) {
    if (notificationClient == 0) {
        // This will get called the first time the audio server registers an internal stream.
        // This will get called the first time the audio server registers an internal stream.
        ALOGD("AAudioClientTracker::registerClientStream(%d,) unrecognized pid\n", pid);
        ALOGV("AAudioClientTracker::registerClientStream(%d,) unrecognized pid\n", pid);
        notificationClient = new NotificationClient(pid);
        notificationClient = new NotificationClient(pid);
        mNotificationClients[pid] = notificationClient;
        mNotificationClients[pid] = notificationClient;
    }
    }
@@ -120,11 +120,11 @@ AAudioClientTracker::registerClientStream(pid_t pid, sp<AAudioServiceStreamBase>
aaudio_result_t
aaudio_result_t
AAudioClientTracker::unregisterClientStream(pid_t pid,
AAudioClientTracker::unregisterClientStream(pid_t pid,
                                            sp<AAudioServiceStreamBase> serviceStream) {
                                            sp<AAudioServiceStreamBase> serviceStream) {
    ALOGD("AAudioClientTracker::unregisterClientStream(%d, %p)\n", pid, serviceStream.get());
    ALOGV("AAudioClientTracker::unregisterClientStream(%d, %p)\n", pid, serviceStream.get());
    std::lock_guard<std::mutex> lock(mLock);
    std::lock_guard<std::mutex> lock(mLock);
    auto it = mNotificationClients.find(pid);
    auto it = mNotificationClients.find(pid);
    if (it != mNotificationClients.end()) {
    if (it != mNotificationClients.end()) {
        ALOGD("AAudioClientTracker::unregisterClientStream(%d, %p) found NotificationClient\n",
        ALOGV("AAudioClientTracker::unregisterClientStream(%d, %p) found NotificationClient\n",
              pid, serviceStream.get());
              pid, serviceStream.get());
        it->second->unregisterClientStream(serviceStream);
        it->second->unregisterClientStream(serviceStream);
    } else {
    } else {
@@ -158,11 +158,7 @@ aaudio_result_t AAudioClientTracker::NotificationClient::registerClientStream(
aaudio_result_t AAudioClientTracker::NotificationClient::unregisterClientStream(
aaudio_result_t AAudioClientTracker::NotificationClient::unregisterClientStream(
        sp<AAudioServiceStreamBase> serviceStream) {
        sp<AAudioServiceStreamBase> serviceStream) {
    std::lock_guard<std::mutex> lock(mLock);
    std::lock_guard<std::mutex> lock(mLock);
    ALOGD("AAudioClientTracker::NotificationClient() before erase() count = %d\n",
          (int)mStreams.size());
    mStreams.erase(serviceStream);
    mStreams.erase(serviceStream);
    ALOGD("AAudioClientTracker::NotificationClient() after erase() count = %d\n",
          (int)mStreams.size());
    return AAUDIO_OK;
    return AAUDIO_OK;
}
}


@@ -176,8 +172,6 @@ void AAudioClientTracker::NotificationClient::binderDied(const wp<IBinder>& who


        {
        {
            std::lock_guard<std::mutex> lock(mLock);
            std::lock_guard<std::mutex> lock(mLock);
            ALOGV("AAudioClientTracker::binderDied() pid = %d, # streams = %d\n",
                  mProcessId, (int) mStreams.size());
            for (auto serviceStream : mStreams) {
            for (auto serviceStream : mStreams) {
                streamsToClose.insert(serviceStream);
                streamsToClose.insert(serviceStream);
            }
            }
+3 −3
Original line number Original line Diff line number Diff line
@@ -57,7 +57,6 @@ aaudio_result_t AAudioServiceEndpointPlay::open(const AAudioStreamConfiguration&
            mLatencyTuningEnabled = true;
            mLatencyTuningEnabled = true;
            burstsPerBuffer = BURSTS_PER_BUFFER_DEFAULT;
            burstsPerBuffer = BURSTS_PER_BUFFER_DEFAULT;
        }
        }
        ALOGD("AAudioServiceEndpoint(): burstsPerBuffer = %d", burstsPerBuffer);
        int32_t desiredBufferSize = burstsPerBuffer * getStreamInternal()->getFramesPerBurst();
        int32_t desiredBufferSize = burstsPerBuffer * getStreamInternal()->getFramesPerBurst();
        getStreamInternal()->setBufferSize(desiredBufferSize);
        getStreamInternal()->setBufferSize(desiredBufferSize);
    }
    }
@@ -66,7 +65,6 @@ aaudio_result_t AAudioServiceEndpointPlay::open(const AAudioStreamConfiguration&


// Mix data from each application stream and write result to the shared MMAP stream.
// Mix data from each application stream and write result to the shared MMAP stream.
void *AAudioServiceEndpointPlay::callbackLoop() {
void *AAudioServiceEndpointPlay::callbackLoop() {
    ALOGD("AAudioServiceEndpointPlay(): callbackLoop() entering");
    int32_t underflowCount = 0;
    int32_t underflowCount = 0;
    aaudio_result_t result = AAUDIO_OK;
    aaudio_result_t result = AAUDIO_OK;
    int64_t timeoutNanos = getStreamInternal()->calculateReasonableTimeout();
    int64_t timeoutNanos = getStreamInternal()->calculateReasonableTimeout();
@@ -102,6 +100,8 @@ void *AAudioServiceEndpointPlay::callbackLoop() {
        }
        }
    }
    }


    ALOGD("AAudioServiceEndpointPlay(): callbackLoop() exiting, %d underflows", underflowCount);
    ALOGW_IF((underflowCount > 0),
             "AAudioServiceEndpointPlay(): callbackLoop() had %d underflows", underflowCount);

    return NULL; // TODO review
    return NULL; // TODO review
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -154,9 +154,9 @@ aaudio_result_t AAudioServiceStreamMMAP::open(const aaudio::AAudioStreamRequest
              status);
              status);
        return AAUDIO_ERROR_UNAVAILABLE;
        return AAUDIO_ERROR_UNAVAILABLE;
    } else {
    } else {
        ALOGD("createMmapBuffer status %d shared_address = %p buffer_size %d burst_size %d"
        ALOGD("createMmapBuffer status %d, buffer_size, %d burst_size %d"
                "Sharable FD: %s",
                ", Sharable FD: %s",
              status, mMmapBufferinfo.shared_memory_address,
              status,
              abs(mMmapBufferinfo.buffer_size_frames),
              abs(mMmapBufferinfo.buffer_size_frames),
              mMmapBufferinfo.burst_size_frames,
              mMmapBufferinfo.burst_size_frames,
              mMmapBufferinfo.buffer_size_frames < 0 ? "Yes" : "No");
              mMmapBufferinfo.buffer_size_frames < 0 ? "Yes" : "No");