cellMusic/Decode: add SelectContents functions

This commit is contained in:
Megamouse 2021-06-19 18:33:43 +02:00
parent 00f6763228
commit cd97d74f0f
11 changed files with 610 additions and 81 deletions

View file

@ -6,10 +6,10 @@
#include "Emu/Io/music_handler_base.h"
#include "Emu/System.h"
#include "Emu/VFS.h"
#include "Emu/RSX/Overlays/overlay_media_list_dialog.h"
#include "cellSearch.h"
#include "cellSpurs.h"
#include "cellSysutil.h"
#include "cellMusic.h"
LOG_CHANNEL(cellMusic);
@ -80,6 +80,45 @@ struct music_state
}
};
error_code cell_music_select_contents()
{
auto& music = g_fxo->get<music_state>();
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
const std::string dir_path = "/dev_hdd0/music";
const std::string vfs_dir_path = vfs::get("/dev_hdd0/music");
const std::string title = get_localized_string(localized_string_id::RSX_OVERLAYS_MEDIA_DIALOG_EMPTY);
error_code error = rsx::overlays::show_media_list_dialog(rsx::overlays::media_list_dialog::media_type::audio, vfs_dir_path, title,
[&music, dir_path, vfs_dir_path](s32 status, utils::media_info info)
{
sysutil_register_cb([&music, dir_path, vfs_dir_path, info, status](ppu_thread& ppu) -> s32
{
const u32 result = status >= 0 ? u32{CELL_OK} : u32{CELL_MUSIC_CANCELED};
if (result == CELL_OK)
{
music_selection_context context;
context.content_path = info.path;
context.content_path = dir_path + info.path.substr(vfs_dir_path.length()); // We need the non-vfs path here
context.content_type = fs::is_dir(info.path) ? CELL_SEARCH_CONTENTTYPE_MUSICLIST : CELL_SEARCH_CONTENTTYPE_MUSIC;
// TODO: context.repeat_mode = CELL_SEARCH_REPEATMODE_NONE;
// TODO: context.context_option = CELL_SEARCH_CONTEXTOPTION_NONE;
music.current_selection_context = context;
cellMusic.success("Media list dialog: selected entry '%s'", context.content_path);
}
else
{
cellMusic.warning("Media list dialog was canceled");
}
music.func(ppu, CELL_MUSIC_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(result), music.userData);
return CELL_OK;
});
});
return error;
}
error_code cellMusicGetSelectionContext(vm::ptr<CellMusicSelectionContext> context)
{
cellMusic.todo("cellMusicGetSelectionContext(context=*0x%x)", context);
@ -392,7 +431,8 @@ error_code cellMusicSetPlaybackCommand2(s32 command, vm::ptr<void> param)
std::string path;
{
std::lock_guard lock(music.mtx);
path = vfs::get(music.current_selection_context.path);
path = vfs::get(music.current_selection_context.content_path);
cellMusic.notice("cellMusicSetPlaybackCommand2: current vfs path: '%s' (unresolved='%s')", path, music.current_selection_context.content_path);
}
switch (command)
@ -447,7 +487,8 @@ error_code cellMusicSetPlaybackCommand(s32 command, vm::ptr<void> param)
std::string path;
{
std::lock_guard lock(music.mtx);
path = vfs::get(music.current_selection_context.path);
path = vfs::get(music.current_selection_context.content_path);
cellMusic.notice("cellMusicSetPlaybackCommand: current vfs path: '%s' (unresolved='%s')", path, music.current_selection_context.content_path);
}
switch (command)
@ -488,36 +529,14 @@ error_code cellMusicSelectContents2()
{
cellMusic.todo("cellMusicSelectContents2()");
auto& music = g_fxo->get<music_state>();
if (!music.func)
return CELL_MUSIC2_ERROR_GENERIC;
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music.func(ppu, CELL_MUSIC2_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
return CELL_OK;
return cell_music_select_contents();
}
error_code cellMusicSelectContents(u32 container)
{
cellMusic.todo("cellMusicSelectContents(container=0x%x)", container);
auto& music = g_fxo->get<music_state>();
if (!music.func)
return CELL_MUSIC_ERROR_GENERIC;
sysutil_register_cb([=, &music](ppu_thread& ppu) -> s32
{
music.func(ppu, CELL_MUSIC_EVENT_SELECT_CONTENTS_RESULT, vm::addr_t(CELL_OK), music.userData);
return CELL_OK;
});
return CELL_OK;
return cell_music_select_contents();
}
error_code cellMusicInitialize2(s32 mode, s32 spuPriority, vm::ptr<CellMusic2Callback> func, vm::ptr<void> userData)