VolumeShaper: Fixes for updated Cts test

1) Limit number of VolumeShapers that can be created.
   a) 16 system VolumeShapers
   b) 16 application/client VolumeShapers
2) Return proper volume before VolumeShaper is started.
3) Consistent xOffset definition used internally:
   a) this is now always the position on the volumeshaper curve
      which can go backwards if in REVERSE.
   b) normalized time is always forward going and is scaled
      to 0.f and 1.f depending on progress relative to
      the curve's duration.
4) Fix replace method.
5) Add comments.

Test: Use updated CTS VolumeShaperTest
Bug: 37536598
Change-Id: I837ab2a481adc0abbd3f1338bfe2cb79831b11fa
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index cba5cf5..7079ff2 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -2042,7 +2042,7 @@
         // For now, we simply advance to the end of the VolumeShaper effect
         // if it has been started.
         if (shaper.isStarted()) {
-            operationToEnd->setXOffset(1.f);
+            operationToEnd->setNormalizedTime(1.f);
         }
         return t->applyVolumeShaper(shaper.mConfiguration, operationToEnd);
     });
@@ -2301,8 +2301,9 @@
         status = mTrack->applyVolumeShaper(configuration, operation);
         if (status >= 0) {
             (void)mVolumeHandler->applyVolumeShaper(configuration, operation);
-            // TODO: start on exact AudioTrack state (STATE_ACTIVE || STATE_STOPPING)
-            mVolumeHandler->setStarted();
+            if (mTrack->isPlaying()) { // match local AudioTrack to properly restore.
+                mVolumeHandler->setStarted();
+            }
         }
     } else {
         status = mVolumeHandler->applyVolumeShaper(configuration, operation);