OSDN Git Service

MediaPlayer changes for Tungsten/Android@Home.
authorMike J. Chen <mjchen@google.com>
Mon, 15 Aug 2011 20:24:13 +0000 (13:24 -0700)
committerJohn Grossman <johngro@google.com>
Wed, 31 Aug 2011 17:05:05 +0000 (10:05 -0700)
Squashed merge from master-tungsten of the following changes:

commit e8b156c6b224f0fe5b6a81d5f92bade36275027c
Author: Jason Simmons <jsimmons@google.com>
Date:   Fri Aug 12 10:28:48 2011 -0700

    Add a null check to handle failure of android::createPlayer

    Change-Id: Iacbbc90369a825838d4374b1f774c8880b25753b

commit 43be3231034ff8537fdd84422a7954780038671f
Author: John Grossman <johngro@google.com>
Date:   Mon Jun 27 18:59:12 2011 -0700

    Move libaah_rtp over from the vendor directory.

    Also move factor PipeEvent out into utils.

    Change-Id: Id3877c66efe22d771cf3ef4877107e431b828e37

commit 17526eb3148c9c3d4365b6d5b47e8dc13bca71b6
Author: John Grossman <johngro@google.com>
Date:   Mon Jun 27 17:06:49 2011 -0700

    Name changes for the TRTP Players s/tungsten/aah/g

    Change-Id: I55e9ad13003f6aa6a36955b54426a7efbe31ac51

commit cbf2903ab6893b6e662514e2f6d670e268a419df
Author: John Grossman <johngro@google.com>
Date:   Fri Apr 15 09:27:54 2011 -0700

    Migrate Tungsten code from the HC-Tungsten to the Master-Tungsten branch.

    Change-Id: I95372d913a0761d90168edb4016f5ece0ea74502

Change-Id: Ic8fd28b1bbd85e86a325f99013e7aa0c763f5f05
Signed-off-by: Mike J. Chen <mjchen@google.com>
Signed-off-by: John Grossman <johngro@google.com>
media/libmediaplayerservice/MediaPlayerService.cpp

index 2051b3b..e6f6231 100644 (file)
 
 #include <OMX.h>
 
+namespace android {
+sp<MediaPlayerBase> createAAH_TXPlayer();
+sp<MediaPlayerBase> createAAH_RXPlayer();
+}
+
 namespace {
 using android::media::Metadata;
 using android::status_t;
@@ -622,6 +627,14 @@ player_type getPlayerType(const char* url)
         }
     }
 
+    if (!strncasecmp("aahRX://", url, 8)) {
+        return AAH_RX_PLAYER;
+    }
+
+    if (!strncasecmp("aahTX://", url, 8)) {
+        return AAH_TX_PLAYER;
+    }
+
     // use MidiFile for MIDI extensions
     int lenURL = strlen(url);
     for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
@@ -658,6 +671,14 @@ static sp<MediaPlayerBase> createPlayer(player_type playerType, void* cookie,
             LOGV("Create Test Player stub");
             p = new TestPlayerStub();
             break;
+        case AAH_RX_PLAYER:
+            LOGV(" create A@H RX Player");
+            p = createAAH_RXPlayer();
+            break;
+        case AAH_TX_PLAYER:
+            LOGV(" create A@H TX Player");
+            p = createAAH_TXPlayer();
+            break;
         default:
             LOGE("Unknown player type: %d", playerType);
             return NULL;
@@ -1005,9 +1026,21 @@ status_t MediaPlayerService::Client::setLooping(int loop)
 status_t MediaPlayerService::Client::setVolume(float leftVolume, float rightVolume)
 {
     LOGV("[%d] setVolume(%f, %f)", mConnId, leftVolume, rightVolume);
-    // TODO: for hardware output, call player instead
-    Mutex::Autolock l(mLock);
-    if (mAudioOutput != 0) mAudioOutput->setVolume(leftVolume, rightVolume);
+
+    // for hardware output, call player instead
+    sp<MediaPlayerBase> p = getPlayer();
+    {
+      Mutex::Autolock l(mLock);
+      if (p != 0 && p->hardwareOutput()) {
+          MediaPlayerHWInterface* hwp =
+                  reinterpret_cast<MediaPlayerHWInterface*>(p.get());
+          return hwp->setVolume(leftVolume, rightVolume);
+      } else {
+          if (mAudioOutput != 0) mAudioOutput->setVolume(leftVolume, rightVolume);
+          return NO_ERROR;
+      }
+    }
+
     return NO_ERROR;
 }