Bug 1158692 - Change omx AudioSink to GonkAudioSink r=cpearce
authorSotaro Ikeda <sikeda@mozilla.com>
Tue, 28 Apr 2015 06:50:59 -0700
changeset 271291 67cb93edea83debd7b96c7b3b671a23a719b594f
parent 271290 4103078c32e59890a448faacf2ebe407afa3d9ee
child 271292 4de411d0cf3891abd274c3cbae652ccbf857b583
child 271317 07900c19ad29f792a460cdf6c79eb7097d50c87e
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1158692
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1158692 - Change omx AudioSink to GonkAudioSink r=cpearce
dom/media/omx/AudioOffloadPlayer.cpp
dom/media/omx/AudioOffloadPlayer.h
dom/media/omx/AudioOutput.h
dom/media/omx/AudioSink.h
dom/media/omx/GonkAudioSink.h
dom/media/omx/moz.build
--- a/dom/media/omx/AudioOffloadPlayer.cpp
+++ b/dom/media/omx/AudioOffloadPlayer.cpp
@@ -46,17 +46,17 @@ namespace mozilla {
 PRLogModuleInfo* gAudioOffloadPlayerLog;
 #define AUDIO_OFFLOAD_LOG(type, msg) \
   PR_LOG(gAudioOffloadPlayerLog, type, msg)
 #else
 #define AUDIO_OFFLOAD_LOG(type, msg)
 #endif
 
 // maximum time in paused state when offloading audio decompression.
-// When elapsed, the AudioSink is destroyed to allow the audio DSP to power down.
+// When elapsed, the GonkAudioSink is destroyed to allow the audio DSP to power down.
 static const uint64_t OFFLOAD_PAUSE_MAX_MSECS = 60000ll;
 
 AudioOffloadPlayer::AudioOffloadPlayer(MediaOmxCommonDecoder* aObserver) :
   mStarted(false),
   mPlaying(false),
   mReachedEOS(false),
   mIsElementVisible(true),
   mSampleRate(0),
@@ -468,38 +468,38 @@ void AudioOffloadPlayer::NotifyAudioTear
     mSeekPromise.Resolve(val, __func__);
   }
   nsCOMPtr<nsIRunnable> nsEvent = NS_NewRunnableMethod(mObserver,
       &MediaOmxCommonDecoder::AudioOffloadTearDown);
   NS_DispatchToMainThread(nsEvent);
 }
 
 // static
-size_t AudioOffloadPlayer::AudioSinkCallback(AudioSink* aAudioSink,
+size_t AudioOffloadPlayer::AudioSinkCallback(GonkAudioSink* aAudioSink,
                                              void* aBuffer,
                                              size_t aSize,
                                              void* aCookie,
-                                             AudioSink::cb_event_t aEvent)
+                                             GonkAudioSink::cb_event_t aEvent)
 {
   AudioOffloadPlayer* me = (AudioOffloadPlayer*) aCookie;
 
   switch (aEvent) {
 
-    case AudioSink::CB_EVENT_FILL_BUFFER:
+    case GonkAudioSink::CB_EVENT_FILL_BUFFER:
       AUDIO_OFFLOAD_LOG(PR_LOG_DEBUG, ("Notify Audio position changed"));
       me->NotifyPositionChanged();
       return me->FillBuffer(aBuffer, aSize);
 
-    case AudioSink::CB_EVENT_STREAM_END:
+    case GonkAudioSink::CB_EVENT_STREAM_END:
       AUDIO_OFFLOAD_LOG(PR_LOG_DEBUG, ("Notify Audio EOS"));
       me->mReachedEOS = true;
       me->NotifyAudioEOS();
       break;
 
-    case AudioSink::CB_EVENT_TEAR_DOWN:
+    case GonkAudioSink::CB_EVENT_TEAR_DOWN:
       AUDIO_OFFLOAD_LOG(PR_LOG_DEBUG, ("Notify Tear down event"));
       me->NotifyAudioTearDown();
       break;
 
     default:
       AUDIO_OFFLOAD_LOG(PR_LOG_ERROR, ("Unknown event %d from audio sink",
           aEvent));
       break;
@@ -692,17 +692,17 @@ MediaDecoderOwner::NextFrameStatus Audio
     return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING;
   } else if (mPlayState == MediaDecoder::PLAY_STATE_ENDED) {
     return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
   } else {
     return MediaDecoderOwner::NEXT_FRAME_AVAILABLE;
   }
 }
 
