Skip to content

Commit

Permalink
fix(audioTrackRender): make thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
I-m-SuperMan authored and skufly committed Apr 13, 2020
1 parent 8904fd7 commit 93d4fa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion framework/render/audio/Android/AudioTrackRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ uint64_t AudioTrackRender::getDevicePlayedSimples()

int AudioTrackRender::device_write(unique_ptr<IAFFrame> &frame)
{
uint64_t playedSamples = getDevicePlayedSimples();
if(mFlushPositionReset != FlushRestPosition::notReset) {
uint64_t playedSamples = getDevicePlayedSimples();
if (playedSamples >= 0x7F000000) {
uint64_t deviceQueDuration = device_get_que_duration();
if (deviceQueDuration > 0) {
Expand Down
6 changes: 3 additions & 3 deletions framework/render/audio/Android/AudioTrackRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class AudioTrackRender :


private:
uint64_t mBasePlayedPosition = 0;
std::atomic<uint64_t> mBasePlayedPosition = 0;
uint8_t *mPcmBuffer = nullptr;
int64_t mPcmBufferLen = 0;

int64_t mPlayedBufferLen = 0;
int64_t mAudioFlushPosition = 0;
std::atomic<int64_t> mAudioFlushPosition = 0;

std::atomic<uint64_t> mSendSimples{0};
int mSimpleSize{0};
Expand All @@ -96,7 +96,7 @@ class AudioTrackRender :
unknow , reset, notReset
};

FlushRestPosition mFlushPositionReset = FlushRestPosition::unknow;
std::atomic<FlushRestPosition> mFlushPositionReset = FlushRestPosition::unknow;

};

Expand Down

0 comments on commit 93d4fa7

Please sign in to comment.