Skip to content

Commit

Permalink
refactor(SuperMediaPlayer): improve stop logic
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Feb 14, 2020
1 parent ac08430 commit d31c821
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,15 @@ namespace Cicada {

if (mDataSource) {
mDataSource->Interrupt(inter);
} else {
AF_TRACE;
}

if (mDemuxerService) {
mDemuxerService->interrupt(inter);
mDemuxerService->preStop();
} else {
AF_TRACE;
}
}

Expand Down Expand Up @@ -3254,6 +3258,10 @@ namespace Cicada {
}
}

if (mCanceled) {
return;
}

{
std::lock_guard<std::mutex> locker(mCreateMutex);
mDemuxerService = new demuxer_service(mDataSource);
Expand Down Expand Up @@ -3448,6 +3456,11 @@ namespace Cicada {
config.customHeaders = mSet.customHeaders;
config.listener = &mSourceListener;
mSourceListener.enableRetry();

if (mCanceled) {
return FRAMEWORK_ERR_EXIT;
}

{
std::lock_guard<std::mutex> locker(mCreateMutex);
mDataSource = dataSourcePrototype::create(mSet.url, &mSet.mOptions);
Expand Down

0 comments on commit d31c821

Please sign in to comment.