AudioStreamIn and AudioStreamOut

These are immutable, so make the fields const.
getOutput() and getInput() methods are now const.

Change-Id: I128246ebd56ea50b3e542be43f2aa1bcb55f1373
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 6701059..96bc552 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1808,7 +1808,7 @@
 }
 
 
-AudioFlinger::AudioStreamOut* AudioFlinger::PlaybackThread::getOutput()
+AudioFlinger::AudioStreamOut* AudioFlinger::PlaybackThread::getOutput() const
 {
     Mutex::Autolock _l(mLock);
     return mOutput;
@@ -4897,7 +4897,7 @@
     return mTrack;
 }
 
-AudioFlinger::AudioStreamIn* AudioFlinger::RecordThread::getInput()
+AudioFlinger::AudioStreamIn* AudioFlinger::RecordThread::getInput() const
 {
     Mutex::Autolock _l(mLock);
     return mInput;
@@ -5045,6 +5045,7 @@
 
     if (thread->type() != ThreadBase::DUPLICATING) {
         AudioStreamOut *out = thread->clearOutput();
+        assert(out != NULL);
         // from now on thread->mOutput is NULL
         out->hwDev->close_output_stream(out->hwDev, out->stream);
         delete out;
@@ -5186,6 +5187,7 @@
     thread->exit();
 
     AudioStreamIn *in = thread->clearInput();
+    assert(in != NULL);
     // from now on thread->mInput is NULL
     in->hwDev->close_input_stream(in->hwDev, in->stream);
     delete in;
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 48edfcd..262c890 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -727,7 +727,7 @@
                                     int sessionId,
                                     status_t *status);
 
-                    AudioStreamOut* getOutput();
+                    AudioStreamOut* getOutput() const;
                     AudioStreamOut* clearOutput();
                     virtual audio_stream_t* stream();
 
@@ -804,7 +804,7 @@
         SortedVector< sp<Track> >       mTracks;
         // mStreamTypes[] uses 1 additional stream type internally for the OutputTrack used by DuplicatingThread
         stream_type_t                   mStreamTypes[AUDIO_STREAM_CNT + 1];
-        AudioStreamOut*                 mOutput;
+        AudioStreamOut                  *mOutput;
         float                           mMasterVolume;
         nsecs_t                         mLastWriteTime;
         int                             mNumWrites;
@@ -994,7 +994,7 @@
                 status_t    start(RecordTrack* recordTrack);
                 void        stop(RecordTrack* recordTrack);
                 status_t    dump(int fd, const Vector<String16>& args);
-                AudioStreamIn* getInput();
+                AudioStreamIn* getInput() const;
                 AudioStreamIn* clearInput();
                 virtual audio_stream_t* stream();
 
@@ -1357,17 +1357,21 @@
         KeyedVector< int, sp<SuspendedEffectDesc> > mSuspendedEffects;
     };
 
+    // AudioStreamOut and AudioStreamIn are immutable, so their fields are const.
+    // For emphasis, we could also make all pointers to them be "const *",
+    // but that would clutter the code unnecessarily.
+
     struct AudioStreamOut {
-        audio_hw_device_t   *hwDev;
-        audio_stream_out_t  *stream;
+        audio_hw_device_t*  const hwDev;
+        audio_stream_out_t* const stream;
 
         AudioStreamOut(audio_hw_device_t *dev, audio_stream_out_t *out) :
             hwDev(dev), stream(out) {}
     };
 
     struct AudioStreamIn {
-        audio_hw_device_t   *hwDev;
-        audio_stream_in_t   *stream;
+        audio_hw_device_t* const hwDev;
+        audio_stream_in_t* const stream;
 
         AudioStreamIn(audio_hw_device_t *dev, audio_stream_in_t *in) :
             hwDev(dev), stream(in) {}