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/media/libaaudio/src/binding/AAudioBinderClient.cpp b/media/libaaudio/src/binding/AAudioBinderClient.cpp
index dd620e3..7b0d31f 100644
--- a/media/libaaudio/src/binding/AAudioBinderClient.cpp
+++ b/media/libaaudio/src/binding/AAudioBinderClient.cpp
@@ -97,8 +97,7 @@
status_t status = binder->linkToDeath(mAAudioClient);
// TODO review what we should do if this fails
if (status != NO_ERROR) {
- ALOGE("getAAudioService: linkToDeath(mAAudioClient = %p) returned %d",
- mAAudioClient.get(), status);
+ ALOGE("%s() - linkToDeath() returned %d", __func__, status);
}
mAAudioService = interface_cast<IAAudioService>(binder);
needToRegister = true;
diff --git a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
index 67955e8..b6e8472 100644
--- a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
+++ b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
@@ -157,5 +157,4 @@
void SharedMemoryParcelable::dump() {
ALOGD("mFd = %d", mFd.get());
ALOGD("mSizeInBytes = %d", mSizeInBytes);
- ALOGD("mResolvedAddress = %p", mResolvedAddress);
}
diff --git a/media/libaaudio/src/client/AAudioFlowGraph.cpp b/media/libaaudio/src/client/AAudioFlowGraph.cpp
index 3e43c6b..8f2c488 100644
--- a/media/libaaudio/src/client/AAudioFlowGraph.cpp
+++ b/media/libaaudio/src/client/AAudioFlowGraph.cpp
@@ -38,7 +38,7 @@
int32_t sinkChannelCount) {
AudioFloatOutputPort *lastOutput = nullptr;
- ALOGD("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d",
+ ALOGV("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d",
__func__, sourceFormat, sourceChannelCount, sinkFormat, sinkChannelCount);
switch (sourceFormat) {
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index ec270f3..db98d58 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -195,13 +195,13 @@
if (isDataCallbackSet()) {
mCallbackFrames = builder.getFramesPerDataCallback();
if (mCallbackFrames > getBufferCapacity() / 2) {
- ALOGE("%s - framesPerCallback too big = %d, capacity = %d",
+ ALOGW("%s - framesPerCallback too big = %d, capacity = %d",
__func__, mCallbackFrames, getBufferCapacity());
result = AAUDIO_ERROR_OUT_OF_RANGE;
goto error;
} else if (mCallbackFrames < 0) {
- ALOGE("%s - framesPerCallback negative", __func__);
+ ALOGW("%s - framesPerCallback negative", __func__);
result = AAUDIO_ERROR_OUT_OF_RANGE;
goto error;
@@ -225,7 +225,7 @@
aaudio_result_t AudioStreamInternal::close() {
aaudio_result_t result = AAUDIO_OK;
- ALOGD("%s(): mServiceStreamHandle = 0x%08X", __func__, mServiceStreamHandle);
+ ALOGV("%s(): mServiceStreamHandle = 0x%08X", __func__, mServiceStreamHandle);
if (mServiceStreamHandle != AAUDIO_HANDLE_INVALID) {
// Don't close a stream while it is running.
aaudio_stream_state_t currentState = getState();
@@ -236,7 +236,7 @@
result = waitForStateChange(currentState, &nextState,
timeoutNanoseconds);
if (result != AAUDIO_OK) {
- ALOGE("%s() waitForStateChange() returned %d %s",
+ ALOGW("%s() waitForStateChange() returned %d %s",
__func__, result, AAudio_convertResultToText(result));
}
}
@@ -283,17 +283,17 @@
{
int64_t startTime;
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("requestStart() mServiceStreamHandle invalid");
+ ALOGD("requestStart() mServiceStreamHandle invalid");
return AAUDIO_ERROR_INVALID_STATE;
}
if (isActive()) {
- ALOGE("requestStart() already active");
+ ALOGD("requestStart() already active");
return AAUDIO_ERROR_INVALID_STATE;
}
aaudio_stream_state_t originalState = getState();
if (originalState == AAUDIO_STREAM_STATE_DISCONNECTED) {
- ALOGE("requestStart() but DISCONNECTED");
+ ALOGD("requestStart() but DISCONNECTED");
return AAUDIO_ERROR_DISCONNECTED;
}
setState(AAUDIO_STREAM_STATE_STARTING);
@@ -356,8 +356,8 @@
}
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("requestStopInternal() mServiceStreamHandle invalid = 0x%08X",
- mServiceStreamHandle);
+ ALOGW("%s() mServiceStreamHandle invalid = 0x%08X",
+ __func__, mServiceStreamHandle);
return AAUDIO_ERROR_INVALID_STATE;
}
@@ -370,7 +370,7 @@
aaudio_result_t AudioStreamInternal::registerThread() {
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("registerThread() mServiceStreamHandle invalid");
+ ALOGW("%s() mServiceStreamHandle invalid", __func__);
return AAUDIO_ERROR_INVALID_STATE;
}
return mServiceInterface.registerAudioThread(mServiceStreamHandle,
@@ -380,7 +380,7 @@
aaudio_result_t AudioStreamInternal::unregisterThread() {
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("unregisterThread() mServiceStreamHandle invalid");
+ ALOGW("%s() mServiceStreamHandle invalid", __func__);
return AAUDIO_ERROR_INVALID_STATE;
}
return mServiceInterface.unregisterAudioThread(mServiceStreamHandle, gettid());
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
index e1443d9..164ad2b 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
@@ -65,7 +65,7 @@
return result;
}
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("%s() mServiceStreamHandle invalid", __func__);
+ ALOGW("%s() mServiceStreamHandle invalid", __func__);
return AAUDIO_ERROR_INVALID_STATE;
}
@@ -77,7 +77,7 @@
aaudio_result_t AudioStreamInternalPlay::requestFlush() {
if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
- ALOGE("%s() mServiceStreamHandle invalid", __func__);
+ ALOGW("%s() mServiceStreamHandle invalid", __func__);
return AAUDIO_ERROR_INVALID_STATE;
}
diff --git a/media/libaaudio/src/core/AAudioAudio.cpp b/media/libaaudio/src/core/AAudioAudio.cpp
index 8ae2644..44d5122 100644
--- a/media/libaaudio/src/core/AAudioAudio.cpp
+++ b/media/libaaudio/src/core/AAudioAudio.cpp
@@ -246,18 +246,20 @@
AAudioStream** streamPtr)
{
AudioStream *audioStream = nullptr;
+ aaudio_stream_id_t id = 0;
// Please leave these logs because they are very helpful when debugging.
- ALOGD("%s() called ----------------------------------------", __func__);
+ ALOGI("%s() called ----------------------------------------", __func__);
AudioStreamBuilder *streamBuilder = COMMON_GET_FROM_BUILDER_OR_RETURN(streamPtr);
aaudio_result_t result = streamBuilder->build(&audioStream);
- ALOGD("AAudioStreamBuilder_openStream() returns %d = %s for (%p) ----------------",
- result, AAudio_convertResultToText(result), audioStream);
if (result == AAUDIO_OK) {
audioStream->registerPlayerBase();
*streamPtr = (AAudioStream*) audioStream;
+ id = audioStream->getId();
} else {
*streamPtr = nullptr;
}
+ ALOGI("%s() returns %d = %s for s#%u ----------------",
+ __func__, result, AAudio_convertResultToText(result), id);
return result;
}
@@ -275,8 +277,9 @@
{
aaudio_result_t result = AAUDIO_ERROR_NULL;
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
- ALOGD("%s(%p) called ---------------", __func__, stream);
if (audioStream != nullptr) {
+ aaudio_stream_id_t id = audioStream->getId();
+ ALOGD("%s(s#%u) called ---------------", __func__, id);
result = audioStream->safeClose();
// Close will only fail if called illegally, for example, from a callback.
// That would result in deleting an active stream, which would cause a crash.
@@ -286,42 +289,39 @@
} else {
ALOGW("%s attempt to close failed. Close it from another thread.", __func__);
}
+ ALOGD("%s(s#%u) returned %d ---------", __func__, id, result);
}
- // We're potentially freeing `stream` above, so its use here makes some
- // static analysis tools unhappy. Casting to uintptr_t helps assure
- // said tools that we're not doing anything bad here.
- ALOGD("%s(%#" PRIxPTR ") returned %d ---------", __func__,
- reinterpret_cast<uintptr_t>(stream), result);
return result;
}
AAUDIO_API aaudio_result_t AAudioStream_requestStart(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
- ALOGD("%s(%p) called --------------", __func__, stream);
+ aaudio_stream_id_t id = audioStream->getId();
+ ALOGD("%s(s#%u) called --------------", __func__, id);
aaudio_result_t result = audioStream->systemStart();
- ALOGD("%s(%p) returned %d ---------", __func__, stream, result);
+ ALOGD("%s(s#%u) returned %d ---------", __func__, id, result);
return result;
}
AAUDIO_API aaudio_result_t AAudioStream_requestPause(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
- ALOGD("%s(%p) called", __func__, stream);
+ ALOGD("%s(s#%u) called", __func__, audioStream->getId());
return audioStream->systemPause();
}
AAUDIO_API aaudio_result_t AAudioStream_requestFlush(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
- ALOGD("%s(%p) called", __func__, stream);
+ ALOGD("%s(s#%u) called", __func__, audioStream->getId());
return audioStream->safeFlush();
}
AAUDIO_API aaudio_result_t AAudioStream_requestStop(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
- ALOGD("%s(%p) called", __func__, stream);
+ ALOGD("%s(s#%u) called", __func__, audioStream->getId());
return audioStream->systemStopFromApp();
}
@@ -371,7 +371,7 @@
// Don't allow writes when playing with a callback.
if (audioStream->isDataCallbackActive()) {
- ALOGE("Cannot write to a callback stream when running.");
+ ALOGD("Cannot write to a callback stream when running.");
return AAUDIO_ERROR_INVALID_STATE;
}
diff --git a/media/libaaudio/src/core/AAudioStreamParameters.cpp b/media/libaaudio/src/core/AAudioStreamParameters.cpp
index e5bda30..c9711da 100644
--- a/media/libaaudio/src/core/AAudioStreamParameters.cpp
+++ b/media/libaaudio/src/core/AAudioStreamParameters.cpp
@@ -56,7 +56,7 @@
case AUDIO_FORMAT_PCM_FLOAT:
break; // valid
default:
- ALOGE("audioFormat not valid, audio_format_t = 0x%08x", format);
+ ALOGD("audioFormat not valid, audio_format_t = 0x%08x", format);
return AAUDIO_ERROR_INVALID_FORMAT;
// break;
}
@@ -66,12 +66,12 @@
aaudio_result_t AAudioStreamParameters::validate() const {
if (mSamplesPerFrame != AAUDIO_UNSPECIFIED
&& (mSamplesPerFrame < SAMPLES_PER_FRAME_MIN || mSamplesPerFrame > SAMPLES_PER_FRAME_MAX)) {
- ALOGE("channelCount out of range = %d", mSamplesPerFrame);
+ ALOGD("channelCount out of range = %d", mSamplesPerFrame);
return AAUDIO_ERROR_OUT_OF_RANGE;
}
if (mDeviceId < 0) {
- ALOGE("deviceId out of range = %d", mDeviceId);
+ ALOGD("deviceId out of range = %d", mDeviceId);
return AAUDIO_ERROR_OUT_OF_RANGE;
}
@@ -89,7 +89,7 @@
case AAUDIO_SHARING_MODE_SHARED:
break;
default:
- ALOGE("illegal sharingMode = %d", mSharingMode);
+ ALOGD("illegal sharingMode = %d", mSharingMode);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
@@ -99,12 +99,12 @@
if (mSampleRate != AAUDIO_UNSPECIFIED
&& (mSampleRate < SAMPLE_RATE_HZ_MIN || mSampleRate > SAMPLE_RATE_HZ_MAX)) {
- ALOGE("sampleRate out of range = %d", mSampleRate);
+ ALOGD("sampleRate out of range = %d", mSampleRate);
return AAUDIO_ERROR_INVALID_RATE;
}
if (mBufferCapacity < 0) {
- ALOGE("bufferCapacity out of range = %d", mBufferCapacity);
+ ALOGD("bufferCapacity out of range = %d", mBufferCapacity);
return AAUDIO_ERROR_OUT_OF_RANGE;
}
@@ -113,7 +113,7 @@
case AAUDIO_DIRECTION_OUTPUT:
break; // valid
default:
- ALOGE("direction not valid = %d", mDirection);
+ ALOGD("direction not valid = %d", mDirection);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
@@ -134,7 +134,7 @@
case AAUDIO_USAGE_ASSISTANT:
break; // valid
default:
- ALOGE("usage not valid = %d", mUsage);
+ ALOGD("usage not valid = %d", mUsage);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
@@ -147,7 +147,7 @@
case AAUDIO_CONTENT_TYPE_SPEECH:
break; // valid
default:
- ALOGE("content type not valid = %d", mContentType);
+ ALOGD("content type not valid = %d", mContentType);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
@@ -162,7 +162,7 @@
case AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE:
break; // valid
default:
- ALOGE("input preset not valid = %d", mInputPreset);
+ ALOGD("input preset not valid = %d", mInputPreset);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
@@ -174,7 +174,7 @@
case AAUDIO_ALLOW_CAPTURE_BY_NONE:
break; // valid
default:
- ALOGE("allowed capture policy not valid = %d", mAllowedCapturePolicy);
+ ALOGD("allowed capture policy not valid = %d", mAllowedCapturePolicy);
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
// break;
}
diff --git a/media/libaaudio/src/core/AudioStream.cpp b/media/libaaudio/src/core/AudioStream.cpp
index 732d45c..25669be 100644
--- a/media/libaaudio/src/core/AudioStream.cpp
+++ b/media/libaaudio/src/core/AudioStream.cpp
@@ -28,9 +28,17 @@
using namespace aaudio;
+
+// Sequential number assigned to streams solely for debugging purposes.
+static aaudio_stream_id_t AAudio_getNextStreamId() {
+ static std::atomic <aaudio_stream_id_t> nextStreamId{1};
+ return nextStreamId++;
+}
+
AudioStream::AudioStream()
: mPlayerBase(new MyPlayerBase(this))
-{
+ , mStreamId(AAudio_getNextStreamId())
+ {
// mThread is a pthread_t of unknown size so we need memset.
memset(&mThread, 0, sizeof(mThread));
setPeriodNanoseconds(0);
@@ -48,22 +56,6 @@
mPlayerBase->clearParentReference(); // remove reference to this AudioStream
}
-static const char *AudioStream_convertSharingModeToShortText(aaudio_sharing_mode_t sharingMode) {
- const char *result;
- switch (sharingMode) {
- case AAUDIO_SHARING_MODE_EXCLUSIVE:
- result = "EX";
- break;
- case AAUDIO_SHARING_MODE_SHARED:
- result = "SH";
- break;
- default:
- result = "?!";
- break;
- }
- return result;
-}
-
aaudio_result_t AudioStream::open(const AudioStreamBuilder& builder)
{
// Call here as well because the AAudioService will call this without calling build().
@@ -106,20 +98,6 @@
mDataCallbackUserData = builder.getDataCallbackUserData();
mErrorCallbackUserData = builder.getErrorCallbackUserData();
- // This is very helpful for debugging in the future. Please leave it in.
- ALOGI("open() rate = %d, channels = %d, format = %d, sharing = %s, dir = %s",
- mSampleRate, mSamplesPerFrame, mFormat,
- AudioStream_convertSharingModeToShortText(mSharingMode),
- (getDirection() == AAUDIO_DIRECTION_OUTPUT) ? "OUTPUT" : "INPUT");
- ALOGI("open() device = %d, sessionId = %d, perfMode = %d, callback: %s with frames = %d",
- mDeviceId,
- mSessionId,
- mPerformanceMode,
- (isDataCallbackSet() ? "ON" : "OFF"),
- mFramesPerDataCallback);
- ALOGI("open() usage = %d, contentType = %d, inputPreset = %d, allowedCapturePolicy = %d",
- mUsage, mContentType, mInputPreset, mAllowedCapturePolicy);
-
return AAUDIO_OK;
}
@@ -278,15 +256,15 @@
}
void AudioStream::setState(aaudio_stream_state_t state) {
- ALOGV("%s(%p) from %d to %d", __func__, this, mState, state);
+ ALOGV("%s(%d) from %d to %d", __func__, getId(), mState, state);
// CLOSED is a final state
if (mState == AAUDIO_STREAM_STATE_CLOSED) {
- ALOGE("%s(%p) tried to set to %d but already CLOSED", __func__, this, state);
+ ALOGE("%s(%d) tried to set to %d but already CLOSED", __func__, getId(), state);
// Once DISCONNECTED, we can only move to CLOSED state.
} else if (mState == AAUDIO_STREAM_STATE_DISCONNECTED
&& state != AAUDIO_STREAM_STATE_CLOSED) {
- ALOGE("%s(%p) tried to set to %d but already DISCONNECTED", __func__, this, state);
+ ALOGE("%s(%d) tried to set to %d but already DISCONNECTED", __func__, getId(), state);
} else {
mState = state;
@@ -485,7 +463,6 @@
}
AudioStream::MyPlayerBase::~MyPlayerBase() {
- ALOGV("MyPlayerBase::~MyPlayerBase(%p) deleted", this);
}
void AudioStream::MyPlayerBase::registerWithAudioManager() {
diff --git a/media/libaaudio/src/core/AudioStream.h b/media/libaaudio/src/core/AudioStream.h
index 32713b1..044c979 100644
--- a/media/libaaudio/src/core/AudioStream.h
+++ b/media/libaaudio/src/core/AudioStream.h
@@ -36,6 +36,7 @@
namespace aaudio {
typedef void *(*aaudio_audio_thread_proc_t)(void *);
+typedef uint32_t aaudio_stream_id_t;
class AudioStreamBuilder;
@@ -121,6 +122,12 @@
return AAUDIO_OK;
}
+ // This is only used to identify a stream in the logs without
+ // revealing any pointers.
+ aaudio_stream_id_t getId() {
+ return mStreamId;
+ }
+
virtual aaudio_result_t setBufferSize(int32_t requestedFrames) = 0;
virtual aaudio_result_t createThread(int64_t periodNanoseconds,
@@ -587,6 +594,8 @@
void *mThreadArg = nullptr;
aaudio_result_t mThreadRegistrationResult = AAUDIO_OK;
+ const aaudio_stream_id_t mStreamId;
+
};
} /* namespace aaudio */
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.cpp b/media/libaaudio/src/core/AudioStreamBuilder.cpp
index 4ef765d..08f4958 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.cpp
+++ b/media/libaaudio/src/core/AudioStreamBuilder.cpp
@@ -104,6 +104,8 @@
}
*streamPtr = nullptr;
+ logParameters();
+
aaudio_result_t result = validate();
if (result != AAUDIO_OK) {
return result;
@@ -217,3 +219,41 @@
return AAUDIO_OK;
}
+
+static const char *AAudio_convertSharingModeToShortText(aaudio_sharing_mode_t sharingMode) {
+ switch (sharingMode) {
+ case AAUDIO_SHARING_MODE_EXCLUSIVE:
+ return "EX";
+ case AAUDIO_SHARING_MODE_SHARED:
+ return "SH";
+ default:
+ return "?!";
+ }
+}
+
+static const char *AAudio_convertDirectionToText(aaudio_direction_t direction) {
+ switch (direction) {
+ case AAUDIO_DIRECTION_OUTPUT:
+ return "OUTPUT";
+ case AAUDIO_DIRECTION_INPUT:
+ return "INPUT";
+ default:
+ return "?!";
+ }
+}
+
+void AudioStreamBuilder::logParameters() const {
+ // This is very helpful for debugging in the future. Please leave it in.
+ ALOGI("rate = %6d, channels = %d, format = %d, sharing = %s, dir = %s",
+ getSampleRate(), getSamplesPerFrame(), getFormat(),
+ AAudio_convertSharingModeToShortText(getSharingMode()),
+ AAudio_convertDirectionToText(getDirection()));
+ ALOGI("device = %6d, sessionId = %d, perfMode = %d, callback: %s with frames = %d",
+ getDeviceId(),
+ getSessionId(),
+ getPerformanceMode(),
+ ((getDataCallbackProc() != nullptr) ? "ON" : "OFF"),
+ mFramesPerDataCallback);
+ ALOGI("usage = %6d, contentType = %d, inputPreset = %d, allowedCapturePolicy = %d",
+ getUsage(), getContentType(), getInputPreset(), getAllowedCapturePolicy());
+}
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.h b/media/libaaudio/src/core/AudioStreamBuilder.h
index a43cfa8..8149af2 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.h
+++ b/media/libaaudio/src/core/AudioStreamBuilder.h
@@ -102,6 +102,8 @@
virtual aaudio_result_t validate() const override;
+ void logParameters() const;
+
private:
bool mSharingModeMatchRequired = false; // must match sharing mode requested
aaudio_performance_mode_t mPerformanceMode = AAUDIO_PERFORMANCE_MODE_NONE;
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index 2edab58..91d2eff 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -206,7 +206,9 @@
void AudioStreamLegacy::onAudioDeviceUpdate(audio_port_handle_t deviceId)
{
- ALOGD("onAudioDeviceUpdate() deviceId %d", (int)deviceId);
+ // Device routing is a common source of errors and DISCONNECTS.
+ // Please leave this log in place.
+ ALOGD("%s() devId %d => %d", __func__, (int) getDeviceId(), (int)deviceId);
if (getDeviceId() != AAUDIO_UNSPECIFIED && getDeviceId() != deviceId &&
getState() != AAUDIO_STREAM_STATE_DISCONNECTED) {
// Note that isDataCallbackActive() is affected by state so call it before DISCONNECTING.
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;
}