Add RecordThread media.log and deferred deallocation

This change allows a media.log buffer for RecordThread.

Unlike playback threads which stick around forever, the RecordThread comes
and goes for every capture session.  This means that the media.log buffer
for a RecordThread would disappear too, and so was useless.  Now when a
thread exits, it's associated media.log buffer is just marked for deferred
deallocation.  It is only actually freed when the memory is needed.

Other changes:
 - Fix bug in unregistering comparison, it was comparing the wrong pointers
 - Increased size of log area so we can log for RecordThread also

Change-Id: If45d4c03a793b86390a0112ec3acc5d41b2e3635
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 9137040..066d5d5 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -235,8 +235,12 @@
     sp<NBLog::Writer>   newWriter_l(size_t size, const char *name);
     void                unregisterWriter(const sp<NBLog::Writer>& writer);
 private:
-    static const size_t kLogMemorySize = 10 * 1024;
+    static const size_t kLogMemorySize = 40 * 1024;
     sp<MemoryDealer>    mLogMemoryDealer;   // == 0 when NBLog is disabled
+    // When a log writer is unregistered, it is done lazily so that media.log can continue to see it
+    // for as long as possible.  The memory is only freed when it is needed for another log writer.
+    Vector< sp<NBLog::Writer> > mUnregisteredWriters;
+    Mutex               mUnregisteredWritersLock;
 public:
 
     class SyncEvent;