summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/lvpp
diff options
context:
space:
mode:
authorRajneesh Chowdury <rajneeshc@google.com>2011-02-21 15:43:33 -0800
committerRajneesh Chowdury <rajneeshc@google.com>2011-02-22 13:42:26 -0800
commit1c97d9ab52a288d24ea54499de435277cc1a3d68 (patch)
treed15a87a64ff1cf292d4d0704f483cb1c61ede0c7 /libvideoeditor/lvpp
parent7e006bd24cccffb9c9fd48fd3b2709b6639bc5f1 (diff)
downloadframeworks_av-1c97d9ab52a288d24ea54499de435277cc1a3d68.zip
frameworks_av-1c97d9ab52a288d24ea54499de435277cc1a3d68.tar.gz
frameworks_av-1c97d9ab52a288d24ea54499de435277cc1a3d68.tar.bz2
Fix for 3369917 Audio skips at clip edit points
Change-Id: Iba66585cc2e679475d8db529d6113586b58e626e
Diffstat (limited to 'libvideoeditor/lvpp')
-rwxr-xr-xlibvideoeditor/lvpp/DummyAudioSource.cpp22
-rwxr-xr-xlibvideoeditor/lvpp/DummyAudioSource.h5
-rw-r--r--libvideoeditor/lvpp/PreviewPlayer.cpp172
-rw-r--r--libvideoeditor/lvpp/PreviewPlayer.h3
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorAudioPlayer.cpp82
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorAudioPlayer.h6
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp6
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorBGAudioProcessing.h8
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPlayer.cpp9
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPlayer.h5
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.cpp14
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.h4
12 files changed, 292 insertions, 44 deletions
diff --git a/libvideoeditor/lvpp/DummyAudioSource.cpp b/libvideoeditor/lvpp/DummyAudioSource.cpp
index 04f8dc9..70f5944 100755
--- a/libvideoeditor/lvpp/DummyAudioSource.cpp
+++ b/libvideoeditor/lvpp/DummyAudioSource.cpp
@@ -97,7 +97,12 @@ DummyAudioSource::~DummyAudioSource () {
LOG2("DummyAudioSource::~DummyAudioSource");
}
-
+void DummyAudioSource::setDuration (int64_t audioDurationUs) {
+ Mutex::Autolock autoLock(mLock);
+ LOG2("SetDuration %lld", mAudioDurationUs);
+ mAudioDurationUs += audioDurationUs;
+ LOG2("SetDuration %lld", mAudioDurationUs);
+}
status_t DummyAudioSource::start(MetaData *params) {
status_t err = OK;
@@ -143,7 +148,7 @@ sp<MetaData> DummyAudioSource::getFormat() {
meta->setInt32(kKeySampleRate, mSamplingRate);
meta->setInt64(kKeyDuration, mFrameDurationUs);
- meta->setCString(kKeyDecoderComponent, "DummyAudioSource");
+ meta->setCString(kKeyDecoderComponent, "DummyAudioSource");
return meta;
}
@@ -159,11 +164,14 @@ status_t DummyAudioSource::read( MediaBuffer **out, const MediaSource::ReadOptio
if (options && options->getSeekTo(&seekTimeUs, &mode)) {
CHECK(seekTimeUs >= 0);
mTimeStampUs = seekTimeUs;
- }
-
- if (mTimeStampUs >= mAudioDurationUs) {
- *out = NULL;
- return ERROR_END_OF_STREAM;
+ }
+ {
+ Mutex::Autolock autoLock(mLock);
+ if (mTimeStampUs >= mAudioDurationUs) {
+ *out = NULL;
+ LOGI("EOS reached");
+ return ERROR_END_OF_STREAM;
+ }
}
err = mBufferGroup->acquire_buffer(&buffer);
diff --git a/libvideoeditor/lvpp/DummyAudioSource.h b/libvideoeditor/lvpp/DummyAudioSource.h
index a562bc1..6e6ead4 100755
--- a/libvideoeditor/lvpp/DummyAudioSource.h
+++ b/libvideoeditor/lvpp/DummyAudioSource.h
@@ -45,8 +45,9 @@ public:
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
virtual sp<MetaData> getFormat();
- virtual status_t read (MediaBuffer **buffer,
+ virtual status_t read (MediaBuffer **buffer,
const MediaSource::ReadOptions *options = NULL);
+ void setDuration (int64_t audioDurationUs);
protected:
DummyAudioSource (int32_t samplingRate,
@@ -63,6 +64,8 @@ private:
int64_t mAudioDurationUs;
int64_t mTimeStampUs;
int32_t mNbBuffer;
+ Mutex mLock;
+
MediaBufferGroup *mBufferGroup;
DummyAudioSource(const DummyAudioSource &);
diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp
index d6233fa..617a1b6 100644
--- a/libvideoeditor/lvpp/PreviewPlayer.cpp
+++ b/libvideoeditor/lvpp/PreviewPlayer.cpp
@@ -192,11 +192,12 @@ PreviewPlayer::PreviewPlayer()
mProgressCbInterval = 0;
mNumberDecVideoFrames = 0;
mOverlayUpdateEventPosted = false;
+ mIsChangeSourceRequired = true;
mVideoEvent = new PreviewPlayerEvent(this, &PreviewPlayer::onVideoEvent);
mVideoEventPending = false;
mStreamDoneEvent = new PreviewPlayerEvent(this,
- &AwesomePlayer::onStreamDone);
+ &PreviewPlayer::onStreamDone);
mStreamDoneEventPending = false;
@@ -396,7 +397,10 @@ void PreviewPlayer::reset_l() {
mTimeSource = NULL;
- delete mAudioPlayer;
+ //Single audio player instance used
+ //So donot delete it here
+ //It is deleted from PreviewController class
+ //delete mAudioPlayer;
mAudioPlayer = NULL;
if (mLastVideoBuffer) {
@@ -489,6 +493,93 @@ status_t PreviewPlayer::startAudioPlayer_l() {
return OK;
}
+status_t PreviewPlayer::setAudioPlayer(AudioPlayer *audioPlayer) {
+ Mutex::Autolock autoLock(mLock);
+ CHECK(!(mFlags & PLAYING));
+ mAudioPlayer = audioPlayer;
+
+ LOGV("SetAudioPlayer");
+ mIsChangeSourceRequired = true;
+ mVeAudioPlayer =
+ (VideoEditorAudioPlayer*)mAudioPlayer;
+
+ // check if the new and old source are dummy
+ sp<MediaSource> anAudioSource = mVeAudioPlayer->getSource();
+ if (anAudioSource == NULL) {
+ // Audio player does not have any source set.
+ LOGV("setAudioPlayer: Audio player does not have any source set");
+ return OK;
+ }
+
+ const char *pSrcType1;
+ const char *pSrcType2;
+ sp<MetaData> meta = anAudioSource->getFormat();
+
+ if (meta->findCString(kKeyDecoderComponent, &pSrcType1)) {
+ if (strcmp(pSrcType1, "DummyAudioSource") == 0) {
+ meta = mAudioSource->getFormat();
+ if (meta->findCString(kKeyDecoderComponent, &pSrcType2)) {
+ if (strcmp(pSrcType2, "DummyAudioSource") == 0) {
+ mIsChangeSourceRequired = false;
+ // Just set the new play duration for the existing source
+ MediaSource *pMediaSrc = anAudioSource.get();
+ DummyAudioSource *pDummyAudioSource = (DummyAudioSource*)pMediaSrc;
+ //Increment the duration of audio source
+ pDummyAudioSource->setDuration((int64_t)((mPlayEndTimeMsec)*1000));
+ }
+ }
+ }
+ }
+
+ return OK;
+}
+
+void PreviewPlayer::onStreamDone() {
+ // Posted whenever any stream finishes playing.
+
+ Mutex::Autolock autoLock(mLock);
+ if (!mStreamDoneEventPending) {
+ return;
+ }
+ mStreamDoneEventPending = false;
+
+ if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
+ LOGV("MEDIA_ERROR %d", mStreamDoneStatus);
+
+ notifyListener_l(
+ MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
+
+ pause_l(true /* at eos */);
+
+ mFlags |= AT_EOS;
+ return;
+ }
+
+ const bool allDone =
+ (mVideoSource == NULL || (mFlags & VIDEO_AT_EOS))
+ && (mAudioSource == NULL || (mFlags & AUDIO_AT_EOS));
+
+ if (!allDone) {
+ return;
+ }
+
+ if (mFlags & (LOOPING | AUTO_LOOPING)) {
+ seekTo_l(0);
+
+ if (mVideoSource != NULL) {
+ postVideoEvent_l();
+ }
+ } else {
+ LOGV("MEDIA_PLAYBACK_COMPLETE");
+ //pause before sending event
+ pause_l(true /* at eos */);
+ notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
+
+ mFlags |= AT_EOS;
+ }
+}
+
+
status_t PreviewPlayer::play_l() {
mFlags &= ~SEEK_PREVIEW;
@@ -531,25 +622,75 @@ status_t PreviewPlayer::play_l() {
mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
mCurrentMediaVolumeValue);
- mTimeSource = mVeAudioPlayer; //mAudioPlayer;
+ mFlags |= AUDIOPLAYER_STARTED;
+ // We've already started the MediaSource in order to enable
+ // the prefetcher to read its data.
+ status_t err = mVeAudioPlayer->start(
+ true /* sourceAlreadyStarted */);
+ if (err != OK) {
+ //delete mAudioPlayer;
+ mAudioPlayer = NULL;
+
+ mFlags &= ~(PLAYING | FIRST_FRAME);
+ return err;
+ }
+
+ mTimeSource = mVeAudioPlayer;
+ mFlags |= AUDIO_RUNNING;
deferredAudioSeek = true;
mWatchForAudioSeekComplete = false;
mWatchForAudioEOS = true;
}
- }
+ } else {
+ mVeAudioPlayer = (VideoEditorAudioPlayer*)mAudioPlayer;
+ bool isAudioPlayerStarted = mVeAudioPlayer->isStarted();
- CHECK(!(mFlags & AUDIO_RUNNING));
+ if (mIsChangeSourceRequired == true) {
+ LOGV("play_l: Change audio source required");
- if (mVideoSource == NULL) {
- status_t err = startAudioPlayer_l();
+ if (isAudioPlayerStarted == true) {
+ mVeAudioPlayer->pause();
+ }
- if (err != OK) {
- delete mAudioPlayer;
- mAudioPlayer = NULL;
- mFlags &= ~(PLAYING | FIRST_FRAME);
- return err;
+ mVeAudioPlayer->setSource(mAudioSource);
+ mVeAudioPlayer->setObserver(this);
+
+ mVeAudioPlayer->setAudioMixSettings(
+ mPreviewPlayerAudioMixSettings);
+
+ mVeAudioPlayer->setAudioMixStoryBoardSkimTimeStamp(
+ mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
+ mCurrentMediaVolumeValue);
+
+ if (isAudioPlayerStarted == true) {
+ mVeAudioPlayer->resume();
+ } else {
+ status_t err = OK;
+ err = mVeAudioPlayer->start(true);
+ if (err != OK) {
+ mAudioPlayer = NULL;
+ mVeAudioPlayer = NULL;
+
+ mFlags &= ~(PLAYING | FIRST_FRAME);
+ return err;
+ }
+ }
+ } else {
+ LOGV("play_l: No Source change required");
+ mVeAudioPlayer->setAudioMixStoryBoardSkimTimeStamp(
+ mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
+ mCurrentMediaVolumeValue);
+
+ mVeAudioPlayer->resume();
}
+
+ mFlags |= AUDIOPLAYER_STARTED;
+ mFlags |= AUDIO_RUNNING;
+ mTimeSource = mVeAudioPlayer;
+ deferredAudioSeek = true;
+ mWatchForAudioSeekComplete = false;
+ mWatchForAudioEOS = true;
}
}
@@ -828,6 +969,7 @@ void PreviewPlayer::onVideoEvent() {
finishSeekIfNecessary(-1);
LOGV("PreviewPlayer: onVideoEvent EOS reached.");
mFlags |= VIDEO_AT_EOS;
+ mFlags |= AUDIO_AT_EOS;
mOverlayUpdateEventPosted = false;
postStreamDoneEvent_l(err);
// Set the last decoded timestamp to duration
@@ -1094,6 +1236,11 @@ void PreviewPlayer::onVideoEvent() {
postStreamDoneEvent_l(ERROR_END_OF_STREAM);
}
else {
+ if (wasSeeking && (mFlags & SEEK_PREVIEW)) {
+ mFlags &= ~SEEK_PREVIEW;
+ return;
+ }
+
if(!mIsVideoSourceJpg) {
postVideoEvent_l(0);
}
@@ -1818,6 +1965,7 @@ status_t PreviewPlayer::readFirstVideoFrame() {
}
LOGV("PreviewPlayer: onVideoEvent EOS reached.");
mFlags |= VIDEO_AT_EOS;
+ mFlags |= AUDIO_AT_EOS;
postStreamDoneEvent_l(err);
return OK;
}
diff --git a/libvideoeditor/lvpp/PreviewPlayer.h b/libvideoeditor/lvpp/PreviewPlayer.h
index 4d3a312..0800115 100644
--- a/libvideoeditor/lvpp/PreviewPlayer.h
+++ b/libvideoeditor/lvpp/PreviewPlayer.h
@@ -93,6 +93,7 @@ struct PreviewPlayer : public AwesomePlayer {
status_t setImageClipProperties(uint32_t width, uint32_t height);
status_t readFirstVideoFrame();
status_t getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs);
+ status_t setAudioPlayer(AudioPlayer *audioPlayer);
private:
friend struct PreviewPlayerEvent;
@@ -123,11 +124,13 @@ private:
status_t initAudioDecoder();
status_t initVideoDecoder(uint32_t flags = 0);
void onVideoEvent();
+ void onStreamDone();
status_t finishSetDataSource_l();
static bool ContinuePreparation(void *cookie);
void onPrepareAsyncEvent();
void finishAsyncPrepare_l();
status_t startAudioPlayer_l();
+ bool mIsChangeSourceRequired;
sp<PreviewPlayerRenderer> mVideoRenderer;
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index 48d43b4..f33bd0a 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -48,6 +48,7 @@ VideoEditorAudioPlayer::VideoEditorAudioPlayer(
mBGAudioStoryBoardCurrentMediaBeginCutTS = 0;
mBGAudioStoryBoardCurrentMediaVolumeVal = 0;
mSeekTimeUs = 0;
+ mSource = NULL;
}
VideoEditorAudioPlayer::~VideoEditorAudioPlayer() {
@@ -61,9 +62,30 @@ VideoEditorAudioPlayer::~VideoEditorAudioPlayer() {
mAudioProcess = NULL;
}
}
+void VideoEditorAudioPlayer::setSource(const sp<MediaSource> &source) {
+ Mutex::Autolock autoLock(mLock);
+ mSource = source;
+ mReachedEOS = false;
+}
-status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
+sp<MediaSource> VideoEditorAudioPlayer::getSource() {
+ Mutex::Autolock autoLock(mLock);
+ return mSource;
+}
+
+void VideoEditorAudioPlayer::setObserver(AwesomePlayer *observer) {
+ LOGV("setObserver");
+ //CHECK(!mStarted);
+ mObserver = observer;
+}
+
+bool VideoEditorAudioPlayer::isStarted() {
+ return mStarted;
+}
+
+status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
+ Mutex::Autolock autoLock(mLock);
CHECK(!mStarted);
CHECK(mSource != NULL);
LOGV("Start");
@@ -85,11 +107,16 @@ status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
veAudMixSettings audioMixSettings;
// Pass on the audio ducking parameters
- audioMixSettings.lvInDucking_threshold = mAudioMixSettings->uiInDucking_threshold;
- audioMixSettings.lvInDucking_lowVolume = ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
- audioMixSettings.lvInDucking_enable = mAudioMixSettings->bInDucking_enable;
- audioMixSettings.lvPTVolLevel = ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
- audioMixSettings.lvBTVolLevel = ((M4OSA_Float)mAudioMixSettings->uiAddVolume) /100.0;
+ audioMixSettings.lvInDucking_threshold =
+ mAudioMixSettings->uiInDucking_threshold;
+ audioMixSettings.lvInDucking_lowVolume =
+ ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
+ audioMixSettings.lvInDucking_enable =
+ mAudioMixSettings->bInDucking_enable;
+ audioMixSettings.lvPTVolLevel =
+ ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
+ audioMixSettings.lvBTVolLevel =
+ ((M4OSA_Float)mAudioMixSettings->uiAddVolume) / 100.0;
audioMixSettings.lvBTChannelCount = mAudioMixSettings->uiBTChannelCount;
audioMixSettings.lvPTChannelCount = mAudioMixSettings->uiNbChannels;
@@ -306,6 +333,33 @@ status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
return OK;
}
+void VideoEditorAudioPlayer::resume() {
+
+ veAudMixSettings audioMixSettings;
+
+ // Single audio player is used;
+ // Pass on the audio ducking parameters
+ // which might have changed with new audio source
+ audioMixSettings.lvInDucking_threshold =
+ mAudioMixSettings->uiInDucking_threshold;
+ audioMixSettings.lvInDucking_lowVolume =
+ ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
+ audioMixSettings.lvInDucking_enable =
+ mAudioMixSettings->bInDucking_enable;
+ audioMixSettings.lvPTVolLevel =
+ ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
+ audioMixSettings.lvBTVolLevel =
+ ((M4OSA_Float)mAudioMixSettings->uiAddVolume) / 100.0;
+ audioMixSettings.lvBTChannelCount = mAudioMixSettings->uiBTChannelCount;
+ audioMixSettings.lvPTChannelCount = mAudioMixSettings->uiNbChannels;
+
+ // Call to Audio mix param setting
+ mAudioProcess->veSetAudioProcessingParams(audioMixSettings);
+
+ //Call the base class
+ AudioPlayer::resume();
+}
+
void VideoEditorAudioPlayer::reset() {
LOGV("reset");
@@ -336,9 +390,9 @@ size_t VideoEditorAudioPlayer::fillBuffer(void *data, size_t size) {
size_t size_remaining = size;
M4OSA_ERR err = M4NO_ERROR;
- M4AM_Buffer bgFrame = {NULL, 0};
- M4AM_Buffer mixFrame = {NULL, 0};
- M4AM_Buffer ptFrame = {NULL, 0};
+ M4AM_Buffer16 bgFrame = {NULL, 0};
+ M4AM_Buffer16 mixFrame = {NULL, 0};
+ M4AM_Buffer16 ptFrame = {NULL, 0};
int64_t currentSteamTS = 0;
int64_t startTimeForBT = 0;
M4OSA_Float fPTVolLevel =
@@ -384,7 +438,11 @@ size_t VideoEditorAudioPlayer::fillBuffer(void *data, size_t size) {
mIsFirstBuffer = false;
} else {
- status = mSource->read(&mInputBuffer, &options);
+
+ {
+ Mutex::Autolock autoLock(mLock);
+ status = mSource->read(&mInputBuffer, &options);
+ }
// Data is Primary Track, mix with background track
// after reading same size from Background track PCM file
if (status == OK)
@@ -395,9 +453,9 @@ size_t VideoEditorAudioPlayer::fillBuffer(void *data, size_t size) {
(int64_t)(mAudioMixSettings->uiAddCts * 1000)) {
LOGV("VideoEditorAudioPlayer::INSIDE MIXING");
- LOGV("Checking %lld <= %lld - %d",
+ LOGV("Checking %lld <= %lld",
mBGAudioPCMFileSeekPoint-mBGAudioPCMFileOriginalSeekPoint,
- mBGAudioPCMFileTrimmedLength, len);
+ mBGAudioPCMFileTrimmedLength);
M4OSA_Void* ptr;
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.h b/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
index 92b77b6..f5232cf 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
@@ -49,6 +49,7 @@ public:
virtual ~VideoEditorAudioPlayer();
status_t start(bool sourceAlreadyStarted = false);
+ void resume();
void setAudioMixSettings(M4xVSS_AudioMixingSettings* pAudioMixSettings);
void setAudioMixPCMFileHandle(M4OSA_Context pBGAudioPCMFileHandle);
@@ -57,6 +58,11 @@ public:
M4OSA_UInt32 pBGAudioCurrentMediaBeginCutTS,
M4OSA_UInt32 pBGAudioCurrentMediaVolumeVal);
+ void setObserver(AwesomePlayer *observer);
+ void setSource(const sp<MediaSource> &source);
+ sp<MediaSource> getSource();
+
+ bool isStarted();
private:
M4xVSS_AudioMixingSettings *mAudioMixSettings;
diff --git a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
index 2049f08..28208d1 100755
--- a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
+++ b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
@@ -50,9 +50,9 @@ VideoEditorBGAudioProcessing ::VideoEditorBGAudioProcessing() {
M4OSA_Int32 VideoEditorBGAudioProcessing::veProcessAudioMixNDuck(
void *pPTBuffer, void *pBTBuffer, void *pOutBuffer) {
- M4AM_Buffer* pPrimaryTrack = (M4AM_Buffer*)pPTBuffer;
- M4AM_Buffer* pBackgroundTrack = (M4AM_Buffer*)pBTBuffer;
- M4AM_Buffer* pMixedOutBuffer = (M4AM_Buffer*)pOutBuffer;
+ M4AM_Buffer16* pPrimaryTrack = (M4AM_Buffer16*)pPTBuffer;
+ M4AM_Buffer16* pBackgroundTrack = (M4AM_Buffer16*)pBTBuffer;
+ M4AM_Buffer16* pMixedOutBuffer = (M4AM_Buffer16*)pOutBuffer;
LOGV("VideoEditorBGAudioProcessing::lvProcessAudioMixNDuck \
pPTBuffer 0x%x pBTBuffer 0x%x pOutBuffer 0x%x", pPTBuffer,
diff --git a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
index 8c54e15..24586a7 100755
--- a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
+++ b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
@@ -31,7 +31,7 @@ enum veAudioFormat {MONO_16_BIT, STEREO_16_BIT};
typedef struct {
M4OSA_UInt16* m_dataAddress; // Android SRC needs a Int16 pointer
M4OSA_UInt32 m_bufferSize;
-} M4AM_Buffer;
+} M4AM_Buffer16; // Structure contains Int16_t pointer
// Following struct will be used by app to supply the PT and BT properties
// along with ducking values
@@ -78,9 +78,9 @@ private:
M4OSA_Float mPTVolLevel;
M4OSA_Float mBTVolLevel;
- M4AM_Buffer mPTBuffer;
- M4AM_Buffer mBTBuffer;
- M4AM_Buffer mOutMixBuffer;
+ M4AM_Buffer16 mPTBuffer;
+ M4AM_Buffer16 mBTBuffer;
+ M4AM_Buffer16 mOutMixBuffer;
M4OSA_Int16 *mTempBuffer;
M4OSA_Int32 mTempFrameCount;
diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.cpp b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
index ab2bb67..3e1743e 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
@@ -49,13 +49,16 @@ status_t VideoEditorPlayer::initCheck() {
return OK;
}
+
+status_t VideoEditorPlayer::setAudioPlayer(VideoEditorAudioPlayer *audioPlayer) {
+ return mPlayer->setAudioPlayer(audioPlayer);
+}
+
+
status_t VideoEditorPlayer::setDataSource(
const char *url, const KeyedVector<String8, String8> *headers) {
LOGI("setDataSource('%s')", url);
- mVeAudioSink = new VeAudioOutput();
- mPlayer->setAudioSink(mVeAudioSink);
-
return mPlayer->setDataSource(url, headers);
}
diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.h b/libvideoeditor/lvpp/VideoEditorPlayer.h
index c61e33a..da00ca5 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.h
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.h
@@ -23,14 +23,14 @@
#include "M4xVSS_API.h"
#include "VideoEditorMain.h"
#include "VideoEditorTools.h"
-
+#include "VideoEditorAudioPlayer.h"
namespace android {
struct PreviewPlayer;
class VideoEditorPlayer : public MediaPlayerInterface {
-
+ public:
class VeAudioOutput: public MediaPlayerBase::AudioSink
{
public:
@@ -144,6 +144,7 @@ public:
virtual status_t readFirstVideoFrame();
virtual status_t getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs);
+ status_t setAudioPlayer(VideoEditorAudioPlayer *audioPlayer);
private:
PreviewPlayer *mPlayer;
sp<VeAudioOutput> mVeAudioSink;
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 830648a..180f75e 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -461,6 +461,13 @@ M4OSA_ERR VideoEditorPreviewController::startPreview(
mTarget = NULL;
}
+ // Create Audio player to be used for entire
+ // storyboard duration
+ mVEAudioSink = new VideoEditorPlayer::VeAudioOutput();
+ mVEAudioPlayer = new VideoEditorAudioPlayer(mVEAudioSink);
+ mVEAudioPlayer->setAudioMixSettings(mBackgroundAudioSetting);
+ mVEAudioPlayer->setAudioMixPCMFileHandle(mAudioMixPCMFileHandle);
+
LOGV("startPreview: loop = %d", loop);
mPreviewLooping = loop;
@@ -671,6 +678,12 @@ M4OSA_UInt32 VideoEditorPreviewController::stopPreview() {
mVePlayer[playerInst] = NULL;
}
}
+ LOGV("stopPreview: clear audioSink and audioPlayer");
+ mVEAudioSink.clear();
+ if (mVEAudioPlayer) {
+ delete mVEAudioPlayer;
+ mVEAudioPlayer = NULL;
+ }
// If image file playing, then free the buffer pointer
if(mFrameStr.pBuffer != M4OSA_NULL) {
@@ -972,6 +985,7 @@ M4OSA_ERR VideoEditorPreviewController::preparePlayer(
LOGV("preparePlayer: seekTo(%d)",
pController->mClipList[index]->uiBeginCutTime);
}
+ pController->mVePlayer[pController->mCurrentPlayer]->setAudioPlayer(pController->mVEAudioPlayer);
pController->mVePlayer[playerInstance]->readFirstVideoFrame();
LOGV("preparePlayer: readFirstVideoFrame of clip");
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.h b/libvideoeditor/lvpp/VideoEditorPreviewController.h
index 216b077..e9e4e84 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.h
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.h
@@ -20,6 +20,7 @@
#include <utils/Log.h>
#include "VideoEditorPlayer.h"
+#include "VideoEditorAudioPlayer.h"
#include "M4OSA_Semaphore.h"
#include "M4OSA_Thread.h"
#include "M4OSA_Clock.h"
@@ -131,6 +132,9 @@ private:
M4OSA_Context mSemThreadWait;
bool mIsFiftiesEffectStarted;
+ sp<VideoEditorPlayer::VeAudioOutput> mVEAudioSink;
+ VideoEditorAudioPlayer *mVEAudioPlayer;
+
M4VIFI_UInt8* mFrameRGBBuffer;
M4VIFI_UInt8* mFrameYUVBuffer;
static M4OSA_ERR preparePlayer(void* param, int playerInstance, int index);