From 9818a9da598f9fbf731f9d894838c26c9b9152f4 Mon Sep 17 00:00:00 2001
From: Glenn Kasten <gkasten@google.com>
Date: Fri, 28 Oct 2011 10:31:42 -0700
Subject: Improve AudioFlinger error logging

Change-Id: I8ce9aff4038cd7fa0067600faa8080b137db1939
---
 services/audioflinger/AudioFlinger.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index b48f23d..d7b31b1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -395,7 +395,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
     int lSessionId;
 
     if (streamType >= AUDIO_STREAM_CNT) {
-        LOGE("invalid stream type");
+        LOGE("createTrack() invalid stream type %d", streamType);
         lStatus = BAD_VALUE;
         goto Exit;
     }
@@ -427,6 +427,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
                     // prevent same audio session on different output threads
                     uint32_t sessions = t->hasAudioSession(*sessionId);
                     if (sessions & PlaybackThread::TRACK_SESSION) {
+                        LOGE("createTrack() session ID %d already in use", *sessionId);
                         lStatus = BAD_VALUE;
                         goto Exit;
                     }
@@ -657,6 +658,7 @@ status_t AudioFlinger::setStreamVolume(int stream, float value, int output)
     }
 
     if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT) {
+        LOGE("setStreamVolume() invalid stream %d", stream);
         return BAD_VALUE;
     }
 
@@ -691,6 +693,7 @@ status_t AudioFlinger::setStreamMute(int stream, bool muted)
 
     if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT ||
         uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) {
+        LOGE("setStreamMute() invalid stream %d", stream);
         return BAD_VALUE;
     }
 
@@ -1526,8 +1529,10 @@ sp<AudioFlinger::PlaybackThread::Track>  AudioFlinger::PlaybackThread::createTra
         for (size_t i = 0; i < mTracks.size(); ++i) {
             sp<Track> t = mTracks[i];
             if (t != 0) {
-                if (sessionId == t->sessionId() &&
-                        strategy != AudioSystem::getStrategyForStream((audio_stream_type_t)t->type())) {
+                uint32_t actual = AudioSystem::getStrategyForStream((audio_stream_type_t)t->type());
+                if (sessionId == t->sessionId() && strategy != actual) {
+                    LOGE("createTrack_l() mismatched strategy; expected %u but found %u",
+                            strategy, actual);
                     lStatus = BAD_VALUE;
                     goto Exit;
                 }
-- 
cgit v1.1