From a6e9a8399700e7de159cf3a95855e4dcb9ce569b Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Fri, 20 Mar 2015 17:53:18 +0900 Subject: [PATCH 01/16] Fix to show "ADD TO PLAYLIST" context popup in ContextView Change-Id: Ic805b5a3b0690b70bbdc95bcca63611dd1f58ba5 Signed-off-by: Kim Tae Soo --- include/define.h | 4 ++-- src/views/PlayListCtxPopup.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/define.h b/include/define.h index 93fb8b4..4b9ce75 100644 --- a/include/define.h +++ b/include/define.h @@ -425,8 +425,8 @@ #define POSITION_SOURCE_POPUP_Y 155 #define POSITION_PLAY_SETTING_POPUP_X 212 #define POSITION_PLAY_SETTING_POPUP_Y 705 -#define POSITION_PLAY_LIST_POPUP_X 1644 -#define POSITION_PLAY_LIST_POPUP_Y 1020 +#define POSITION_PLAY_LIST_POPUP_X 1645 +#define POSITION_PLAY_LIST_POPUP_Y 190 /* TEMP KEY DEFINITION */ #undef KEY_VOLUMEUP diff --git a/src/views/PlayListCtxPopup.cpp b/src/views/PlayListCtxPopup.cpp index 04821d5..9146082 100644 --- a/src/views/PlayListCtxPopup.cpp +++ b/src/views/PlayListCtxPopup.cpp @@ -42,7 +42,7 @@ void CPlayListCtxPopup::t_OnConfiguration(void) t_SetList((const char **)m->settingTexts, m->listSize, 0, CCtxPopup::TOPBTN_BASE, (const char **)m->btnIds, POSITION_PLAY_LIST_POPUP_X, POSITION_PLAY_LIST_POPUP_Y, - NULL, + MUSIC_STYLE_LIST_POPUP, MUSIC_STYLE_TOPTEXT_BTN, MUSIC_STYLE_MIDDLETEXT_BTN, MUSIC_STYLE_BOTTOMTEXT_BTN); } -- 2.7.4 From cf1d694f4be2e357bd50fda055b5f1e3af4ba001 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 23 Mar 2015 08:26:37 +0900 Subject: [PATCH 02/16] Fix bug: Key event processing for focus move should not be done when there is no contents Change-Id: I404472126341657c319c03e45f1fcd569c2d7fb1 Signed-off-by: Kim Tae Soo --- src/views/base-view.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index f66379a..e8804d6 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -999,7 +999,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) elm_object_focus_set(m->c_grpbtn, EINA_TRUE); - else if (!strcmp(ev->keyname, KEY_DOWN)) { + else if (!strcmp(ev->keyname, KEY_DOWN) && + !((CExtBaseLayout *)m->lmgr->Layout())->EmptyStatus()) { const char *btnText = NULL; if (id == BASE_VIEW_PLAY_BUTTON) -- 2.7.4 From 6d1f6a234ca73713f72c22cde292cc3c7565de53 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 23 Mar 2015 11:45:46 +0900 Subject: [PATCH 03/16] Fix callback mechanism for playback complete, usb connection, contents updated. Change-Id: I7199be0361b8cf4d020ee0cc392ae88491448aa8 Signed-off-by: Kim Tae Soo --- include/base-view.h | 9 +- include/music-controller.h | 34 ++- include/playback-view.h | 9 +- src/data/mediadata.cpp | 4 +- src/playback/music-controller.cpp | 491 ++++++++++++++++++-------------------- src/views/base-view.cpp | 8 +- src/views/playback-view.cpp | 8 +- 7 files changed, 268 insertions(+), 295 deletions(-) diff --git a/include/base-view.h b/include/base-view.h index eea02fd..39ecb51 100644 --- a/include/base-view.h +++ b/include/base-view.h @@ -94,11 +94,10 @@ public: virtual void OnMouseClicked(int id, Evas_Object *obj); virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); -protected: - virtual void t_OnComplete(void); - virtual void t_OnError(void); - virtual void t_OnUsbConnected(void); - virtual void t_OnUpdateContent(void); + virtual void OnComplete(void); + virtual void OnError(void); + virtual void OnUsbConnected(void); + virtual void OnUpdateContent(void); }; diff --git a/include/music-controller.h b/include/music-controller.h index 498017a..4accf5c 100644 --- a/include/music-controller.h +++ b/include/music-controller.h @@ -23,17 +23,16 @@ class IMusicControllerListener { -private: - static void sm_CbComplete(void *cookie); - static void sm_CbError(void *cookie); - static void sm_CbUsbConnected(void *cookie); - static void sm_CbUpdateContent(void *cookie); - -protected: - virtual void t_OnComplete(void) = 0; - virtual void t_OnError(void) = 0; - virtual void t_OnUsbConnected(void) = 0; - virtual void t_OnUpdateContent(void) = 0; +public: + static void s_CbComplete(void *cookie); + static void s_CbError(void *cookie); + static void s_CbUsbConnected(void *cookie); + static void s_CbUpdateContent(void *cookie); + + virtual void OnComplete(void) = 0; + virtual void OnError(void) = 0; + virtual void OnUsbConnected(void) = 0; + virtual void OnUpdateContent(void) = 0; }; @@ -65,6 +64,8 @@ private: static void sm_CbContentUpdated(void *dt); void m_OnContentUpdated(void); + void m_InvokeErrorCallback(SMusicController *m, int type); + protected: bool t_PlayNext(int direction, int playnext_type); SMusicController* t_Create(void); @@ -97,12 +98,10 @@ public: bool UpdatePlaylist(Eina_List *slist, int addmode); bool EmptyPlaylist(void); - bool PlaylistUpdateShuffle(void); bool PlayPreviousSong(void); bool PlayNextSong(void); bool PlayIndexSong(int index); bool RemoveSong(CSongInfo *sinfo, int index); - bool CheckUsb(void); bool MediaGetList(int EListType, void *info, Eina_List **list); bool MediaInsertPlaylist(const char *name, Eina_List *idlist); @@ -116,16 +115,13 @@ public: CSongInfo *MediaSongByUri(char *uri); bool SetPlayState(EPlayStatus state); - EPlayStatus - PlayState(void); + EPlayStatus PlayState(void); bool SetShuffleState(EShuffleStatus state); - EShuffleStatus - ShuffleState(void); + EShuffleStatus ShuffleState(void); bool SetRepeatState(ERepeatStatus state); - ERepeatStatus - RepeatState(void); + ERepeatStatus RepeatState(void); public: virtual void OnConnect(void); diff --git a/include/playback-view.h b/include/playback-view.h index a1e36a3..991e928 100644 --- a/include/playback-view.h +++ b/include/playback-view.h @@ -150,11 +150,10 @@ public: virtual void OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item); virtual void OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item); -protected: - virtual void t_OnComplete(void); - virtual void t_OnError(void); - virtual void t_OnUsbConnected(void); - virtual void t_OnUpdateContent(void); + virtual void OnComplete(void); + virtual void OnError(void); + virtual void OnUsbConnected(void); + virtual void OnUpdateContent(void); }; diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index d0d3d99..71ca524 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -360,7 +360,7 @@ void CMediadata::Destroy(void) ASSERT(FlagCreate()); int r; - struct SCbInfo *cbinfo; + SCbInfo *cbinfo; void *obj; m->storageSong->Delete(); @@ -379,7 +379,7 @@ void CMediadata::Destroy(void) EINA_LIST_FREE(m->cblist, obj) { cbinfo = (SCbInfo *)obj; - free(cbinfo); + delete cbinfo; } CMediaContentDbUpdateListener::Destroy(); diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index 6a231e9..d521f1a 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -66,51 +66,102 @@ CMusicController *CMusicController::instance = NULL; int CMusicController::refCnt = 0; -void IMusicControllerListener::sm_CbComplete(void *cookie) +// Implementation of IMusicControllerListener +void IMusicControllerListener::s_CbComplete(void *cookie) { IMusicControllerListener *root = (IMusicControllerListener *)cookie; if (root) - root->t_OnComplete(); + root->OnComplete(); } -void IMusicControllerListener::sm_CbError(void *cookie) +void IMusicControllerListener::s_CbError(void *cookie) { IMusicControllerListener *root = (IMusicControllerListener *)cookie; if (root) - root->t_OnError(); + root->OnError(); } -void IMusicControllerListener::sm_CbUsbConnected(void *cookie) +void IMusicControllerListener::s_CbUsbConnected(void *cookie) { IMusicControllerListener *root = (IMusicControllerListener *)cookie; if (root) - root->t_OnUsbConnected(); + root->OnUsbConnected(); } -void IMusicControllerListener::sm_CbUpdateContent(void *cookie) +void IMusicControllerListener::s_CbUpdateContent(void *cookie) { IMusicControllerListener *root = (IMusicControllerListener *)cookie; if (root) - root->t_OnUpdateContent(); + root->OnUpdateContent(); } -static void _run_callback(SMusicController *m, int type) +// Implementation of CMusicController +void CMusicController::sm_CbPlaybackCompletion(void *dt) { + CMusicController* root = (CMusicController*)dt; + if (root) + root->m_OnPlaybackCompletion(); +} + + +void CMusicController::m_OnPlaybackCompletion(void) +{ + bool r; Eina_List *l; - SCbInfo *cbinfo; + IMusicControllerListener *mcListener = NULL; + void *obj; + + r = t_PlayNext(DIR_NEXT, E_ON_COMPLETE); + if (r == false) + _ERR(" music play next song failed "); + + EINA_LIST_FOREACH(m->elListener, l, obj) { + mcListener = (IMusicControllerListener *)obj; + if (mcListener) + mcListener->s_CbComplete(mcListener); + } +} + + +void CMusicController::sm_CbContentUpdated(void *dt) +{ + CMusicController *root = (CMusicController *)dt; + if (root) + root->m_OnContentUpdated(); +} + + +void CMusicController::m_OnContentUpdated(void) +{ + Eina_List *l; + IMusicControllerListener *mcListener = NULL; + void *obj; + + EINA_LIST_FOREACH(m->elListener, l, obj) { + mcListener = (IMusicControllerListener *)obj; + if (mcListener) + mcListener->s_CbUpdateContent(mcListener); + } +} + + +void CMusicController::m_InvokeErrorCallback(SMusicController *m, int type) +{ + Eina_List *l; + IMusicControllerListener *mcListener = NULL; void *obj; if (!m) return; EINA_LIST_FOREACH(m->elListener, l, obj) { - cbinfo = (SCbInfo *)obj; - if (cbinfo->type == type && cbinfo->cb) - cbinfo->cb(cbinfo->data); + mcListener = (IMusicControllerListener *)obj; + if (mcListener) + mcListener->s_CbError(mcListener); } } @@ -126,12 +177,13 @@ bool CMusicController::t_PlayNext(int direction, int playnext_type) Stop(); if (playnext_type == E_ON_COMPLETE && - m->repeatstate == REPEAT_STATUS_ONE) + m->repeatstate == REPEAT_STATUS_ONE) goto finish; if (direction == DIR_NEXT) { r = m->pPlaylist->LoadNextSong(m->stateShuffle); - } else { + } + else { r = m->pPlaylist->LoadPreviousSong(m->stateShuffle); } @@ -141,7 +193,7 @@ bool CMusicController::t_PlayNext(int direction, int playnext_type) } if (playnext_type == E_ON_COMPLETE && - m->repeatstate == REPEAT_STATUS_NONE) { + m->repeatstate == REPEAT_STATUS_NONE) { r = m->pPlaylist->GetCurSongIndex(&index); if (r == false) { _ERR(" get cur song index failed "); @@ -158,54 +210,6 @@ finish: return true; } -void CMusicController::sm_CbPlaybackCompletion(void *dt) -{ - CMusicController* root = (CMusicController*)dt; - if (root) - root->m_OnPlaybackCompletion(); -} - - -void CMusicController::m_OnPlaybackCompletion(void) -{ - bool r; - Eina_List *l; - SCbInfo *cbinfo; - void *obj; - - r = t_PlayNext(DIR_NEXT, E_ON_COMPLETE); - if (r == false) - _ERR(" music play next song failed "); - - EINA_LIST_FOREACH(m->elListener, l, obj) { - cbinfo = (SCbInfo *)obj; - if (cbinfo->type == E_SONG_COMPLETE && cbinfo->cb) - cbinfo->cb(cbinfo->data); - } -} - - -void CMusicController::sm_CbContentUpdated(void *dt) -{ - CMusicController *root = (CMusicController *)dt; - if (root) - root->m_OnContentUpdated(); -} - - -void CMusicController::m_OnContentUpdated(void) -{ - Eina_List *l; - SCbInfo *cbinfo; - void *obj; - - EINA_LIST_FOREACH(m->elListener, l, obj) { - cbinfo = (SCbInfo *)obj; - if (cbinfo->type == E_CONTENT_UPDATE && cbinfo->cb) - cbinfo->cb(cbinfo->data); - } -} - SMusicController *CMusicController::t_Create(void) { @@ -243,33 +247,8 @@ SMusicController *CMusicController::t_Create(void) } -bool CMusicController::Initialize(void) -{ - if (refCnt == 0) { - instance = new CMusicController; - if (instance == NULL) { - return false; - } - instance->m = instance->t_Create(); - if (!instance->m) { - _ERR("music_init failed"); - delete instance; - instance = NULL; - return false; - } - } - - refCnt++; - - return true; -} - - void CMusicController::t_Destroy(void) { - SCbInfo *cbinfo; - void *obj; - CUsbConnectionListener::Destroy(); if (m->pPlayback->FlagCreate()) { @@ -288,13 +267,29 @@ void CMusicController::t_Destroy(void) m->alinfo->Destroy(); delete m->alinfo; + delete m; +} - EINA_LIST_FREE(m->elListener, obj) { - cbinfo = (SCbInfo *)obj; - free(cbinfo); + +bool CMusicController::Initialize(void) +{ + if (refCnt == 0) { + instance = new CMusicController; + if (instance == NULL) { + return false; + } + instance->m = instance->t_Create(); + if (!instance->m) { + _ERR("music_init failed"); + delete instance; + instance = NULL; + return false; + } } - delete m; + refCnt++; + + return true; } @@ -318,123 +313,124 @@ CMusicController* CMusicController::GetInstance(void) } -bool CMusicController::UpdatePlaylist(Eina_List *slist, int addmode) +bool CMusicController::Start(void) { ASSERT(m); - ASSERT(slist); - if (m->pPlaylist->FlagCreate()) - m->pPlaylist->Update(slist, addmode); - else { - if (!m->pPlaylist->Create(slist)) - _ERR(" playlist create failed "); - } - return true; -} + const char *songpath; + int index; + CPlaylist *pPlaylist; + CPlayback *pPlayback; + CSongInfo *sinfo; + char *media_id; + pPlaylist = m->pPlaylist; + pPlayback = m->pPlayback; -bool CMusicController::AddListener(IMusicControllerListener *listener) -{ - ASSERT(m); - ASSERT(listener); + _CREATE_BEGIN{ + _CHECK(pPlaylist && pPlayback) + _CHECK(pPlaylist->GetCurSongIndex(&index)) + _CHECK(songpath = pPlaylist->SongpathFromIndex(index)) + _CHECK(pPlayback->SetUri(songpath)) + _CHECK(pPlayback->Prepare()) + _CHECK(pPlayback->Start()) - m->elListener = eina_list_append(m->elListener, listener); + _WHEN_SUCCESS{ + m->statePlay = PLAY_STATUS_PLAY; + + _CHECK(m->pPlaylist->GetSonginfoFromIndex(index, &sinfo)) + _CHECK(media_id = sinfo->Id()) + _CHECK(m->pMediadata->SetPlayedTime(media_id)) + + _WHEN_SUCCESS{ + bus_send_signal(); + } + + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + } + + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ _ERR("Playback Failed!!"); m_InvokeErrorCallback(m, E_PLAYBACK_ERROR); } + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ _ERR("CMusicController::Start Failed!!"); Stop(); } + } _CREATE_END_AND_CATCH{ return false; } return true; } -bool CMusicController::RemoveListener(IMusicControllerListener *listener) +bool CMusicController::Stop(void) { ASSERT(m); - ASSERT(listener); - m->elListener = eina_list_remove(m->elListener, listener); + if (!m->pPlayback->FlagCreate()) + return false; + + if (!m->pPlayback->Stop()) + _ERR(" playback stop failed "); + + m->statePlay = PLAY_STATUS_STOP; + + if (!m->pPlayback->Unprepare()) + _ERR(" playback unprepare failed"); return true; } -bool CMusicController::Start(void) +bool CMusicController::Resume(void) { ASSERT(m); - const char *songpath; - int index; - CPlaylist *pPlaylist; - CPlayback *pPlayback; - CSongInfo *sinfo; - char *media_id; - - pPlaylist = m->pPlaylist; - pPlayback = m->pPlayback; + if (!m->pPlayback->FlagCreate()) + return false; - if (!pPlaylist || !pPlayback) - goto error; + if (!m->pPlayback->Resume()) + return false; - if (!pPlaylist->GetCurSongIndex(&index)) { - _ERR(" playlist get current song index failed"); - goto error; - } + m->statePlay = PLAY_STATUS_PLAY; - songpath = pPlaylist->SongpathFromIndex(index); - if (!songpath) { - _ERR(" palylist get song path from index failed"); - goto error; - } + return true; +} - if (!pPlayback->SetUri(songpath)) { - _ERR(" playback set uri failed"); - goto playback_error; - } - if (!pPlayback->Prepare()) { - _ERR(" playback prepare failed"); - goto playback_error; - } +bool CMusicController::Pause(void) +{ + ASSERT(m); - if (!pPlayback->Start()) { - _ERR(" playback start failed"); - goto playback_error; - } + if (!m || !m->pPlayback->FlagCreate()) + return false; - m->statePlay = PLAY_STATUS_PLAY; + if (!m->pPlayback->Pause()) + return false; - if (m->pPlaylist->GetSonginfoFromIndex(index, &sinfo)) { - media_id = sinfo->Id(); - if (media_id) { - if (m->pMediadata->SetPlayedTime(media_id)) - bus_send_signal(); - } else - _ERR("song info get media id failed"); - } else - _ERR("playback get songinfo failed"); + m->statePlay = PLAY_STATUS_PAUSE; return true; - -playback_error: - _run_callback(m, E_PLAYBACK_ERROR); -error: - Stop(); - - return false; } -bool CMusicController::Stop(void) +bool CMusicController::AddListener(IMusicControllerListener *listener) { ASSERT(m); + ASSERT(listener); - if (!m->pPlayback->FlagCreate()) - return false; + m->elListener = eina_list_append(m->elListener, listener); - if (!m->pPlayback->Stop()) - _ERR(" playback stop failed "); + return true; +} - m->statePlay = PLAY_STATUS_STOP; - if (!m->pPlayback->Unprepare()) - _ERR(" playback unprepare failed"); +bool CMusicController::RemoveListener(IMusicControllerListener *listener) +{ + ASSERT(m); + ASSERT(listener); + + m->elListener = eina_list_remove(m->elListener, listener); return true; } @@ -522,175 +518,157 @@ bool CMusicController::GetSonginfoFromIndex(int index, CSongInfo **const csinfo) } -bool CMusicController::PlayNextSong(void) +bool CMusicController::SetPosition(int milseconds) { ASSERT(m); - return t_PlayNext(DIR_NEXT, E_BUTTON_CLICK); -} - + if (!m->pPlayback->FlagCreate()) + return false; -bool CMusicController::PlayPreviousSong(void) -{ - ASSERT(m); + if (!m->pPlayback->SetPosition(milseconds)) + return false; - return t_PlayNext(DIR_PREVIOUS, E_BUTTON_CLICK); + return true; } -bool CMusicController::PlayIndexSong(int index) +bool CMusicController::GetPosition(int *const milseconds) { ASSERT(m); - if (!m->pPlaylist->FlagCreate()) + if (!m->pPlayback->FlagCreate()) return false; - Stop(); - - if (!m->pPlaylist->SetCurSongIndex(index)) + if (!m->pPlayback->GetPosition(milseconds)) return false; - Start(); - return true; } -bool CMusicController::Resume(void) +bool CMusicController::SetCurrentSong(char *mediaid) { ASSERT(m); + ASSERT(mediaid); - if (!m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->Resume()) + if (!m->pPlaylist->FlagCreate()) return false; - m->statePlay = PLAY_STATUS_PLAY; + m->pPlaylist->SetCurrentSong(mediaid); return true; } -bool CMusicController::Pause(void) +bool CMusicController::GetCurrentSong(CSongInfo **const sinfo) { ASSERT(m); - if (!m || !m->pPlayback->FlagCreate()) + int index; + + if (!m->pPlaylist->FlagCreate()) return false; - if (!m->pPlayback->Pause()) + if (!m->pPlaylist->GetCurSongIndex(&index)) { + _ERR(" playlist get current song index failed"); return false; + } - m->statePlay = PLAY_STATUS_PAUSE; + if (!m->pPlaylist->GetSonginfoFromIndex(index, sinfo)) { + _ERR(" playlist get current song info failed"); + return false; + } return true; } -bool CMusicController::SetPosition(int milseconds) +bool CMusicController::UpdatePlaylist(Eina_List *slist, int addmode) { ASSERT(m); + ASSERT(slist); - if (!m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->SetPosition(milseconds)) - return false; - + if (m->pPlaylist->FlagCreate()) + m->pPlaylist->Update(slist, addmode); + else { + if (!m->pPlaylist->Create(slist)) + _ERR(" playlist create failed "); + } return true; } -bool CMusicController::GetPosition(int *const milseconds) +bool CMusicController::EmptyPlaylist(void) { ASSERT(m); - if (!m->pPlayback->FlagCreate()) + if (!m->pPlaylist->FlagCreate()) return false; - if (!m->pPlayback->GetPosition(milseconds)) - return false; + m->pPlaylist->Destroy(); return true; } -bool CMusicController::RemoveSong(CSongInfo *sinfo, int index) +bool CMusicController::PlayPreviousSong(void) { ASSERT(m); - ASSERT(sinfo); - - int ind; - - if (!m->pPlaylist->FlagCreate()) - return false; - if (!GetCurrentSongIndex(&ind)) { - _ERR("unable to find current song index"); - return false; - } + return t_PlayNext(DIR_PREVIOUS, E_BUTTON_CLICK); +} - if (!m->pPlaylist->RemoveSong(sinfo, index, m->stateShuffle)) { - _ERR("Song can not be deleted"); - return false; - } - if (ind != 0 && ind == index) - Stop(); +bool CMusicController::PlayNextSong(void) +{ + ASSERT(m); - return true; + return t_PlayNext(DIR_NEXT, E_BUTTON_CLICK); } -bool CMusicController::EmptyPlaylist(void) +bool CMusicController::PlayIndexSong(int index) { ASSERT(m); if (!m->pPlaylist->FlagCreate()) return false; - m->pPlaylist->Destroy(); + Stop(); + + if (!m->pPlaylist->SetCurSongIndex(index)) + return false; + + Start(); return true; } -bool CMusicController::GetCurrentSong(CSongInfo **const sinfo) +bool CMusicController::RemoveSong(CSongInfo *sinfo, int index) { ASSERT(m); + ASSERT(sinfo); - int index; + int ind; if (!m->pPlaylist->FlagCreate()) return false; - if (!m->pPlaylist->GetCurSongIndex(&index)) { - _ERR(" playlist get current song index failed"); + if (!GetCurrentSongIndex(&ind)) { + _ERR("unable to find current song index"); return false; } - if (!m->pPlaylist->GetSonginfoFromIndex(index, sinfo)) { - _ERR(" playlist get current song info failed"); + if (!m->pPlaylist->RemoveSong(sinfo, index, m->stateShuffle)) { + _ERR("Song can not be deleted"); return false; } - return true; -} - - -CSongInfo *CMusicController::MediaSongByUri(char *uri) -{ - ASSERT(m); - ASSERT(uri); - - CSongInfo *sinfo; - - sinfo = m->pMediadata->SongByUri(uri); - if (!sinfo) - return NULL; + if (ind != 0 && ind == index) + Stop(); - return sinfo; + return true; } @@ -791,17 +769,18 @@ bool CMusicController::MediaAddsongsPlaylist(int lid, Eina_List *list) } -bool CMusicController::SetCurrentSong(char *mediaid) +CSongInfo *CMusicController::MediaSongByUri(char *uri) { ASSERT(m); - ASSERT(mediaid); + ASSERT(uri); - if (!m->pPlaylist->FlagCreate()) - return false; + CSongInfo *sinfo; - m->pPlaylist->SetCurrentSong(mediaid); + sinfo = m->pMediadata->SongByUri(uri); + if (!sinfo) + return NULL; - return true; + return sinfo; } @@ -867,7 +846,7 @@ void CMusicController::OnConnect(void) return; Eina_List *l; - SCbInfo *cbinfo; + IMusicControllerListener *mcListener = NULL;; void *obj; if (CInfo::SourceType() == SOURCE_TYPE_USB) { @@ -876,8 +855,8 @@ void CMusicController::OnConnect(void) } EINA_LIST_FOREACH(m->elListener, l, obj) { - cbinfo = (SCbInfo *)obj; - if (cbinfo->type == E_USB_CONNECT && cbinfo->cb) - cbinfo->cb(cbinfo->data); + mcListener = (IMusicControllerListener *)obj; + if (mcListener) + mcListener->s_CbUsbConnected(mcListener); } } \ No newline at end of file diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index e8804d6..ccec9b2 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -1183,24 +1183,24 @@ void CMusicBaseView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) } -void CMusicBaseView::t_OnComplete(void) +void CMusicBaseView::OnComplete(void) { m_UpdatePlaysongLabel(); } -void CMusicBaseView::t_OnError(void) +void CMusicBaseView::OnError(void) { } -void CMusicBaseView::t_OnUsbConnected(void) +void CMusicBaseView::OnUsbConnected(void) { m->popup = m_CreateLoadingPopup(); } -void CMusicBaseView::t_OnUpdateContent(void) +void CMusicBaseView::OnUpdateContent(void) { int source; diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 510098f..aff7a1c 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -2134,23 +2134,23 @@ void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item) } -void CPlaybackView::t_OnComplete(void) +void CPlaybackView::OnComplete(void) { m_UpdateCurrentSongInfo(); } -void CPlaybackView::t_OnError(void) +void CPlaybackView::OnError(void) { m_CreateErrorPopup(); } -void CPlaybackView::t_OnUsbConnected(void) +void CPlaybackView::OnUsbConnected(void) { } -void CPlaybackView::t_OnUpdateContent(void) +void CPlaybackView::OnUpdateContent(void) { } -- 2.7.4 From 744d07ad0681de73aac69fae9b67405b582e0207 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 23 Mar 2015 16:27:13 +0900 Subject: [PATCH 04/16] Remove unnecessary function definition Change-Id: I98e0f3da7f376244c9a2330141fb8a5ffa952dd1 Signed-off-by: Kim Tae Soo --- include/playback-view.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/playback-view.h b/include/playback-view.h index 991e928..104f26a 100644 --- a/include/playback-view.h +++ b/include/playback-view.h @@ -38,7 +38,6 @@ private: static Eina_Bool sm_CbUpdateSlider(void *dt); static Eina_Bool sm_CbLongpressTimer(void *dt); static Eina_Bool sm_CbWaitTimer(void *dt); - static Eina_Bool sm_CbVolumeTimer(void *dt); static void sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info); @@ -65,8 +64,6 @@ private: void m_KeyNextUnpress(void); void m_KeyPreviousUnpress(void); - - void m_RemoveTimer(int timer_code); void m_PlaybackPause(void); void m_PlaybackResume(void); @@ -94,7 +91,6 @@ private: void m_HandleOnRepeated(void); void m_DeleteSelectedItems(void); - void m_AddSlider(void); void m_AddAlbumCover(void); void m_AddCurrentSonginfo(void); -- 2.7.4 From e192f7f7efdd742ed92e519fc54472825d23ac37 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 24 Mar 2015 11:13:30 +0900 Subject: [PATCH 05/16] Modify volume implementation. Change-Id: Ida9d65a70a7d4f5c8c661b3042d44c55989b3abf Signed-off-by: Kim Tae Soo --- src/playback/volume-control.cpp | 88 +++++++++++++++++++++++------------------ src/views/HandleVolume.cpp | 1 - 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/playback/volume-control.cpp b/src/playback/volume-control.cpp index 2f7da36..e45767f 100644 --- a/src/playback/volume-control.cpp +++ b/src/playback/volume-control.cpp @@ -21,8 +21,8 @@ #include "dbg.h" -#define VOLUME_MUTE 1 -#define VOLUME_UNMUTE 0 +#define VOLUME_MUTE 1 +#define VOLUME_UNMUTE 0 static int currentVolume = 0; static bool muteFlag = false; @@ -31,19 +31,21 @@ bool CVolumeController::Mute(void) { int r; - r = sound_manager_get_volume(SOUND_TYPE_MEDIA, ¤tVolume); - if (r != 0) { - _ERR("failed to get volume"); - return false; - } + if (muteFlag == false) { + r = sound_manager_get_volume(SOUND_TYPE_MEDIA, ¤tVolume); + if (r != 0) { + _ERR("failed to get volume"); + return false; + } - r = sound_manager_set_volume(SOUND_TYPE_MEDIA, 0); - if (r != 0) { - _ERR("failed to set volume"); - return false; - } + r = sound_manager_set_volume(SOUND_TYPE_MEDIA, 0); + if (r != 0) { + _ERR("failed to set volume"); + return false; + } - muteFlag = true; + muteFlag = true; + } return true; } @@ -52,23 +54,31 @@ bool CVolumeController::Unmute(void) { int r; - r = sound_manager_set_volume(SOUND_TYPE_MEDIA, currentVolume); - if (r != 0) { - _ERR("failed to set volume"); - return false; - } + if (muteFlag == true) { + r = sound_manager_set_volume(SOUND_TYPE_MEDIA, currentVolume); + if (r != 0) { + _ERR("failed to set volume"); + return false; + } - muteFlag = false; + muteFlag = false; + } return true; } bool CVolumeController::Up(void) { - int r, vol; + int r, vol, maxVol; if (!CVolumeController::Unmute()) { - _ERR("failed to set volume unmute"); + _ERR("failed to unmute"); + return false; + } + + r = sound_manager_get_max_volume(SOUND_TYPE_MEDIA, &maxVol); + if (r != 0) { + _ERR("failed to get max volume"); return false; } @@ -79,6 +89,8 @@ bool CVolumeController::Up(void) } vol++; + if (vol > maxVol) + vol = maxVol; r = sound_manager_set_volume(SOUND_TYPE_MEDIA, vol); if (r != 0) { @@ -86,6 +98,8 @@ bool CVolumeController::Up(void) return false; } + currentVolume = vol; + return true; } @@ -94,7 +108,7 @@ bool CVolumeController::Down(void) int r, vol; if (!CVolumeController::Unmute()) { - _ERR("failed to set volume unmute"); + _ERR("failed to unmute"); return false; } @@ -103,7 +117,10 @@ bool CVolumeController::Down(void) _ERR("failed to get volume"); return false; } + vol--; + if (vol < 0) + vol = 0; r = sound_manager_set_volume(SOUND_TYPE_MEDIA, vol); if (r != 0) { @@ -111,24 +128,13 @@ bool CVolumeController::Down(void) return false; } + currentVolume = vol; + return true; } bool CVolumeController::IsMute(void) { - /*int r; - bool mute; - - r = sound_manager_get_master_mute(&mute); - if (r != 0) { - _ERR("failed to get mute"); - return false; - } - - if (mute) - return true; - - return false;*/ return muteFlag; } @@ -136,11 +142,15 @@ bool CVolumeController::Get(int *vol) { int r; - r = sound_manager_get_volume(SOUND_TYPE_MEDIA, vol); - if (r != 0) { - _ERR("failed to get volume"); - return false; + if (muteFlag == false) { + r = sound_manager_get_volume(SOUND_TYPE_MEDIA, vol); + if (r != 0) { + _ERR("failed to get volume"); + return false; + } } + else + *vol = currentVolume; return true; } diff --git a/src/views/HandleVolume.cpp b/src/views/HandleVolume.cpp index 8db38e3..10c4911 100644 --- a/src/views/HandleVolume.cpp +++ b/src/views/HandleVolume.cpp @@ -66,7 +66,6 @@ void CHandleVolume::m_HandleVolumeKey(int mode) m->etVol = ecore_timer_add(VOLUME_TIMER_INTERVAL, sm_CbVolumeTimer, m); m->flagVolumeMode = true; - evas_object_show(m->eoVolLayout); elm_object_part_content_set(m->eoBase, MUSIC_PART_VOLUME_LAYOUT, m->eoVolLayout); evas_object_show(m->eoVolLayout); -- 2.7.4 From a5a26419b7a9ae8e3577239d6c1e9da9c3ef7056 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 24 Mar 2015 11:25:22 +0900 Subject: [PATCH 06/16] Modify to destroy ctxpopup when already selected item is selected again. Change-Id: Ic06eb1ffad6adf6929dbb569f3f95afa6b92bf16 Signed-off-by: Kim Tae Soo --- src/views/PlayListCtxPopup.cpp | 1 - src/views/SortCtxPopup.cpp | 8 +++++--- src/views/SourceCtxPopup.cpp | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/views/PlayListCtxPopup.cpp b/src/views/PlayListCtxPopup.cpp index 9146082..123c989 100644 --- a/src/views/PlayListCtxPopup.cpp +++ b/src/views/PlayListCtxPopup.cpp @@ -70,7 +70,6 @@ void CPlayListCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev) return; CInfo::SetPlayListDbId(m->dbIds[index]); - CCtxPopup::t_OnBtnClicked(obj, ev); Destroy(); diff --git a/src/views/SortCtxPopup.cpp b/src/views/SortCtxPopup.cpp index d72cfd3..8706d59 100644 --- a/src/views/SortCtxPopup.cpp +++ b/src/views/SortCtxPopup.cpp @@ -129,11 +129,13 @@ void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev) } } - if (index == -1 || index == CInfo::SortType()) + if (index == -1) return; - CInfo::SetSortType(index); - CCtxPopup::t_OnBtnClicked(obj, ev); + if (index != CInfo::SortType()) { + CInfo::SetSortType(index); + CCtxPopup::t_OnBtnClicked(obj, ev); + } Destroy(); } diff --git a/src/views/SourceCtxPopup.cpp b/src/views/SourceCtxPopup.cpp index e6cadaa..11eba8d 100644 --- a/src/views/SourceCtxPopup.cpp +++ b/src/views/SourceCtxPopup.cpp @@ -71,11 +71,13 @@ void CSourceCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev) break; } } - if (index == -1 || index == CInfo::SourceType()) + if (index == -1) return; - CInfo::SetSourceType(index); - CCtxPopup::t_OnBtnClicked(obj, ev); + if (index != CInfo::SourceType()) { + CInfo::SetSourceType(index); + CCtxPopup::t_OnBtnClicked(obj, ev); + } Destroy(); } -- 2.7.4 From 5583b2a5d86cf06cd78a6bcecf4825c1a61b6a06 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 24 Mar 2015 19:06:54 +0900 Subject: [PATCH 07/16] Add temp key name macro Change-Id: Ic8696183594dab06cbd2d0286efcd980ae75e446 Signed-off-by: Kim Tae Soo --- include/define.h | 39 ++++++++++++++++++++++----------------- src/views/base-view.cpp | 6 ++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/include/define.h b/include/define.h index 4b9ce75..ac1b648 100644 --- a/include/define.h +++ b/include/define.h @@ -429,6 +429,14 @@ #define POSITION_PLAY_LIST_POPUP_Y 190 /* TEMP KEY DEFINITION */ +#undef KEY_UP +#define KEY_UP "Up" +#undef KEY_DOWN +#define KEY_DOWN "Down" +#undef KEY_LEFT +#define KEY_LEFT "Left" +#undef KEY_RIGHT +#define KEY_RIGHT "Right" #undef KEY_VOLUMEUP #define KEY_VOLUMEUP "F9" #undef KEY_VOLUMEDOWN @@ -439,34 +447,31 @@ #define KEY_BACK "Escape" #undef KEY_MENU #define KEY_MENU "Super_L" +#undef KEY_VOLUMEUP_REMOTE +#define KEY_VOLUMEUP_REMOTE "XF86AudioRaiseVolume" +#undef KEY_VOLUMEDOWN_REMOTE +#define KEY_VOLUMEDOWN_REMOTE "XF86AudioLowerVolume" #undef KEY_ENTER_REMOTE #define KEY_ENTER_REMOTE "KP_Enter" #undef KEY_BACK_REMOTE #define KEY_BACK_REMOTE "XF86Close" #undef KEY_MENU_REMOTE #define KEY_MENU_REMOTE "XF86Send" -#undef KEY_UP -#define KEY_UP "Up" -#undef KEY_DOWN -#define KEY_DOWN "Down" -#undef KEY_LEFT -#define KEY_LEFT "Left" -#undef KEY_RIGHT -#define KEY_RIGHT "Right" - -/* SHOULD BE DEFINED */ #undef KEY_PLAY -#define KEY_PLAY "Play" +#define KEY_PLAY "XF86AudioPlay" +#undef KEY_PAUSE +#define KEY_PAUSE "Pause" #undef KEY_NEXT -#define KEY_NEXT "Next" +#define KEY_NEXT "XF86AudioNext" #undef KEY_PREVIOUS -#define KEY_PREVIOUS "Previous" +#define KEY_PREVIOUS "XF86AudioPrev" +#undef KEY_MUTE +#define KEY_MUTE "XF86AudioMute" + +/* SHOULD BE DEFINED */ #undef KEY_EXIT #define KEY_EXIT "Exit" -#undef KEY_MUTE -#define KEY_MUTE "Mute" -#undef KEY_PAUSE -#define KEY_PAUSE "Pause" + /* SORTING ID */ #define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ" diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index ccec9b2..93ff5fb 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -975,9 +975,11 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key m_UpdateCurrentLayout(true); } } - else if (!strcmp(ev->keyname, KEY_VOLUMEUP)) + else if (!strcmp(ev->keyname, KEY_VOLUMEUP) || + !strcmp(ev->keyname, KEY_VOLUMEUP_REMOTE)) m->pHandleVolume->Up(); - else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) + else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN) || + !strcmp(ev->keyname, KEY_VOLUMEDOWN_REMOTE)) m->pHandleVolume->Down(); else if (!strcmp(ev->keyname, KEY_MUTE)) m->pHandleVolume->Mute(); -- 2.7.4 From 3c7059b0d6e39574a78a741cc6daa7ac2e75fd9a Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 08:12:17 +0900 Subject: [PATCH 08/16] Remove unused function. Change-Id: I51017df2b1010d9e62eeacf1a4105012bb4e9d26 Signed-off-by: Kim Tae Soo --- include/music-controller.h | 1 - src/playback/music-controller.cpp | 22 ++-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/include/music-controller.h b/include/music-controller.h index 4accf5c..153d51e 100644 --- a/include/music-controller.h +++ b/include/music-controller.h @@ -86,7 +86,6 @@ public: bool RemoveListener(IMusicControllerListener *listener); bool GetCurrentSongIndex(int *ind); - bool SetCurrentSongIndex(int ind); bool GetTotalSongs(int *ts); bool GetSonginfoFromIndex(int index, CSongInfo **const csinfo); diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index d521f1a..e7851c5 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -458,26 +458,6 @@ bool CMusicController::GetCurrentSongIndex(int *ind) } -bool CMusicController::SetCurrentSongIndex(int index) -{ - ASSERT(m); - - if (!m->pPlaylist->FlagCreate()) { - _ERR("NULL received"); - return false; - } - - if (!m->pPlaylist->SetCurSongIndex(index)) { - _ERR(" playlist get current song index failed"); - return false; - } - - m->initial_index = index; - - return true; -} - - bool CMusicController::GetTotalSongs(int *ts) { ASSERT(m); @@ -641,6 +621,8 @@ bool CMusicController::PlayIndexSong(int index) Start(); + m->initial_index = index; + return true; } -- 2.7.4 From cb748e50663f0ba5aac629c8c078c67e9e008b47 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 10:10:19 +0900 Subject: [PATCH 09/16] Fix Bug: When a song is removed from the list of playback view, playback view should be updated Change-Id: If562c80f8ba6bfb96d59fea709db08eb57311c2b Signed-off-by: Kim Tae Soo --- src/main.cpp | 3 ++- src/views/playback-view.cpp | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a98f343..28fcf8f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,7 +69,8 @@ private: static void sm_CbPopView(void* cookie, const char *szDestroyViewId, CBaseView *pShowView) { const char *viewId = pShowView->ViewId(); - if (!strcmp(viewId, MUSIC_CONTEXT_VIEW)) + if (!strcmp(viewId, MUSIC_CONTEXT_VIEW) || + !strcmp(viewId, MUSIC_PLAYBACK_VIEW)) CViewMgr::GetInstance()->UpdateView(viewId, NULL); } diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index aff7a1c..aba56e8 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -266,6 +266,7 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) { SPlaybackView *m = (SPlaybackView *)dt; SItemInfo *itinfo = NULL; + Elm_Object_Item *focucedItem = NULL; if (!m) return; @@ -283,8 +284,15 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) if (type == ACTION_TYPE_DELETE) { itinfo->check_status = true; m->parent->m_DeleteSelectedItems(); + + if (!m->mgr->PopView()) { + _ERR("CViewMgr::PopView failed"); + return; + } + + focucedItem = m->cs_itinfo->item; } - else if (type == ACTION_TYPE_PLAY) { + else { // ACTION_TYPE_PLAY if (m->ctxtinfo->status == PLAY_STATUS_PLAY) m->parent->m_KeyPausePress(); else { @@ -293,18 +301,16 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) else m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item); } - } - else { - _ERR(" Wrong ctxt add type in plaback view "); - ASSERT(0); - } - if (!m->mgr->PopView()) { - _ERR("CViewMgr::PopView failed"); - return; + if (!m->mgr->PopView()) { + _ERR("CViewMgr::PopView failed"); + return; + } + + focucedItem = m->focused_item; } - elm_object_item_focus_set(m->focused_item, EINA_TRUE); + elm_object_item_focus_set(focucedItem, EINA_TRUE); } @@ -1799,12 +1805,15 @@ void CPlaybackView::t_OnUpdate(void *data) { ASSERT(m); - if (!data) - return; + SParcel *parcel; + int updateType; - SParcel *parcel = (SParcel *)data; - int updateType = parcel->updateType; - char *key = (char *)parcel->keyEvent; + if (!data) + updateType = E_PLAYLIST_UPDATE; + else { + parcel = (SParcel *)data; + updateType = parcel->updateType; + } switch (updateType) { case E_PLAYLIST_UPDATE: @@ -1819,11 +1828,11 @@ void CPlaybackView::t_OnUpdate(void *data) break; case E_KEY_PRESS: - m_HandleKeyPress(key); + m_HandleKeyPress((char *)parcel->keyEvent); break; case E_KEY_RELEASE: - m_HandleKeyUnpress(key); + m_HandleKeyUnpress((char *)parcel->keyEvent); break; default: -- 2.7.4 From 96ba3a3858e2855ae6096c5b934b9dae9a5e2f88 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 14:57:25 +0900 Subject: [PATCH 10/16] Rearrangement of source code Change-Id: I502050b3119f081a7090e05788e6e1284197526d Signed-off-by: Kim Tae Soo --- src/playback/music-controller.cpp | 113 ++++++++++++++++++-------------------- src/playback/volume-control.cpp | 35 +++++++----- src/views/playback-view.cpp | 11 ++-- 3 files changed, 82 insertions(+), 77 deletions(-) diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index e7851c5..194f835 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -47,18 +47,6 @@ struct SMusicController { ERepeatStatus repeatstate; SCbInfo *cbinfo; - - SMusicController() { - memset(this, 0, sizeof(SMusicController)); - pPlayback = new CPlayback; - pPlaylist = new CPlaylist; - pMediadata = new CMediadata; - } - ~SMusicController() { - delete pMediadata; - delete pPlaylist; - delete pPlayback; - } }; @@ -217,29 +205,41 @@ SMusicController *CMusicController::t_Create(void) _CREATE_BEGIN { _CHECK(mhandle = new SMusicController) - _CHECK(mhandle->alinfo = new CAlbumInfo) - _CHECK(mhandle->alinfo->Create() == true) - _CHECK(mhandle->pMediadata->Create() == true) - _CHECK(mhandle->pPlayback->Create() == true) - _CHECK(mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this) == true) - _CHECK(CUsbConnectionListener::Create() == true) _WHEN_SUCCESS{ - mhandle->statePlay = PLAY_STATUS_INITIAL; - mhandle->stateShuffle = SHUFFLE_STATUS_OFF; - mhandle->repeatstate = REPEAT_STATUS_ALL; - mhandle->initial_index = 0; - CInfo::SetSortType(E_SORT_TITLE_A_Z); - CInfo::SetSourceType(SOURCE_TYPE_ALL); - mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, sm_CbContentUpdated, this); + memset(mhandle, 0, sizeof(SMusicController)); + + _CHECK(mhandle->alinfo = new CAlbumInfo) + _CHECK(mhandle->alinfo->Create() == true) + _CHECK(mhandle->pMediadata = new CMediadata) + _CHECK(mhandle->pMediadata->Create() == true) + _CHECK(mhandle->pPlayback = new CPlayback) + _CHECK(mhandle->pPlayback->Create() == true) + _CHECK(mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this) == true) + _CHECK(mhandle->pPlaylist = new CPlaylist) + _CHECK(CUsbConnectionListener::Create() == true) + + _WHEN_SUCCESS{ + mhandle->statePlay = PLAY_STATUS_INITIAL; + mhandle->stateShuffle = SHUFFLE_STATUS_OFF; + mhandle->repeatstate = REPEAT_STATUS_ALL; + mhandle->initial_index = 0; + CInfo::SetSortType(E_SORT_TITLE_A_Z); + CInfo::SetSourceType(SOURCE_TYPE_ALL); + mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, sm_CbContentUpdated, this); + } + + _CHECK_FAIL{ CUsbConnectionListener::Destroy(); } + _CHECK_FAIL{ delete mhandle->pPlaylist; } + _CHECK_FAIL{} + _CHECK_FAIL{ mhandle->pPlayback->Destroy(); } + _CHECK_FAIL{ delete mhandle->pPlayback; } + _CHECK_FAIL{ mhandle->pMediadata->Destroy(); } + _CHECK_FAIL{ delete mhandle->pMediadata; } + _CHECK_FAIL{ mhandle->alinfo->Destroy(); } + _CHECK_FAIL{ delete mhandle->alinfo; } } - _CHECK_FAIL{ CUsbConnectionListener::Destroy(); } - _CHECK_FAIL{} - _CHECK_FAIL{ mhandle->pPlayback->Destroy(); } - _CHECK_FAIL{ mhandle->pMediadata->Destroy(); } - _CHECK_FAIL{ mhandle->alinfo->Destroy(); } - _CHECK_FAIL{ delete mhandle->alinfo; } _CHECK_FAIL{ delete mhandle; mhandle = NULL; } } _CREATE_END_AND_CATCH{ return NULL; } @@ -251,12 +251,10 @@ void CMusicController::t_Destroy(void) { CUsbConnectionListener::Destroy(); - if (m->pPlayback->FlagCreate()) { - if (!m->pPlayback->UnsetCallback()) - _ERR(" playback remove completion callback failed"); + if (!m->pPlayback->UnsetCallback()) + _ERR(" playback remove completion callback failed"); - m->pPlayback->Destroy(); - } + m->pPlayback->Destroy(); if (m->pPlaylist->FlagCreate()) { m->pPlaylist->Destroy(); @@ -328,7 +326,7 @@ bool CMusicController::Start(void) pPlayback = m->pPlayback; _CREATE_BEGIN{ - _CHECK(pPlaylist && pPlayback) + _CHECK(pPlaylist->FlagCreate()) _CHECK(pPlaylist->GetCurSongIndex(&index)) _CHECK(songpath = pPlaylist->SongpathFromIndex(index)) _CHECK(pPlayback->SetUri(songpath)) @@ -367,16 +365,17 @@ bool CMusicController::Stop(void) { ASSERT(m); - if (!m->pPlayback->FlagCreate()) + if (!m->pPlayback->Stop()) { + _ERR("playback stop failed"); return false; - - if (!m->pPlayback->Stop()) - _ERR(" playback stop failed "); + } m->statePlay = PLAY_STATUS_STOP; - if (!m->pPlayback->Unprepare()) - _ERR(" playback unprepare failed"); + if (!m->pPlayback->Unprepare()) { + _ERR("playback unprepare failed"); + return false; + } return true; } @@ -386,11 +385,10 @@ bool CMusicController::Resume(void) { ASSERT(m); - if (!m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->Resume()) + if (!m->pPlayback->Resume()) { + _ERR("playback resume failed"); return false; + } m->statePlay = PLAY_STATUS_PLAY; @@ -402,11 +400,10 @@ bool CMusicController::Pause(void) { ASSERT(m); - if (!m || !m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->Pause()) + if (!m->pPlayback->Pause()) { + _ERR("playback Pause failed"); return false; + } m->statePlay = PLAY_STATUS_PAUSE; @@ -502,11 +499,10 @@ bool CMusicController::SetPosition(int milseconds) { ASSERT(m); - if (!m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->SetPosition(milseconds)) + if (!m->pPlayback->SetPosition(milseconds)) { + _ERR("playback set position failed"); return false; + } return true; } @@ -516,11 +512,10 @@ bool CMusicController::GetPosition(int *const milseconds) { ASSERT(m); - if (!m->pPlayback->FlagCreate()) - return false; - - if (!m->pPlayback->GetPosition(milseconds)) + if (!m->pPlayback->GetPosition(milseconds)) { + _ERR("playback get position failed"); return false; + } return true; } diff --git a/src/playback/volume-control.cpp b/src/playback/volume-control.cpp index e45767f..339f4b8 100644 --- a/src/playback/volume-control.cpp +++ b/src/playback/volume-control.cpp @@ -24,15 +24,24 @@ #define VOLUME_MUTE 1 #define VOLUME_UNMUTE 0 -static int currentVolume = 0; -static bool muteFlag = false; +struct SVolumeController { + int currentVolume; + bool flagMute; + + SVolumeController() { + currentVolume = 0; + flagMute = false; + } + ~SVolumeController() {} +}; +static SVolumeController sM; bool CVolumeController::Mute(void) { int r; - if (muteFlag == false) { - r = sound_manager_get_volume(SOUND_TYPE_MEDIA, ¤tVolume); + if (sM.flagMute == false) { + r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &sM.currentVolume); if (r != 0) { _ERR("failed to get volume"); return false; @@ -44,7 +53,7 @@ bool CVolumeController::Mute(void) return false; } - muteFlag = true; + sM.flagMute = true; } return true; @@ -54,14 +63,14 @@ bool CVolumeController::Unmute(void) { int r; - if (muteFlag == true) { - r = sound_manager_set_volume(SOUND_TYPE_MEDIA, currentVolume); + if (sM.flagMute == true) { + r = sound_manager_set_volume(SOUND_TYPE_MEDIA, sM.currentVolume); if (r != 0) { _ERR("failed to set volume"); return false; } - muteFlag = false; + sM.flagMute = false; } return true; @@ -98,7 +107,7 @@ bool CVolumeController::Up(void) return false; } - currentVolume = vol; + sM.currentVolume = vol; return true; } @@ -128,21 +137,21 @@ bool CVolumeController::Down(void) return false; } - currentVolume = vol; + sM.currentVolume = vol; return true; } bool CVolumeController::IsMute(void) { - return muteFlag; + return sM.flagMute; } bool CVolumeController::Get(int *vol) { int r; - if (muteFlag == false) { + if (sM.flagMute == false) { r = sound_manager_get_volume(SOUND_TYPE_MEDIA, vol); if (r != 0) { _ERR("failed to get volume"); @@ -150,7 +159,7 @@ bool CVolumeController::Get(int *vol) } } else - *vol = currentVolume; + *vol = sM.currentVolume; return true; } diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index aba56e8..bf30235 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -1805,14 +1805,15 @@ void CPlaybackView::t_OnUpdate(void *data) { ASSERT(m); - SParcel *parcel; + SParcel *parcel = (SParcel *)data; int updateType; + char *keyEvent = NULL; - if (!data) + if (!parcel) updateType = E_PLAYLIST_UPDATE; else { - parcel = (SParcel *)data; updateType = parcel->updateType; + keyEvent = (char *)parcel->keyEvent; } switch (updateType) { @@ -1828,11 +1829,11 @@ void CPlaybackView::t_OnUpdate(void *data) break; case E_KEY_PRESS: - m_HandleKeyPress((char *)parcel->keyEvent); + m_HandleKeyPress(keyEvent); break; case E_KEY_RELEASE: - m_HandleKeyUnpress((char *)parcel->keyEvent); + m_HandleKeyUnpress(keyEvent); break; default: -- 2.7.4 From 5a62b00e6d87164999510a5bb917aa1f879cf1ba Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 15:05:33 +0900 Subject: [PATCH 11/16] Remove unused functions Change-Id: Ia6741a870ae837651abaee453c77c8dba518e0db Signed-off-by: Kim Tae Soo --- include/playback-mgr.h | 3 --- src/playback/playback-mgr.cpp | 30 ------------------------------ 2 files changed, 33 deletions(-) diff --git a/include/playback-mgr.h b/include/playback-mgr.h index 4e37b71..3edb5c8 100644 --- a/include/playback-mgr.h +++ b/include/playback-mgr.h @@ -37,9 +37,6 @@ public: bool SetCallback(player_completed_cb cbPlaybackCompletion, void *data); bool UnsetCallback(void); - bool SetMute(bool flag); - bool SetLooping(bool flag); - bool Start(void); bool Stop(void); diff --git a/src/playback/playback-mgr.cpp b/src/playback/playback-mgr.cpp index d87c8bf..3906bf3 100644 --- a/src/playback/playback-mgr.cpp +++ b/src/playback/playback-mgr.cpp @@ -139,36 +139,6 @@ bool CPlayback::UnsetCallback(void) } -bool CPlayback::SetMute(bool flag) -{ - ASSERT(m); - ASSERT(m->player); - - int r = player_set_mute(m->player, flag); - if (r != PLAYER_ERROR_NONE) { - _ERR("Player set mute failed"); - return false; - } - - return true; -} - - -bool CPlayback::SetLooping(bool flag) -{ - ASSERT(m); - ASSERT(m->player); - - int r = player_set_looping(m->player, flag); - if (r != PLAYER_ERROR_NONE) { - _ERR("Player set looping failed"); - return false; - } - - return true; -} - - bool CPlayback::Resume(void) { ASSERT(m); -- 2.7.4 From ab0ca3a14761862012156334ca619abb6b644bb9 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 16:01:00 +0900 Subject: [PATCH 12/16] Refactoring of callback mechanism / Modification focus of playback view Change-Id: I06d3fbb09647428848585e75070af89f368b1ac2 Signed-off-by: Kim Tae Soo --- include/playback-view.h | 7 ++++ src/main.cpp | 3 +- src/views/playback-view.cpp | 93 ++++++++++++++++++++++++++++----------------- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/include/playback-view.h b/include/playback-view.h index 104f26a..7d4c0b8 100644 --- a/include/playback-view.h +++ b/include/playback-view.h @@ -36,8 +36,12 @@ private: private: static Eina_Bool sm_CbUpdateSlider(void *dt); + static Eina_Bool sm_CbLongpressTimer(void *dt); + void m_OnLongpressTimer(void); + static Eina_Bool sm_CbWaitTimer(void *dt); + void m_OnWaitTimer(void); static void sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info); @@ -45,7 +49,10 @@ private: void m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source); static void sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid); + void m_OnCtxtUpdate(EActionType type, int lid); + static void sm_CbCtxtClose(void *dt); + void m_OnCtxtClose(void); static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text); void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text); diff --git a/src/main.cpp b/src/main.cpp index 28fcf8f..a98f343 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,8 +69,7 @@ private: static void sm_CbPopView(void* cookie, const char *szDestroyViewId, CBaseView *pShowView) { const char *viewId = pShowView->ViewId(); - if (!strcmp(viewId, MUSIC_CONTEXT_VIEW) || - !strcmp(viewId, MUSIC_PLAYBACK_VIEW)) + if (!strcmp(viewId, MUSIC_CONTEXT_VIEW)) CViewMgr::GetInstance()->UpdateView(viewId, NULL); } diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index bf30235..35f1642 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -112,7 +112,6 @@ struct SPlaybackView { SContentInfo *ctxtinfo; int press_status; - CPlaybackView *parent; CHandleVolume *pHandleVolume; SPlaybackView() { @@ -202,30 +201,43 @@ Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt) Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt) { - SPlaybackView *m = (SPlaybackView *)dt; - - m->parent->m_HandleOnRepeated(); + CPlaybackView *root = (CPlaybackView *)dt; + if (root) + root->m_OnLongpressTimer(); return ECORE_CALLBACK_RENEW; } +void CPlaybackView::m_OnLongpressTimer(void) +{ + m_HandleOnRepeated(); +} + + Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt) { - SPlaybackView *m = (SPlaybackView *)dt; + CPlaybackView *root = (CPlaybackView *)dt; + if (root) + root->m_OnWaitTimer(); + + return ECORE_CALLBACK_CANCEL; +} + +void CPlaybackView::m_OnWaitTimer(void) +{ m->press_status = PRESS_LONG; if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) { /* Handle long press */ - m->parent->m_PlaybackPause(); - m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, m); + m_PlaybackPause(); + m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this); } else { m->press_status = PRESS_LONG_PAUSE; } m->etWait = NULL; - return ECORE_CALLBACK_CANCEL; } @@ -264,17 +276,21 @@ void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) { - SPlaybackView *m = (SPlaybackView *)dt; - SItemInfo *itinfo = NULL; - Elm_Object_Item *focucedItem = NULL; + CPlaybackView *root = (CPlaybackView *)dt; + if (root) + root->m_OnCtxtUpdate(type, lid); +} - if (!m) - return; + +void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid) +{ + SItemInfo *itinfo = NULL; + Elm_Object_Item *focusedItem = NULL; if (!m->ctxtinfo || !m->ctxtinfo->context) return; - itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo, + itinfo = m_FindItemInfoFromSong(m->elInfo, (CSongInfo *)m->ctxtinfo->context); if (!itinfo) { _ERR(" Unable to find song in the list "); @@ -283,23 +299,28 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) if (type == ACTION_TYPE_DELETE) { itinfo->check_status = true; - m->parent->m_DeleteSelectedItems(); + m_DeleteSelectedItems(); if (!m->mgr->PopView()) { _ERR("CViewMgr::PopView failed"); return; } - focucedItem = m->cs_itinfo->item; + SParcel parcel; + memset(&parcel, 0, sizeof(SParcel)); + parcel.updateType = E_PLAYLIST_UPDATE; + t_OnUpdate(&parcel); + + focusedItem = m->cs_itinfo->item; } else { // ACTION_TYPE_PLAY if (m->ctxtinfo->status == PLAY_STATUS_PLAY) - m->parent->m_KeyPausePress(); + m_KeyPausePress(); else { if (itinfo == m->cs_itinfo) - m->parent->m_KeyPlayPress(); + m_KeyPlayPress(); else - m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item); + m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item); } if (!m->mgr->PopView()) { @@ -307,20 +328,26 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) return; } - focucedItem = m->focused_item; + focusedItem = m->focused_item; } - elm_object_item_focus_set(focucedItem, EINA_TRUE); + if (focusedItem) { + elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN); + elm_object_item_focus_set(focusedItem, EINA_TRUE); + } } void CPlaybackView::sm_CbCtxtClose(void *dt) { - SPlaybackView *m = (SPlaybackView *)dt; + CPlaybackView *root = (CPlaybackView *)dt; + if (root) + root->m_OnCtxtClose(); +} - if (!m) - return; +void CPlaybackView::m_OnCtxtClose(void) +{ if (!m->mgr->PopView()) { _ERR("CViewMgr::PopView failed"); return; @@ -1564,7 +1591,7 @@ void CPlaybackView::m_HandleOnPressed(Evas_Object *obj) m->press_status = PRESS_SHORT; m->eoPressedObj = obj; - m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m); + m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this); } @@ -1637,8 +1664,6 @@ bool CPlaybackView::Create(void *data) _WHEN_SUCCESS{ m->press_status = PRESS_SHORT; - m->parent = this; - evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m); m_AddControlButtons(); @@ -1783,12 +1808,6 @@ void CPlaybackView::t_OnShow(void) m_UpdateCurrentSongInfo(); - if (m->cs_itinfo) { - elm_genlist_item_show(m->cs_itinfo->item, - ELM_GENLIST_ITEM_SCROLLTO_IN); - elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE); - } - state = m->hMusicController->PlayState(); if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) { m_RemovePlaylist(); @@ -1797,6 +1816,12 @@ void CPlaybackView::t_OnShow(void) m_UpdateCurrentSongInfo(); } + if (m->cs_itinfo) { + elm_genlist_item_show(m->cs_itinfo->item, + ELM_GENLIST_ITEM_SCROLLTO_IN); + elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE); + } + evas_object_show(m->eoBase); } @@ -1903,7 +1928,7 @@ void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ else ctxtinfo->status = PLAY_STATUS_PAUSE; - ctxtinfo->cbdata = m; + ctxtinfo->cbdata = this; ctxtinfo->update = sm_CbCtxtUpdate; ctxtinfo->close = sm_CbCtxtClose; ctxtinfo->type = CONTEXT_TYPE_PLAYSONG; -- 2.7.4 From 3c2e63b80b2fbf5416269ed63e90065ba00cf347 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Mar 2015 17:28:44 +0900 Subject: [PATCH 13/16] Fix genlist issue of playback view Change-Id: If2f292015e6200cfcc0c13d601e84ac95d6fedec Signed-off-by: Kim Tae Soo --- src/views/playback-view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 35f1642..90f9921 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -1342,7 +1342,7 @@ public: if (!strcmp(part, "elm.text0")) { index = elm_genlist_item_index_get(pItemInfo->item); - snprintf(buf, sizeof(buf), "%d", index); + snprintf(buf, sizeof(buf), "%d", index + 1); if ((index & 1) == 1) { elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW); @@ -1644,7 +1644,7 @@ void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_It index = elm_genlist_item_index_get(genListItem); - m->hMusicController->PlayIndexSong(--index); + m->hMusicController->PlayIndexSong(index); m_UpdateCurrentSongInfo(); } -- 2.7.4 From fb4629dd12eb7695826e87c49dad904020b477c7 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Fri, 27 Mar 2015 08:09:04 +0900 Subject: [PATCH 14/16] Fix genlist issue again: According to the EFL specs, the index of genlist starts with 1. Change-Id: I95d3c0ab2a9d96ae3f278db2d135e35d1938ae35 Signed-off-by: Kim Tae Soo --- src/views/playback-view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 90f9921..35f1642 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -1342,7 +1342,7 @@ public: if (!strcmp(part, "elm.text0")) { index = elm_genlist_item_index_get(pItemInfo->item); - snprintf(buf, sizeof(buf), "%d", index + 1); + snprintf(buf, sizeof(buf), "%d", index); if ((index & 1) == 1) { elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW); @@ -1644,7 +1644,7 @@ void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_It index = elm_genlist_item_index_get(genListItem); - m->hMusicController->PlayIndexSong(index); + m->hMusicController->PlayIndexSong(--index); m_UpdateCurrentSongInfo(); } -- 2.7.4 From 6ed95df88f4afbb47574475aa457dad50fb26f04 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Fri, 27 Mar 2015 10:02:01 +0900 Subject: [PATCH 15/16] Modification focus sequence: When layout changed from "category song layout" to "category layout" chosen item should be focused. Change-Id: Ibc33632850e3cd2dfe345483fbd5811eb15a7e10 Signed-off-by: Kim Tae Soo --- include/category-songs-layout.h | 3 +++ src/views/category-layout.cpp | 16 +++++++++++++++ src/views/category-songs-layout.cpp | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/include/category-songs-layout.h b/include/category-songs-layout.h index 4dc1fda..863c4f5 100644 --- a/include/category-songs-layout.h +++ b/include/category-songs-layout.h @@ -102,6 +102,9 @@ public: void SetParameter(EDepth depth, ESelectType selType, CCategoryInfo *catInfo, CAlbumInfo *albumInfo); Eina_List *CategorySongItemInfoList(void); + void SetCurrentCategory(CCategoryInfo *curCatInfo); + CCategoryInfo *CurrentCategory(void); + virtual void SetFocus(const char *btnStr); public: diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 039e6de..b208815 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -544,6 +544,8 @@ void CCategoryLayout::m_OnItemSelect(Elm_Object_Item *it, const char *emission, t.c_catinfo = NULL; t_HandleItemSelect(itinfo); + + m->layoutCatSongs->SetCurrentCategory(t.c_catinfo); } t_UpdateLayoutWithFocus(); @@ -1243,6 +1245,9 @@ void CCategoryLayout::Update(bool focusFlag) { ASSERT(m); + CCategoryInfo *catInfo; + Elm_Object_Item *item; + if (!focusFlag) { if (t.depth != E_DEPTH_CATEGORY) return; @@ -1250,6 +1255,17 @@ void CCategoryLayout::Update(bool focusFlag) return; } + catInfo = m->layoutCatSongs->CurrentCategory(); + if (catInfo && catInfo->FlagCreate()) { + item = m_FindItemByInfo(m->it_infolist, catInfo); + if (item) { + m->layoutCatSongs->SetCurrentCategory(NULL); + elm_gengrid_item_show(item, ELM_GENGRID_ITEM_SCROLLTO_IN); + elm_object_item_focus_set(item, EINA_TRUE); + return; + } + } + elm_object_focus_set(t.grid, EINA_TRUE); } diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index 074684a..c2891d4 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -104,6 +104,8 @@ struct SCategorySongsLayout { const char *focusBtnStr; EFocusIderType idlerType; + CCategoryInfo *curCatInfo; + SCategorySongsLayout() { memset(this, 0, sizeof(SCategorySongsLayout)); } @@ -896,6 +898,7 @@ bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent) Evas_Object *layout = NULL; CMusicController *mhandle = NULL; CViewMgr *vmgr = NULL; + CCategoryInfo *catInfo = NULL; _CHECK(m = new SCategorySongsLayout) _CHECK(vmgr = CViewMgr::GetInstance()) @@ -904,6 +907,7 @@ bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent) _CHECK(mhandle = CMusicController::GetInstance()) _CHECK(layout = CCommonUI::AddBase(base, MUSIC_CATEGORY_SONGS_LAYOUT)) _CHECK(CExtBaseLayout::Create(layout)) + _CHECK(catInfo = new CCategoryInfo) _WHEN_SUCCESS{ m->win = win; @@ -912,10 +916,12 @@ bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent) m->mhandle = mhandle; m->mgr = mgr; m->parent = parent; + m->curCatInfo = catInfo; Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN); } + _CHECK_FAIL{ delete catInfo; } _CHECK_FAIL{ CExtBaseLayout::Destroy(); } _CHECK_FAIL{ evas_object_del(layout); } _CHECK_FAIL{} @@ -934,6 +940,10 @@ void CCategorySongsLayout::Destroy(void) Disconnect(Layout()); + if (m->curCatInfo->FlagCreate()) + m->curCatInfo->Destroy(); + delete m->curCatInfo; + m_RemoveFocusIdler(); m_EmptySongList(); CExtBaseLayout::Destroy(); @@ -964,6 +974,35 @@ Eina_List *CCategorySongsLayout::CategorySongItemInfoList(void) } +void CCategorySongsLayout::SetCurrentCategory(CCategoryInfo *curCatInfo) +{ + ASSERT(m); + + if (m->curCatInfo->FlagCreate()) + m->curCatInfo->Destroy(); + + m->curCatInfo->Create(); + + if (curCatInfo) + m->curCatInfo->Duplicate(curCatInfo); + else { + CCategoryInfo *emptyInfo = new CCategoryInfo; + emptyInfo->Create(); + m->curCatInfo->Duplicate(emptyInfo); + emptyInfo->Destroy(); + delete emptyInfo; + } +} + + +CCategoryInfo*CCategorySongsLayout::CurrentCategory(void) +{ + ASSERT(m); + + return m->curCatInfo; +} + + void CCategorySongsLayout::SetFocus(const char *btnStr) { ASSERT(m); -- 2.7.4 From 72ebe4917bf6fbfa67b8d1f9ac0752d50d63f129 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Sat, 28 Mar 2015 23:54:37 +0900 Subject: [PATCH 16/16] Fix Bug : Fix to use IKeyDownListener instead of IFocusedListener to show the first depth of layout when one of group button is focused. : Using IFocusedListener can make a critical bug because OnFocused function can be called unintentionally when elm_object_part_content_unset is called. Change-Id: Ied4f0a9a6d05f67de9058fb27deb9783ec78861f Signed-off-by: Kim Tae Soo --- include/base-view.h | 8 +++---- src/views/album-songs-layout.cpp | 28 +++++++++++++++++------- src/views/base-view.cpp | 46 +++++++++++++++++++++------------------- src/views/song-layout.cpp | 2 +- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/include/base-view.h b/include/base-view.h index 39ecb51..3b1482b 100644 --- a/include/base-view.h +++ b/include/base-view.h @@ -32,8 +32,7 @@ class CMusicBaseView : public CBaseView, public IMouseMoveListener, public IMouseClickedListener, - public IMusicControllerListener, - public IFocusedListener { + public IMusicControllerListener { private: struct SMusicBaseView* m; @@ -44,6 +43,9 @@ private: static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text); void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text); + static Eina_Bool sm_CbShowLayoutIdler(void *cookie); + void m_OnShowLayoutIdler(void); + private: void m_UpdateFocusSequence(void); void m_UpdateEmptyFocusSequence(void); @@ -78,7 +80,6 @@ public: CBaseView(pViewId), IMouseMoveListener(this), IMouseClickedListener(this), - IFocusedListener(this), m(0) {} virtual ~CMusicBaseView() {} @@ -92,7 +93,6 @@ public: virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev); virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev); virtual void OnMouseClicked(int id, Evas_Object *obj); - virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); virtual void OnComplete(void); virtual void OnError(void); diff --git a/src/views/album-songs-layout.cpp b/src/views/album-songs-layout.cpp index f167d2e..f8efc2a 100644 --- a/src/views/album-songs-layout.cpp +++ b/src/views/album-songs-layout.cpp @@ -62,6 +62,7 @@ struct SAlbumSongsLayout { Evas_Object *base; Evas_Object *songlist; Evas_Object *addBtns[TOTAL_ADD_BTNS]; + Evas_Object *albumCover; Elm_Object_Item *focused_item; CMusicController* mhandle; @@ -337,6 +338,18 @@ void CAlbumSongsLayout::m_EmptySongList(void) m->it_infolist = NULL; } + if (m->albumCover) + evas_object_del(m->albumCover); + m->albumCover = NULL; + + int i; + + for (i = 0; i < TOTAL_ADD_BTNS; i++) { + if (m->addBtns[i]) + evas_object_del(m->addBtns[i]); + m->addBtns[i] = NULL; + } + m->total_duration = 0; } @@ -397,7 +410,6 @@ Evas_Object *CAlbumSongsLayout::m_AddAlbumCover(void) void CAlbumSongsLayout::m_CreateTopSection(void) { - Evas_Object *thumb = NULL; int i; Evas_Object *btn; Evas_Object *img = NULL; @@ -424,8 +436,8 @@ void CAlbumSongsLayout::m_CreateTopSection(void) btninfo[BTN_LAST].icon = MUSIC_IMAGE_ADD_LAST; btninfo[BTN_LAST].type = ALBUM_SONGS_LAST_BUTTON; - thumb = m_AddAlbumCover(); - if (!thumb) + m->albumCover = m_AddAlbumCover(); + if (!m->albumCover) return; for (i = 0; i < TOTAL_ADD_BTNS; i++) { @@ -459,18 +471,18 @@ void CAlbumSongsLayout::m_CreateTopSection(void) path = m->alinfo->ThumbnailPath(); if (path) { - elm_image_file_set(thumb, path, NULL); - elm_image_aspect_fixed_set(thumb, EINA_FALSE); + elm_image_file_set(m->albumCover, path, NULL); + elm_image_aspect_fixed_set(m->albumCover, EINA_FALSE); } else { snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, MUSIC_IMAGE_DEFAULT_THUMB_126); - elm_image_file_set(thumb, buf, NULL); - elm_image_no_scale_set(thumb, EINA_TRUE); + elm_image_file_set(m->albumCover, buf, NULL); + elm_image_no_scale_set(m->albumCover, EINA_TRUE); } elm_object_part_content_set(layout, MUSIC_PART_ALBUM_THUMB, - thumb); + m->albumCover); elm_object_part_text_set(layout, MUSIC_PART_ALBUM_NAME, m->alinfo->Name()); elm_object_part_text_set(layout, MUSIC_PART_ALBUM_ARTIST, diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 93ff5fb..2ce9eb5 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -169,6 +169,8 @@ struct SMusicBaseView { CHandleVolume *pHandleVolume; + Ecore_Idler *eiShowLayout; + SMusicBaseView() { memset(this, 0, sizeof(SMusicBaseView)); pHandleVolume = new CHandleVolume; @@ -413,6 +415,25 @@ void CMusicBaseView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* te } +Eina_Bool CMusicBaseView::sm_CbShowLayoutIdler(void *cookie) +{ + CMusicBaseView *root = (CMusicBaseView*)cookie; + if (root) + root->m_OnShowLayoutIdler(); + + return ECORE_CALLBACK_CANCEL; +} + + +void CMusicBaseView::m_OnShowLayoutIdler(void) +{ + m->eiShowLayout = NULL; + + if (elm_object_focus_get(m->c_grpbtn)) + m_ShowCurrentLayout(); +} + + Evas_Object *CMusicBaseView::m_CreateLoadingPopup(void) { Evas_Object *popup = NULL, *label = NULL, *icon = NULL; @@ -993,6 +1014,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key parcel.keyEvent = ev->keyname; CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel); } + else if (!strcmp(ev->keyname, KEY_LEFT)) + m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this); break; case BASE_VIEW_PLAY_BUTTON: @@ -1131,7 +1154,7 @@ void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj) case BASE_VIEW_GROUP_PLAYLIST: { if (m->c_grpbtn == obj) - return; + return; elm_object_signal_emit(m->c_grpbtn, MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW); @@ -1164,27 +1187,6 @@ void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj) } -void CMusicBaseView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) -{ - switch (id) { - case BASE_VIEW_GROUP_SONG: - case BASE_VIEW_GROUP_ALBUM: - case BASE_VIEW_GROUP_ARTIST: - case BASE_VIEW_GROUP_GENRE: - case BASE_VIEW_GROUP_FOLDER: - case BASE_VIEW_GROUP_PLAYLIST: - if (m->lmgr->Layout()) { - m_ShowCurrentLayout(); - m_UpdateCurrentLayout(false); - } - break; - - default: - break; - } -} - - void CMusicBaseView::OnComplete(void) { m_UpdatePlaysongLabel(); diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index 69a92f1..ac82f67 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -382,7 +382,7 @@ void CSongLayout::m_UpdateSongList(bool sort_flag) CSongInfo *sinfo; void *obj; Eina_List *l; - struct SSongItemInfo *itinfo; + SSongItemInfo *itinfo; Elm_Object_Item *item; /* Remove existing songlist and prepare afresh */ -- 2.7.4