Add unique audio port IDs to AudioTrack and AudioRecord

This will allow to track activity at the track level instead of
at audio session level as only possible with current implementation.

AudioTracks and AudioRecords will receive a unique audio port ID the
first time they register to audio policy with
getOutputForAttr()/getInputForAttr() and keep this ID for their
lifetime.

This CL is the first partial change and just updates the
audio policy and audio flinger APIs used at track creation time.

Test: basic regression test of audio playback and capture use cases

Change-Id: I8d612e67738e120494f61e3f7c60bfd0b2c6a329
diff --git a/services/audioflinger/TrackBase.h b/services/audioflinger/TrackBase.h
index 4fcb596..9ca2d63 100644
--- a/services/audioflinger/TrackBase.h
+++ b/services/audioflinger/TrackBase.h
@@ -65,7 +65,8 @@
                                 uid_t uid,
                                 bool isOut,
                                 alloc_type alloc = ALLOC_CBLK,
-                                track_type type = TYPE_DEFAULT);
+                                track_type type = TYPE_DEFAULT,
+                                audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
     virtual             ~TrackBase();
     virtual status_t    initCheck() const;
 
@@ -163,6 +164,7 @@
     bool                mTerminated;
     track_type          mType;      // must be one of TYPE_DEFAULT, TYPE_OUTPUT, TYPE_PATCH ...
     audio_io_handle_t   mThreadIoHandle; // I/O handle of the thread the track is attached to
+    audio_port_handle_t mPortId; // unique ID for this track used by audio policy
 };
 
 // PatchProxyBufferProvider interface is implemented by PatchTrack and PatchRecord.