aaudio: reduce error logging, improve security
Reduce log spam and error logging as part of the Green Log effort.
Replace logging of addresses with integer IDs.
Bug: 36785118
Bug: 122073229
Bug: 130569151
Test: Open an AAudio stream at 44100 and look at logcat.
Test: adb shell write_sine_callback -pl -r44100
Test: adb logcat | grep -i aaudio | grep " E "
Test: Should see no "E" logs from AAudio.
Test: Should see no addresses from AAudio.
Change-Id: I1d4e0bc349095f818fad52603d2bb8e7317d3681
Merged-In: I1d4e0bc349095f818fad52603d2bb8e7317d3681
(cherry picked from commit 7ba46558fbd28b555ba751837cc9094a7c785f75)
diff --git a/services/oboeservice/AAudioClientTracker.cpp b/services/oboeservice/AAudioClientTracker.cpp
index 7264a9b..83704ba 100644
--- a/services/oboeservice/AAudioClientTracker.cpp
+++ b/services/oboeservice/AAudioClientTracker.cpp
@@ -101,7 +101,7 @@
aaudio_result_t
AAudioClientTracker::registerClientStream(pid_t pid, sp<AAudioServiceStreamBase> serviceStream) {
aaudio_result_t result = AAUDIO_OK;
- ALOGV("registerClientStream(%d, %p)\n", pid, serviceStream.get());
+ ALOGV("registerClientStream(%d,)\n", pid);
std::lock_guard<std::mutex> lock(mLock);
sp<NotificationClient> notificationClient = mNotificationClients[pid];
if (notificationClient == 0) {
@@ -118,27 +118,23 @@
aaudio_result_t
AAudioClientTracker::unregisterClientStream(pid_t pid,
sp<AAudioServiceStreamBase> serviceStream) {
- ALOGV("unregisterClientStream(%d, %p)\n", pid, serviceStream.get());
+ ALOGV("unregisterClientStream(%d,)\n", pid);
std::lock_guard<std::mutex> lock(mLock);
auto it = mNotificationClients.find(pid);
if (it != mNotificationClients.end()) {
- ALOGV("unregisterClientStream(%d, %p) found NotificationClient\n",
- pid, serviceStream.get());
+ ALOGV("unregisterClientStream(%d,) found NotificationClient\n", pid);
it->second->unregisterClientStream(serviceStream);
} else {
- ALOGE("unregisterClientStream(%d, %p) missing NotificationClient\n",
- pid, serviceStream.get());
+ ALOGE("unregisterClientStream(%d,) missing NotificationClient\n", pid);
}
return AAUDIO_OK;
}
AAudioClientTracker::NotificationClient::NotificationClient(pid_t pid)
: mProcessId(pid) {
- //ALOGD("NotificationClient(%d) created %p\n", pid, this);
}
AAudioClientTracker::NotificationClient::~NotificationClient() {
- //ALOGD("~NotificationClient() destroyed %p\n", this);
}
int32_t AAudioClientTracker::NotificationClient::getStreamCount() {
diff --git a/services/oboeservice/AAudioService.cpp b/services/oboeservice/AAudioService.cpp
index 2fbaeb4..e6a8375 100644
--- a/services/oboeservice/AAudioService.cpp
+++ b/services/oboeservice/AAudioService.cpp
@@ -132,11 +132,10 @@
if (result != AAUDIO_OK) {
serviceStream.clear();
- ALOGW("openStream(): failed, return %d = %s", result, AAudio_convertResultToText(result));
return result;
} else {
aaudio_handle_t handle = mStreamTracker.addStreamForHandle(serviceStream.get());
- ALOGD("openStream(): handle = 0x%08X", handle);
+ ALOGV("openStream(): handle = 0x%08X", handle);
serviceStream->setHandle(handle);
pid_t pid = request.getProcessId();
AAudioClientTracker::getInstance().registerClientStream(pid, serviceStream);
diff --git a/services/oboeservice/AAudioServiceEndpoint.cpp b/services/oboeservice/AAudioServiceEndpoint.cpp
index 4dfb62a..553754e 100644
--- a/services/oboeservice/AAudioServiceEndpoint.cpp
+++ b/services/oboeservice/AAudioServiceEndpoint.cpp
@@ -90,7 +90,8 @@
std::lock_guard<std::mutex> lock(mLockStreams);
mConnected.store(false);
for (const auto& stream : mRegisteredStreams) {
- ALOGD("disconnectRegisteredStreams() stop and disconnect %p", stream.get());
+ ALOGD("disconnectRegisteredStreams() stop and disconnect port %d",
+ stream->getPortHandle());
stream->stop();
stream->disconnect();
}
diff --git a/services/oboeservice/AAudioServiceEndpoint.h b/services/oboeservice/AAudioServiceEndpoint.h
index 3616fa2..a2f66a5 100644
--- a/services/oboeservice/AAudioServiceEndpoint.h
+++ b/services/oboeservice/AAudioServiceEndpoint.h
@@ -61,7 +61,7 @@
virtual aaudio_result_t startClient(const android::AudioClient& client,
audio_port_handle_t *clientHandle) {
- ALOGD("AAudioServiceEndpoint::startClient(%p, ...) AAUDIO_ERROR_UNAVAILABLE", &client);
+ ALOGD("AAudioServiceEndpoint::startClient(...) AAUDIO_ERROR_UNAVAILABLE");
return AAUDIO_ERROR_UNAVAILABLE;
}
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index fbf7d10..447f32c 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -163,7 +163,9 @@
ALOGD("%s() mMapClient.uid = %d, pid = %d => portHandle = %d\n",
__func__, mMmapClient.clientUid, mMmapClient.clientPid, mPortHandle);
if (status != OK) {
- ALOGE("%s() - openMmapStream() returned status %d", __func__, status);
+ // This can happen if the resource is busy or the config does
+ // not match the hardware.
+ ALOGD("%s() - openMmapStream() returned status %d", __func__, status);
return AAUDIO_ERROR_UNAVAILABLE;
}
@@ -196,9 +198,9 @@
result = AAUDIO_ERROR_UNAVAILABLE;
goto error;
} else {
- ALOGD("%s() createMmapBuffer() returned = %d, buffer_size = %d, burst_size %d"
+ ALOGD("%s() createMmapBuffer() buffer_size = %d fr, burst_size %d fr"
", Sharable FD: %s",
- __func__, status,
+ __func__,
mMmapBufferinfo.buffer_size_frames,
mMmapBufferinfo.burst_size_frames,
isBufferShareable ? "Yes" : "No");
@@ -243,14 +245,13 @@
burstMicros = mFramesPerBurst * static_cast<int64_t>(1000000) / getSampleRate();
} while (burstMicros < burstMinMicros);
- ALOGD("%s() original burst = %d, minMicros = %d, to burst = %d\n",
+ ALOGD("%s() original burst = %d, minMicros = %d => burst = %d\n",
__func__, mMmapBufferinfo.burst_size_frames, burstMinMicros, mFramesPerBurst);
- ALOGD("%s() actual rate = %d, channels = %d"
- ", deviceId = %d, capacity = %d\n",
- __func__, getSampleRate(), getSamplesPerFrame(), deviceId, getBufferCapacity());
+ ALOGD("%s() actual rate = %d, channels = %d, deviceId = %d\n",
+ __func__, getSampleRate(), getSamplesPerFrame(), deviceId);
- ALOGD("%s() format = =x%08x, frame size = %d",
+ ALOGD("%s() format = 0x%08x, frame size = %d",
__func__, getFormat(), calculateBytesPerFrame());
return result;
@@ -262,7 +263,6 @@
aaudio_result_t AAudioServiceEndpointMMAP::close() {
if (mMmapStream != 0) {
- ALOGD("%s() clear() endpoint", __func__);
// Needs to be explicitly cleared or CTS will fail but it is not clear why.
mMmapStream.clear();
// Apparently the above close is asynchronous. An attempt to open a new device
@@ -284,7 +284,7 @@
LOG_ALWAYS_FATAL_IF(tempHandle != mPortHandle,
"%s() port handle not expected to change from %d to %d",
__func__, mPortHandle, tempHandle);
- ALOGV("%s(%p) mPortHandle = %d", __func__, stream.get(), mPortHandle);
+ ALOGV("%s() mPortHandle = %d", __func__, mPortHandle);
return result;
}
@@ -299,26 +299,20 @@
mFramesTransferred.roundUp64(getBufferCapacity());
// Use the port handle that was provided by openMmapStream().
- ALOGV("%s(%p) mPortHandle = %d", __func__, stream.get(), mPortHandle);
+ ALOGV("%s() mPortHandle = %d", __func__, mPortHandle);
return stopClient(mPortHandle);
}
aaudio_result_t AAudioServiceEndpointMMAP::startClient(const android::AudioClient& client,
audio_port_handle_t *clientHandle) {
if (mMmapStream == nullptr) return AAUDIO_ERROR_NULL;
- ALOGD("%s(%p(uid=%d, pid=%d))", __func__, &client, client.clientUid, client.clientPid);
- audio_port_handle_t originalHandle = *clientHandle;
status_t status = mMmapStream->start(client, clientHandle);
- aaudio_result_t result = AAudioConvert_androidToAAudioResult(status);
- ALOGD("%s() , portHandle %d => %d, returns %d", __func__, originalHandle, *clientHandle, result);
- return result;
+ return AAudioConvert_androidToAAudioResult(status);
}
aaudio_result_t AAudioServiceEndpointMMAP::stopClient(audio_port_handle_t clientHandle) {
- ALOGD("%s(portHandle = %d), called", __func__, clientHandle);
if (mMmapStream == nullptr) return AAUDIO_ERROR_NULL;
aaudio_result_t result = AAudioConvert_androidToAAudioResult(mMmapStream->stop(clientHandle));
- ALOGD("%s(portHandle = %d), returns %d", __func__, clientHandle, result);
return result;
}
@@ -371,7 +365,7 @@
// TODO Do we really need a different volume for each channel?
// We get called with an array filled with a single value!
float volume = values[0];
- ALOGD("%s(%p) volume[0] = %f", __func__, this, volume);
+ ALOGD("%s() volume[0] = %f", __func__, volume);
std::lock_guard<std::mutex> lock(mLockStreams);
for(const auto& stream : mRegisteredStreams) {
stream->onVolumeChanged(volume);
@@ -379,7 +373,7 @@
};
void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t deviceId) {
- ALOGD("%s(%p) called with dev %d, old = %d", __func__, this, deviceId, getDeviceId());
+ ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId());
if (getDeviceId() != AUDIO_PORT_HANDLE_NONE && getDeviceId() != deviceId) {
disconnectRegisteredStreams();
}
diff --git a/services/oboeservice/AAudioServiceEndpointPlay.cpp b/services/oboeservice/AAudioServiceEndpointPlay.cpp
index 1e1c552..bda4b90 100644
--- a/services/oboeservice/AAudioServiceEndpointPlay.cpp
+++ b/services/oboeservice/AAudioServiceEndpointPlay.cpp
@@ -43,7 +43,6 @@
AAudioServiceEndpointPlay::AAudioServiceEndpointPlay(AAudioService &audioService)
: mStreamInternalPlay(audioService, true) {
- ALOGD("%s(%p) created", __func__, this);
mStreamInternal = &mStreamInternalPlay;
}
diff --git a/services/oboeservice/AAudioServiceStreamShared.cpp b/services/oboeservice/AAudioServiceStreamShared.cpp
index 14742dd..2ca847a 100644
--- a/services/oboeservice/AAudioServiceStreamShared.cpp
+++ b/services/oboeservice/AAudioServiceStreamShared.cpp
@@ -111,7 +111,7 @@
capacityInFrames, MAX_FRAMES_PER_BUFFER);
return AAUDIO_ERROR_OUT_OF_RANGE;
}
- ALOGD("calculateBufferCapacity() requested %d frames, actual = %d",
+ ALOGV("calculateBufferCapacity() requested %d frames, actual = %d",
requestedCapacityFrames, capacityInFrames);
return capacityInFrames;
}
@@ -144,7 +144,7 @@
if (getFormat() == AUDIO_FORMAT_DEFAULT) {
setFormat(AUDIO_FORMAT_PCM_FLOAT);
} else if (getFormat() != AUDIO_FORMAT_PCM_FLOAT) {
- ALOGE("%s() audio_format_t mAudioFormat = %d, need FLOAT", __func__, getFormat());
+ ALOGD("%s() audio_format_t mAudioFormat = %d, need FLOAT", __func__, getFormat());
result = AAUDIO_ERROR_INVALID_FORMAT;
goto error;
}
@@ -153,7 +153,7 @@
if (getSampleRate() == AAUDIO_UNSPECIFIED) {
setSampleRate(endpoint->getSampleRate());
} else if (getSampleRate() != endpoint->getSampleRate()) {
- ALOGE("%s() mSampleRate = %d, need %d",
+ ALOGD("%s() mSampleRate = %d, need %d",
__func__, getSampleRate(), endpoint->getSampleRate());
result = AAUDIO_ERROR_INVALID_RATE;
goto error;
@@ -163,7 +163,7 @@
if (getSamplesPerFrame() == AAUDIO_UNSPECIFIED) {
setSamplesPerFrame(endpoint->getSamplesPerFrame());
} else if (getSamplesPerFrame() != endpoint->getSamplesPerFrame()) {
- ALOGE("%s() mSamplesPerFrame = %d, need %d",
+ ALOGD("%s() mSamplesPerFrame = %d, need %d",
__func__, getSamplesPerFrame(), endpoint->getSamplesPerFrame());
result = AAUDIO_ERROR_OUT_OF_RANGE;
goto error;
@@ -190,9 +190,6 @@
}
}
- ALOGD("%s() actual rate = %d, channels = %d, deviceId = %d",
- __func__, getSampleRate(), getSamplesPerFrame(), endpoint->getDeviceId());
-
result = endpoint->registerStream(keep);
if (result != AAUDIO_OK) {
goto error;
@@ -227,7 +224,7 @@
{
std::lock_guard<std::mutex> lock(mAudioDataQueueLock);
if (mAudioDataQueue == nullptr) {
- ALOGE("%s(): mUpMessageQueue null! - stream not open", __func__);
+ ALOGW("%s(): mUpMessageQueue null! - stream not open", __func__);
return AAUDIO_ERROR_NULL;
}
// Gather information on the data queue.
@@ -262,7 +259,7 @@
int64_t position = 0;
sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
if (endpoint == nullptr) {
- ALOGE("%s() has no endpoint", __func__);
+ ALOGW("%s() has no endpoint", __func__);
return AAUDIO_ERROR_INVALID_STATE;
}