From b1a9e87ecfa2b3ff5a8d4ffc28566aa5cce8f49b Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 20 Feb 2022 15:22:41 +0100 Subject: [PATCH] cellSearch: fix cellSearchStartListSearch Fixes listing BGM in Gundam. The returned content was always empty. Playback of the tracks will still require a MusicSelectionContext and cellMusic playback, which isn't implemented yet. --- rpcs3/Emu/Cell/Modules/cellSearch.cpp | 41 +++++++++++++-------------- rpcs3/util/media_utils.h | 11 +++++++ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSearch.cpp b/rpcs3/Emu/Cell/Modules/cellSearch.cpp index b571a09ba6..7829af8997 100644 --- a/rpcs3/Emu/Cell/Modules/cellSearch.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSearch.cpp @@ -102,17 +102,6 @@ struct search_object_t std::vector content_ids; }; -template -void parse_metadata(D& dst, const utils::media_info& mi, const std::string& key, const std::string& def, usz max_length) -{ - std::string value = mi.get_metadata(key, def); - if (value.size() > max_length) - { - value.resize(max_length); - } - strcpy_trunc(dst, value); -}; - error_code check_search_state(search_state state, search_state action) { switch (action) @@ -651,7 +640,7 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo content_map.map.emplace(hash, curr_find); curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types - cellSearch.notice("cellSearchStartListSearch(): Content ID: %08X, Path: \"%s\"", hash, item_path); + cellSearch.notice("cellSearchStartListSearch(): CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } else // list is already stored and tracked { @@ -659,8 +648,9 @@ error_code cellSearchStartListSearch(CellSearchListSearchType type, CellSearchSo // Perform checks to see if the identified list has been modified since last checked // In which case, update the stored content's properties // auto content_found = &content_map->at(content_id); - // curr_search->content_ids.emplace_back(found->first, found->second); - cellSearch.notice("cellSearchStartListSearch(): Already tracked: Content ID: %08X, Path: \"%s\"", hash, item_path); + curr_search->content_ids.emplace_back(found->first, found->second); + + cellSearch.notice("cellSearchStartListSearch(): Already tracked: CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } } }; @@ -870,7 +860,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list content_map.map.emplace(hash, curr_find); curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types - cellSearch.notice("cellSearchStartContentSearchInList(): Content ID: %08X, Path: \"%s\"", hash, item_path); + cellSearch.notice("cellSearchStartContentSearchInList(): CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } else // file is already stored and tracked { @@ -880,7 +870,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list // auto content_found = &content_map->at(content_id); curr_search->content_ids.emplace_back(found->first, found->second); - cellSearch.notice("cellSearchStartContentSearchInList(): Already Tracked: Content ID: %08X, Path: \"%s\"", hash, item_path); + cellSearch.notice("cellSearchStartContentSearchInList(): Already Tracked: CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } } }; @@ -1052,7 +1042,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe content_map.map.emplace(hash, curr_find); curr_search->content_ids.emplace_back(hash, curr_find); // place this file's "ID" into the list of found types - cellSearch.notice("cellSearchStartContentSearch(): Content ID: %08X, Path: \"%s\"", hash, item_path); + cellSearch.notice("cellSearchStartContentSearch(): CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } else // file is already stored and tracked { // TODO @@ -1061,7 +1051,7 @@ error_code cellSearchStartContentSearch(CellSearchContentSearchType type, CellSe // auto content_found = &content_map->at(content_id); curr_search->content_ids.emplace_back(found->first, found->second); - cellSearch.notice("cellSearchStartContentSearch(): Already Tracked: Content ID: %08X, Path: \"%s\"", hash, item_path); + cellSearch.notice("cellSearchStartContentSearch(): Already Tracked: CellSearchId: 0x%x, Content ID: %08X, Path: \"%s\"", id, hash, item_path); } } }; @@ -1480,34 +1470,43 @@ error_code cellSearchGetMusicSelectionContext(CellSearchId searchId, vm::cptrcontent_ids.cend() && content->second) { // Check if the type of the found content is correct + if (content->second->type != CELL_SEARCH_CONTENTTYPE_MUSIC) + { + return { CELL_SEARCH_ERROR_INVALID_CONTENTTYPE, fmt::format("Type: %d, Expected: CELL_SEARCH_CONTENTTYPE_MUSIC")}; + } + + // Check if the type of the found content matches our search content type if (content->second->type != first_content->type) { - return CELL_SEARCH_ERROR_NOT_SUPPORTED_CONTEXT; + return { CELL_SEARCH_ERROR_NOT_SUPPORTED_CONTEXT, fmt::format("Type: %d, Expected: %d", +content->second->type, +first_content->type) }; } // TODO: Use the found content // first track/playlist of context = content->second; + cellSearch.todo("cellSearchGetMusicSelectionContext(): Hash=%08X, Assign found track: Type=0x%x, Path=%s", content_hash, +content->second->type, content->second->infoPath.contentPath); } else if (first_content->type == CELL_SEARCH_CONTENTTYPE_MUSICLIST) { // Abort if we can't find the playlist. - return CELL_SEARCH_ERROR_CONTENT_NOT_FOUND; + return { CELL_SEARCH_ERROR_CONTENT_NOT_FOUND, "Type: CELL_SEARCH_CONTENTTYPE_MUSICLIST" }; } else { // TODO: Select the first track by default // first track of context = first_content; + cellSearch.todo("cellSearchGetMusicSelectionContext(): Hash=%08X, Assign first track: Type=0x%x, Path=%s", content_hash, +first_content->type, first_content->infoPath.contentPath); } } else if (first_content->type == CELL_SEARCH_CONTENTTYPE_MUSICLIST) { // Abort if we don't have the necessary info to select a playlist. - return CELL_SEARCH_ERROR_NOT_SUPPORTED_CONTEXT; + return { CELL_SEARCH_ERROR_NOT_SUPPORTED_CONTEXT, "Type: CELL_SEARCH_CONTENTTYPE_MUSICLIST" }; } else { // TODO: Select the first track by default // first track of context = first_content; + cellSearch.todo("cellSearchGetMusicSelectionContext(): Assign first track: Type=0x%x, Path=%s", +first_content->type, first_content->infoPath.contentPath); } // TODO: Use repeatMode and option in our context, depending on the type (list vs single) diff --git a/rpcs3/util/media_utils.h b/rpcs3/util/media_utils.h index 2e95397398..1917d0dc5a 100644 --- a/rpcs3/util/media_utils.h +++ b/rpcs3/util/media_utils.h @@ -21,4 +21,15 @@ namespace utils }; std::pair get_media_info(const std::string& path, s32 av_media_type); + + template + void parse_metadata(D& dst, const utils::media_info& mi, const std::string& key, const std::string& def, usz max_length) + { + std::string value = mi.get_metadata(key, def); + if (value.size() > max_length) + { + value.resize(max_length); + } + strcpy_trunc(dst, value); + }; }