Apply ASSERT 02/36902/1 accepted/tizen/tv/20150317.055629 accepted/tizen/tv/20150317.055645 submit/tizen_tv/20150317.024518 submit/tizen_tv/20150317.024716
authorKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Mar 2015 02:44:03 +0000 (11:44 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Mar 2015 02:44:03 +0000 (11:44 +0900)
Change-Id: I8160bd71d5cd56dda607f394d2ca351b1e7c93a4
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/playback-mgr.h
src/playback/playback-mgr.cpp
src/playback/playlist-mgr.cpp

index 6ad1e7a..4e37b71 100644 (file)
@@ -46,7 +46,6 @@ public:
        bool Resume(void);
        bool Pause(void);
 
-       bool SetNextUri(const char *path);
        bool SetUri(const char *path);
        bool Prepare(void);
        bool Unprepare(void);
@@ -54,28 +53,5 @@ public:
        bool SetPosition(int milsec);
        bool GetPosition(int *const milsec);
 };
-/*
-struct playback;
-
-struct playback *playback_create();
-void playback_destroy(struct playback *plback);
-int playback_start(struct playback *plback);
-int playback_stop(struct playback *plback);
-
-int playback_add_completed_cb(struct playback *plback,
-               player_completed_cb on_playback_completion, void *data);
-int playback_remove_completed_cb(struct playback *plback);
-
-int playback_set_mute(struct playback *plback, bool flag);
-int playback_set_looping(struct playback *plback, bool flag);
 
-int playback_resume(struct playback *plback);
-int playback_pause(struct playback *plback);
-int playback_set_next_uri(struct playback *plback, const char *path);
-int playback_set_uri(struct playback *plback, const char *path);
-int playback_prepare(struct playback *plback);
-int playback_unprepare(struct playback *plback);
-int playback_set_position(struct playback *plback, int milsec);
-int playback_get_position(struct playback *plback, int *const milsec);
-*/
 #endif /*__PLAYBACK_MGR_H__*/
index 6a41d29..d87c8bf 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <stdlib.h>
+#include <AppCommon.h>
 #include "i18n.h"
 #include "dbg.h"
 #include "playback-mgr.h"