-void AudioOffloadPlayer::SendMetaDataToHal(sp<AudioSink>& aSink,
+void AudioOffloadPlayer::SendMetaDataToHal(sp<GonkAudioSink>& aSink,
                                            const sp<MetaData>& aMeta)
 {
   int32_t sampleRate = 0;
   int32_t bitRate = 0;
   int32_t channelMask = 0;
   int32_t delaySamples = 0;
   int32_t paddingSamples = 0;
   CHECK(aSink.get());
--- a/dom/media/omx/AudioOffloadPlayer.h
+++ b/dom/media/omx/AudioOffloadPlayer.h
@@ -45,21 +45,21 @@ class WakeLock;
  *
  * This depends on offloading capability provided by Android KK AudioTrack class
  *
  * Audio playback is based on pull mechanism, whenever audio sink needs
  * data, FillBuffer() will read data from compressed audio source and provide
  * it to the sink
  *
  * Also this class passes state changes (play/pause/seek) from
- * MediaOmxCommonDecoder to AudioSink as well as provide AudioSink status
+ * MediaOmxCommonDecoder to GonkAudioSink as well as provide GonkAudioSink status
  * (position changed, playback ended, seek complete, audio tear down) back to
  * MediaOmxCommonDecoder
  *
- * It acts as a bridge between MediaOmxCommonDecoder and AudioSink during
+ * It acts as a bridge between MediaOmxCommonDecoder and GonkAudioSink during
  * offload playback
  */
 
 class AudioOffloadPlayer : public AudioOffloadPlayerBase
 {
   typedef android::Mutex Mutex;
   typedef android::MetaData MetaData;
   typedef android::status_t status_t;
@@ -75,17 +75,17 @@ public:
 
   AudioOffloadPlayer(MediaOmxCommonDecoder* aDecoder = nullptr);
 
   ~AudioOffloadPlayer();
 
   // Caller retains ownership of "aSource".
   virtual void SetSource(const android::sp<MediaSource> &aSource) override;
 
-  // Start the source if it's not already started and open the AudioSink to
+  // Start the source if it's not already started and open the GonkAudioSink to
   // create an offloaded audio track
   virtual status_t Start(bool aSourceAlreadyStarted = false) override;
 
   virtual status_t ChangeState(MediaDecoder::PlayState aState) override;
 
   virtual void SetVolume(double aVolume) override;
 
   virtual double GetMediaTimeSecs() override;
@@ -101,17 +101,17 @@ public:
   virtual nsRefPtr<MediaDecoder::SeekPromise> Seek(SeekTarget aTarget) override;
 
   void TimeUpdate();
 
   // Close the audio sink, stop time updates, frees the input buffers
   void Reset();
 
 private:
-  // Set when audio source is started and audioSink is initialized
+  // Set when audio source is started and GonkAudioSink is initialized
   // Used only in main thread
   bool mStarted;
 
   // Set when audio sink is started. i.e. playback started
   // Used only in main thread
   bool mPlaying;
 
   // Once playback reached end of stream (last ~100ms), position provided by DSP
@@ -165,30 +165,30 @@ private:
 
   // Compressed audio source.
   // Used in main thread first and later in offload callback thread
   android::sp<MediaSource> mSource;
 
   // Audio sink wrapper to access offloaded audio tracks
   // Used in main thread and offload callback thread
   // Race conditions are protected in underlying Android::AudioTrack class
-  android::sp<AudioSink> mAudioSink;
+  android::sp<GonkAudioSink> mAudioSink;
 
   // Buffer used to get date from audio source. Used in offload callback thread
   MediaBuffer* mInputBuffer;
 
   // MediaOmxCommonDecoder object used mainly to notify the audio sink status
   MediaOmxCommonDecoder* mObserver;
 
   TimeStamp mLastFireUpdateTime;
 
   // Timer to trigger position changed events
   nsCOMPtr<nsITimer> mTimeUpdateTimer;
 
-  // Timer to reset AudioSink when audio is paused for OFFLOAD_PAUSE_MAX_USECS.
+  // Timer to reset GonkAudioSink when audio is paused for OFFLOAD_PAUSE_MAX_USECS.
   // It is triggered in Pause() and canceled when there is a Play() within
   // OFFLOAD_PAUSE_MAX_USECS. Used only from main thread so no lock is needed.
   nsCOMPtr<nsITimer> mResetTimer;
 
   // To avoid device suspend when mResetTimer is going to be triggered.
   // Used only from main thread so no lock is needed.
   nsRefPtr<mozilla::dom::WakeLock> mWakeLock;
 
@@ -198,22 +198,22 @@ private:
   // frames played by audio track
   int64_t GetOutputPlayPositionUs_l() const;
 
   // Fill the buffer given by audio sink with data from compressed audio
   // source. Also handles the seek by seeking audio source and stop the sink in
   // case of error
   size_t FillBuffer(void *aData, size_t aSize);
 
-  // Called by AudioSink when it needs data, to notify EOS or tear down event
-  static size_t AudioSinkCallback(AudioSink *aAudioSink,
+  // Called by GonkAudioSink when it needs data, to notify EOS or tear down event
+  static size_t AudioSinkCallback(GonkAudioSink *aAudioSink,
                                   void *aData,
                                   size_t aSize,
                                   void *aMe,
-                                  AudioSink::cb_event_t aEvent);
+                                  GonkAudioSink::cb_event_t aEvent);
 
   bool IsSeeking();
 
   // Set mSeekTarget to the given position and restart the sink. Actual seek
   // happens in FillBuffer(). If mSeekPromise is not empty, send
   // SeekingStarted event always and SeekingStopped event when the play state is
   // paused to MediaDecoder.
   // When decoding and playing happens separately, if there is a seek during
@@ -249,18 +249,18 @@ private:
   // Notify position changed event by sending PlaybackPositionChanged event to
   // observer
   void NotifyPositionChanged();
 
   // Offloaded audio track is invalidated due to usecase change. Notify
   // MediaDecoder to re-evaluate offloading options
   void NotifyAudioTearDown();
 
-  // Send information from MetaData to the HAL via AudioSink
-  void SendMetaDataToHal(android::sp<AudioSink>& aSink,
+  // Send information from MetaData to the HAL via GonkAudioSink
+  void SendMetaDataToHal(android::sp<GonkAudioSink>& aSink,
                          const android::sp<MetaData>& aMeta);
 
   AudioOffloadPlayer(const AudioOffloadPlayer &);
   AudioOffloadPlayer &operator=(const AudioOffloadPlayer &);
 };
 
 } // namespace mozilla
 
--- a/dom/media/omx/AudioOutput.h
+++ b/dom/media/omx/AudioOutput.h
@@ -19,27 +19,27 @@
 
 #ifndef AUDIOOUTPUT_H_
 #define AUDIOOUTPUT_H_
 
 #include <stagefright/foundation/ABase.h>
 #include <utils/Mutex.h>
 #include <AudioTrack.h>
 
-#include "AudioSink.h"
+#include "GonkAudioSink.h"
 
 namespace mozilla {
 
 /**
  * Stripped version of Android KK MediaPlayerService::AudioOutput class
  * Android MediaPlayer uses AudioOutput as a wrapper to handle
  * Android::AudioTrack
  * Similarly to ease handling offloaded tracks, part of AudioOutput is used here
  */
-class AudioOutput : public AudioSink
+class AudioOutput : public GonkAudioSink
 {
   typedef android::Mutex Mutex;
   typedef android::String8 String8;
   typedef android::status_t status_t;
   typedef android::AudioTrack AudioTrack;
 
   class CallbackData;
 
rename from dom/media/omx/AudioSink.h
rename to dom/media/omx/GonkAudioSink.h
--- a/dom/media/omx/AudioSink.h
+++ b/dom/media/omx/GonkAudioSink.h
@@ -12,18 +12,18 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
-#ifndef AUDIO_SINK_H_
-#define AUDIO_SINK_H_
+#ifndef GONK_AUDIO_SINK_H_
+#define GONK_AUDIO_SINK_H_
 
 #include <utils/Errors.h>
 #include <utils/String8.h>
 #include <system/audio.h>
 
 #define DEFAULT_AUDIOSINK_BUFFERCOUNT 4
 #define DEFAULT_AUDIOSINK_BUFFERSIZE 1200
 #define DEFAULT_AUDIOSINK_SAMPLERATE 44100
@@ -34,37 +34,37 @@
 
 namespace mozilla {
 
 /**
  * AudioSink: abstraction layer for audio output
  * Stripped version of Android KK MediaPlayerBase::AudioSink class
  */
 
-class AudioSink : public android::RefBase
+class GonkAudioSink : public android::RefBase
 {
   typedef android::String8 String8;
   typedef android::status_t status_t;
 
 public:
   enum cb_event_t {
     CB_EVENT_FILL_BUFFER,   // Request to write more data to buffer.
     CB_EVENT_STREAM_END,    // Sent after all the buffers queued in AF and HW
                             // are played back (after stop is called)
     CB_EVENT_TEAR_DOWN      // The AudioTrack was invalidated due to usecase
                             // change. Need to re-evaluate offloading options
   };
 
   // Callback returns the number of bytes actually written to the buffer.
-  typedef size_t (*AudioCallback)(AudioSink* aAudioSink,
+  typedef size_t (*AudioCallback)(GonkAudioSink* aAudioSink,
                                   void* aBuffer,
                                   size_t aSize,
                                   void* aCookie,
                                   cb_event_t aEvent);
-  virtual ~AudioSink() {}
+  virtual ~GonkAudioSink() {}
   virtual ssize_t FrameSize() const = 0;
   virtual status_t GetPosition(uint32_t* aPosition) const = 0;
   virtual status_t SetVolume(float aVolume) const = 0;
   virtual status_t SetParameters(const String8& aKeyValuePairs)
   {
     return android::NO_ERROR;
   }
 
@@ -81,9 +81,9 @@ public:
   virtual void Stop() = 0;
   virtual void Flush() = 0;
   virtual void Pause() = 0;
   virtual void Close() = 0;
 };
 
 } // namespace mozilla
 
-#endif // AUDIO_SINK_H_
+#endif // GONK_AUDIO_SINK_H_
--- a/dom/media/omx/moz.build
+++ b/dom/media/omx/moz.build
@@ -21,17 +21,17 @@ SOURCES += [
     'OMXCodecProxy.cpp',
     'OmxDecoder.cpp',
 ]
 
 if CONFIG['MOZ_AUDIO_OFFLOAD']:
     EXPORTS += [
         'AudioOffloadPlayer.h',
         'AudioOutput.h',
-        'AudioSink.h',
+        'GonkAudioSink.h',
     ]
     SOURCES += [
         'AudioOffloadPlayer.cpp',
         'AudioOutput.cpp',
     ]
 
 if CONFIG['MOZ_OMX_ENCODER']:
     EXPORTS += [