Skip to content

Commit

Permalink
MediaPlayer : Check parameter of setDataSource
Browse files Browse the repository at this point in the history
If source is nullptr, setDataSource returns PLAYER_ERROR.
Else it returns PLAYER_OK.
  • Loading branch information
junmin-kim committed Apr 23, 2018
1 parent 93fc855 commit c7d4cab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion framework/include/media/MediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ class MediaPlayer
* @details @b #include <media/MediaPlayer.h>
* This function is sync call apis
* @param[in] dataSource The dataSource that the config of input data
* @return The result of the setDataSource operation
* @since TizenRT v2.0 PRE
*/
void setDataSource(std::unique_ptr<stream::InputDataSource>);
player_result_t setDataSource(std::unique_ptr<stream::InputDataSource>);
/**
* @brief Sets the observer of MediaPlayer
* @details @b #include <media/MediaPlayer.h>
Expand Down
4 changes: 2 additions & 2 deletions framework/src/media/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ player_result_t MediaPlayer::setVolume(int vol)
return mPMpImpl->setVolume(vol);
}

void MediaPlayer::setDataSource(std::unique_ptr<stream::InputDataSource> source)
player_result_t MediaPlayer::setDataSource(std::unique_ptr<stream::InputDataSource> source)
{
mPMpImpl->setDataSource(std::move(source));
return mPMpImpl->setDataSource(std::move(source));
}

void MediaPlayer::setObserver(std::shared_ptr<MediaPlayerObserverInterface> observer)
Expand Down
8 changes: 7 additions & 1 deletion framework/src/media/MediaPlayerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,17 @@ player_result_t MediaPlayerImpl::setVolume(int vol)
}
}

void MediaPlayerImpl::setDataSource(std::unique_ptr<stream::InputDataSource> source)
player_result_t MediaPlayerImpl::setDataSource(std::unique_ptr<stream::InputDataSource> source)
{
std::lock_guard<std::mutex> lock(mCmdMtx);
medvdbg("MediaPlayer setDataSource\n");
if (!source) {
meddbg("MediaPlayer setDataSource fail : invalid argument. DataSource should not be nullptr\n");
return PLAYER_ERROR;
}

mInputDataSource = std::move(source);
return PLAYER_OK;
}

void MediaPlayerImpl::setObserver(std::shared_ptr<MediaPlayerObserverInterface> observer)
Expand Down
2 changes: 1 addition & 1 deletion framework/src/media/MediaPlayerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MediaPlayerImpl : public std::enable_shared_from_this<MediaPlayerImpl>
int getVolume();
player_result_t setVolume(int);

void setDataSource(std::unique_ptr<stream::InputDataSource>);
player_result_t setDataSource(std::unique_ptr<stream::InputDataSource>);
void setObserver(std::shared_ptr<MediaPlayerObserverInterface>);

player_state_t getState();
Expand Down

0 comments on commit c7d4cab

Please sign in to comment.