@@ -32,10 +33,9 @@ void _on_seek_completion(void *dt)
 
 bool CPlayback::Create(void)
 {
-       int r;
+       ASSERT(!m);
 
-       if (m)
-               return false;
+       int r;
 
        m = new SPlayback;
        if (!m)
@@ -55,27 +55,25 @@ bool CPlayback::Create(void)
 
 void CPlayback::Destroy(void)
 {
-       if (!m)
-               return;
+       ASSERT(m);
+       ASSERT(m->player);
 
        int r;
        player_state_e state;
 
-       if (m->player) {
-               r = player_get_state(m->player, &state);
-               if (r == PLAYER_ERROR_NONE) {
-                       if (state == PLAYER_STATE_PLAYING ||
-                                       state == PLAYER_STATE_PAUSED)
-                               player_stop(m->player);
-                       if (state == PLAYER_STATE_READY)
-                               player_unprepare(m->player);
-               }
-
-               r = player_destroy(m->player);
-               if (r != PLAYER_ERROR_NONE)
-                       _ERR("Player destroy failed");
+       r = player_get_state(m->player, &state);
+       if (r == PLAYER_ERROR_NONE) {
+               if (state == PLAYER_STATE_PLAYING ||
+                               state == PLAYER_STATE_PAUSED)
+                       player_stop(m->player);
+               if (state == PLAYER_STATE_READY)
+                       player_unprepare(m->player);
        }
 
+       r = player_destroy(m->player);
+       if (r != PLAYER_ERROR_NONE)
+               _ERR("Player destroy failed");
+
        delete m;
        m = NULL;
 }
@@ -83,15 +81,10 @@ void CPlayback::Destroy(void)
 
 bool CPlayback::Start(void)
 {
-       if (!m)
-               return false;
-
-       int r;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       if (!m->player)
-               return false;
-
-       r = player_start(m->player);
+       int r = player_start(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player start failed");
                return false;
@@ -103,15 +96,10 @@ bool CPlayback::Start(void)
 
 bool CPlayback::Stop(void)
 {
-       if (!m)
-               return false;
-
-       int r;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       if (!m->player)
-               return false;
-
-       r = player_stop(m->player);
+       int r = player_stop(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player stop failed");
                return false;
@@ -123,14 +111,10 @@ bool CPlayback::Stop(void)
 
 bool CPlayback::SetCallback(player_completed_cb on_playback_completion, void *data)
 {
-       if (!m)
-               return false;
-
-       int r;
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_set_completed_cb(m->player, on_playback_completion, data);
+       int r = player_set_completed_cb(m->player, on_playback_completion, data);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set completed callaback failed");
                return false;
@@ -142,15 +126,10 @@ bool CPlayback::SetCallback(player_completed_cb on_playback_completion, void *da
 
 bool CPlayback::UnsetCallback(void)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_unset_completed_cb(m->player);
+       int r = player_unset_completed_cb(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player unset completed cb failed");
                return false;
@@ -162,15 +141,10 @@ bool CPlayback::UnsetCallback(void)
 
 bool CPlayback::SetMute(bool flag)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_set_mute(m->player, flag);
+       int r = player_set_mute(m->player, flag);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set mute failed");
                return false;
@@ -182,15 +156,10 @@ bool CPlayback::SetMute(bool flag)
 
 bool CPlayback::SetLooping(bool flag)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_set_looping(m->player, flag);
+       int r = player_set_looping(m->player, flag);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set looping failed");
                return false;
@@ -202,15 +171,10 @@ bool CPlayback::SetLooping(bool flag)
 
 bool CPlayback::Resume(void)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_start(m->player);
+       int r = player_start(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player start in playback resume failed");
                return false;
@@ -222,15 +186,10 @@ bool CPlayback::Resume(void)
 
 bool CPlayback::Pause(void)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_pause(m->player);
+       int r = player_pause(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player pause failed");
                return false;
@@ -240,38 +199,12 @@ bool CPlayback::Pause(void)
 }
 
 
-bool CPlayback::SetNextUri(const char *path)
-{
-       // Not used
-       /*if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
-
-       r = player_set_next_uri(m->player, path);
-       if (r != PLAYER_ERROR_NONE) {
-               _ERR("Player set next uri failed");
-               return false;
-       }*/
-
-       return true;
-}
-
-
 bool CPlayback::SetUri(const char *path)
 {
-       if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_set_uri(m->player, path);
+       int r = player_set_uri(m->player, path);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set uri failed");
                return false;
@@ -283,15 +216,10 @@ bool CPlayback::SetUri(const char *path)
 
 bool CPlayback::Prepare(void)
 {
-       if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_prepare(m->player);
+       int r = player_prepare(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player prepare failed");
                return false;
@@ -303,15 +231,10 @@ bool CPlayback::Prepare(void)
 
 bool CPlayback::Unprepare(void)
 {
-       if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_unprepare(m->player);
+       int r = player_unprepare(m->player);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player unprepare failed");
                return false;
@@ -323,15 +246,10 @@ bool CPlayback::Unprepare(void)
 
 bool CPlayback::SetPosition(int milsec)
 {
-       if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_set_play_position(m->player, milsec, false, _on_seek_completion, m);
+       int r = player_set_play_position(m->player, milsec, false, _on_seek_completion, m);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set position failed");
                return false;
@@ -343,15 +261,10 @@ bool CPlayback::SetPosition(int milsec)
 
 bool CPlayback::GetPosition(int *const milsec)
 {
-       if (!m)
-               return false;
-
-       int r;
-
-       if (!m->player)
-               return false;
+       ASSERT(m);
+       ASSERT(m->player);
 
-       r = player_get_play_position(m->player, milsec);
+       int r = player_get_play_position(m->player, milsec);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set position failed");
                return false;
index 8e163ce..f13c79e 100644 (file)
@@ -17,6 +17,7 @@
 #include <app.h>
 #include <stdlib.h>
 #include <string.h>
+#include <AppCommon.h>
 #include "dbg.h"
 #include "i18n.h"
 #include "song_info.h"
@@ -126,8 +127,7 @@ static int _get_next(int *list, int size, int index)
 
 bool CPlaylist::Create(Eina_List *songlist)
 {
-       if (m)
-               return false;
+       ASSERT(!m);
 
        CSongInfo *sinfo;
        CSongInfo *d_sinfo;
@@ -167,8 +167,7 @@ bool CPlaylist::Create(Eina_List *songlist)
 
 void CPlaylist::Destroy(void)
 {
-       if (!m)
-               return;
+       ASSERT(m);
 
        CSongInfo *sinfo;
        void *obj;
@@ -191,8 +190,8 @@ void CPlaylist::Destroy(void)
 
 bool CPlaylist::Update(Eina_List *songlist, int addmode)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(songlist);
 
        CSongInfo *sinfo;
        CSongInfo *d_sinfo;
@@ -201,11 +200,6 @@ bool CPlaylist::Update(Eina_List *songlist, int addmode)
        Eina_List *l;
        int rindex;
 
-       if (!songlist) {
-               _ERR(" No m or songlist ");
-               return NULL;
-       }
-
        if (addmode == ADD_TYPE_FRESH || (m->total_songs == 0)) {
                Destroy();
                return Create(songlist);
@@ -242,8 +236,8 @@ bool CPlaylist::Update(Eina_List *songlist, int addmode)
 
 bool CPlaylist::SetCurrentSong(char *mediaid)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
+       ASSERT(mediaid);
 
        Eina_List *l;
        CSongInfo *sinfo;
@@ -270,8 +264,7 @@ bool CPlaylist::SetCurrentSong(char *mediaid)
 
 bool CPlaylist::SetCurSongIndex(int index)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
 
        if (index < 0 || index >= m->total_songs) {
                _ERR(" set index is out of range ");
@@ -286,10 +279,7 @@ bool CPlaylist::SetCurSongIndex(int index)
 
 bool CPlaylist::GetCurSongIndex(int *index)
 {
-       if (!m) {
-               _ERR(" No play list");
-               return false;
-       }
+       ASSERT(m);
 
        *index = m->cur_song_index;
 
@@ -299,10 +289,7 @@ bool CPlaylist::GetCurSongIndex(int *index)
 
 bool CPlaylist::GetTotalSongs(int *ts)
 {
-       if (!m) {
-               _ERR(" No play list");
-               return false;
-       }
+       ASSERT(m);
 
        *ts = m->total_songs;
 
@@ -312,12 +299,9 @@ bool CPlaylist::GetTotalSongs(int *ts)
 
 bool CPlaylist::LoadNextSong(int shufstate)
 {
-       int index, total_songs;
+       ASSERT(m);
 
-       if (!m) {
-               _ERR(" No play list");
-               return false;
-       }
+       int index, total_songs;
 
        total_songs = m->total_songs;
 
@@ -343,12 +327,9 @@ bool CPlaylist::LoadNextSong(int shufstate)
 
 bool CPlaylist::LoadPreviousSong(int shufstate)
 {
-       int index, total_songs;
+       ASSERT(m);
 
-       if (!m) {
-               _ERR(" No play list");
-               return false;
-       }
+       int index, total_songs;
 
        total_songs = m->total_songs;
 
@@ -375,8 +356,7 @@ bool CPlaylist::LoadPreviousSong(int shufstate)
 
 const char *CPlaylist::SongpathFromIndex(int index)
 {
-       if (!m)
-               return NULL;
+       ASSERT(m);
 
        const char *path;
        CSongInfo *sinfo;
@@ -409,8 +389,7 @@ const char *CPlaylist::SongpathFromIndex(int index)
 
 bool CPlaylist::GetSonginfoFromIndex(int index, CSongInfo **const csinfo)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
 
        CSongInfo *sinfo;
 
@@ -438,8 +417,7 @@ bool CPlaylist::GetSonginfoFromIndex(int index, CSongInfo **const csinfo)
 
 bool CPlaylist::RemoveSong(CSongInfo *sinfo, int index, int shufstate)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
 
        if (!m->songlist) {
                _ERR(" No play list");
@@ -465,8 +443,7 @@ bool CPlaylist::RemoveSong(CSongInfo *sinfo, int index, int shufstate)
 
 bool CPlaylist::UpdateShuffle(void)
 {
-       if (!m)
-               return false;
+       ASSERT(m);
 
        int i;
        int *list;