mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
cellMusic: improve logging
This commit is contained in:
parent
5ca5b54bf6
commit
b935a89a2a
4 changed files with 59 additions and 31 deletions
|
@ -1732,7 +1732,7 @@ void patch_engine::save_config(const patch_map& patches_map)
|
||||||
|
|
||||||
fs::pending_file file(path);
|
fs::pending_file file(path);
|
||||||
|
|
||||||
if (!file.file || (file.file.write(out.c_str(), out.size()), !file.commit()))
|
if (!file.file || file.file.write(out.c_str(), out.size() < out.size() || !file.commit()))
|
||||||
{
|
{
|
||||||
patch_log.error("Failed to create patch config file %s (error=%s)", path, fs::g_tls_error);
|
patch_log.error("Failed to create patch config file %s (error=%s)", path, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,11 @@ struct music_state
|
||||||
return CELL_MUSIC_ERROR_NO_MORE_CONTENT;
|
return CELL_MUSIC_ERROR_NO_MORE_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fs::is_file(path))
|
||||||
|
{
|
||||||
|
cellMusic.error("set_playback_command: File does not exist: '%s'", path);
|
||||||
|
}
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
case CELL_MUSIC_PB_CMD_FASTFORWARD:
|
case CELL_MUSIC_PB_CMD_FASTFORWARD:
|
||||||
|
|
|
@ -77,7 +77,7 @@ std::string music_selection_context::get_yaml_path() const
|
||||||
|
|
||||||
if (!fs::create_path(path))
|
if (!fs::create_path(path))
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.fatal("Failed to create path: %s (%s)", path, fs::g_tls_error);
|
cellMusicSelectionContext.fatal("get_yaml_path: Failed to create path: %s (%s)", path, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path + hash + ".yml";
|
return path + hash + ".yml";
|
||||||
|
@ -101,13 +101,18 @@ void music_selection_context::set_playlist(const std::string& path)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.push_back(dir_path + std::string(path + "/" + dir_entry.name).substr(vfs_dir_path.length()));
|
std::string track = dir_path + std::string(path + "/" + dir_entry.name).substr(vfs_dir_path.length());
|
||||||
|
cellMusicSelectionContext.notice("set_playlist: Adding track to playlist: '%s'. (path: '%s', name: '%s')", track, path, dir_entry.name);
|
||||||
|
playlist.push_back(std::move(track));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
content_type = CELL_SEARCH_CONTENTTYPE_MUSIC;
|
content_type = CELL_SEARCH_CONTENTTYPE_MUSIC;
|
||||||
playlist.push_back(dir_path + path.substr(vfs_dir_path.length()));
|
|
||||||
|
std::string track = dir_path + path.substr(vfs_dir_path.length());
|
||||||
|
cellMusicSelectionContext.notice("set_playlist: Adding track to playlist: '%s'. (path: '%s')", track, path);
|
||||||
|
playlist.push_back(std::move(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
|
@ -118,7 +123,7 @@ void music_selection_context::create_playlist(const std::string& new_hash)
|
||||||
hash = new_hash;
|
hash = new_hash;
|
||||||
|
|
||||||
const std::string yaml_path = get_yaml_path();
|
const std::string yaml_path = get_yaml_path();
|
||||||
cellMusicSelectionContext.notice("Saving music playlist file %s", yaml_path);
|
cellMusicSelectionContext.notice("create_playlist: Saving music playlist file %s", yaml_path);
|
||||||
|
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
out << YAML::BeginMap;
|
out << YAML::BeginMap;
|
||||||
|
@ -140,9 +145,9 @@ void music_selection_context::create_playlist(const std::string& new_hash)
|
||||||
|
|
||||||
fs::pending_file file(yaml_path);
|
fs::pending_file file(yaml_path);
|
||||||
|
|
||||||
if (!file.file || (file.file.write(out.c_str(), out.size()), !file.commit()))
|
if (!file.file || file.file.write(out.c_str(), out.size() < out.size() || !file.commit()))
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("Failed to create music playlist file %s (error=%s)", yaml_path, fs::g_tls_error);
|
cellMusicSelectionContext.error("create_playlist: Failed to create music playlist file '%s' (error=%s)", yaml_path, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +156,7 @@ bool music_selection_context::load_playlist()
|
||||||
playlist.clear();
|
playlist.clear();
|
||||||
|
|
||||||
const std::string path = get_yaml_path();
|
const std::string path = get_yaml_path();
|
||||||
cellMusicSelectionContext.notice("Loading music playlist file %s", path);
|
cellMusicSelectionContext.notice("load_playlist: Loading music playlist file '%s'", path);
|
||||||
|
|
||||||
std::string content;
|
std::string content;
|
||||||
{
|
{
|
||||||
|
@ -160,7 +165,7 @@ bool music_selection_context::load_playlist()
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("Failed to load music playlist file %s: %s", path, fs::g_tls_error);
|
cellMusicSelectionContext.error("load_playlist: Failed to load music playlist file '%s': %s", path, fs::g_tls_error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +176,7 @@ bool music_selection_context::load_playlist()
|
||||||
|
|
||||||
if (!error.empty() || !root)
|
if (!error.empty() || !root)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("Failed to load music playlist file %s:\n%s", path, error);
|
cellMusicSelectionContext.error("load_playlist: Failed to load music playlist file '%s':\n%s", path, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,54 +185,54 @@ bool music_selection_context::load_playlist()
|
||||||
const std::string version = get_yaml_node_value<std::string>(root["Version"], err);
|
const std::string version = get_yaml_node_value<std::string>(root["Version"], err);
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No Version entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No Version entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version != target_version)
|
if (version != target_version)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("Version '%s' does not match music playlist target '%s' (file: %s)", version, target_version, path);
|
cellMusicSelectionContext.error("load_playlist: Version '%s' does not match music playlist target '%s' (file: '%s')", version, target_version, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string file_type = get_yaml_node_value<std::string>(root["FileType"], err);
|
const std::string file_type = get_yaml_node_value<std::string>(root["FileType"], err);
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No FileType entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No FileType entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_type != target_file_type)
|
if (file_type != target_file_type)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("FileType '%s' does not match music playlist target '%s' (file: %s)", file_type, target_file_type, path);
|
cellMusicSelectionContext.error("load_playlist: FileType '%s' does not match music playlist target '%s' (file: '%s')", file_type, target_file_type, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_type = static_cast<CellSearchContentType>(get_yaml_node_value<u32>(root["ContentType"], err));
|
content_type = static_cast<CellSearchContentType>(get_yaml_node_value<u32>(root["ContentType"], err));
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No ContentType entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No ContentType entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_option = static_cast<CellSearchContextOption>(get_yaml_node_value<u32>(root["ContextOption"], err));
|
context_option = static_cast<CellSearchContextOption>(get_yaml_node_value<u32>(root["ContextOption"], err));
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No ContextOption entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No ContextOption entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
repeat_mode = static_cast<CellSearchRepeatMode>(get_yaml_node_value<u32>(root["RepeatMode"], err));
|
repeat_mode = static_cast<CellSearchRepeatMode>(get_yaml_node_value<u32>(root["RepeatMode"], err));
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No RepeatMode entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No RepeatMode entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
first_track = get_yaml_node_value<u32>(root["FirstTrack"], err);
|
first_track = get_yaml_node_value<u32>(root["FirstTrack"], err);
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No FirstTrack entry found. Error: '%s' (file: %s)", err, path);
|
cellMusicSelectionContext.error("load_playlist: No FirstTrack entry found. Error: '%s' (file: '%s')", err, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,15 +240,17 @@ bool music_selection_context::load_playlist()
|
||||||
|
|
||||||
if (!track_node || track_node.Type() != YAML::NodeType::Sequence)
|
if (!track_node || track_node.Type() != YAML::NodeType::Sequence)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No Tracks entry found or Tracks is not a Sequence. (file: %s)", path);
|
cellMusicSelectionContext.error("load_playlist: No Tracks entry found or Tracks is not a Sequence. (file: '%s')", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (usz i = 0; i < track_node.size(); i++)
|
for (usz i = 0; i < track_node.size(); i++)
|
||||||
{
|
{
|
||||||
|
cellMusicSelectionContext.notice("load_playlist: Adding track to playlist: '%s'. (file: '%s')", track_node[i].Scalar(), path);
|
||||||
playlist.push_back(track_node[i].Scalar());
|
playlist.push_back(track_node[i].Scalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cellMusicSelectionContext.notice("load_playlist: Loaded music playlist file '%s' (context: %s)", path, to_string());
|
||||||
valid = true;
|
valid = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -254,13 +261,13 @@ void music_selection_context::set_track(std::string_view track)
|
||||||
|
|
||||||
if (playlist.empty())
|
if (playlist.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No tracks to play... (requested path='%s')", track);
|
cellMusicSelectionContext.error("set_track: No tracks to play... (requested path='%s')", track);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (usz i = 0; i < playlist.size(); i++)
|
for (usz i = 0; i < playlist.size(); i++)
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("Comparing track '%s' vs '%s'", track, playlist[i]);
|
cellMusicSelectionContext.error("set_track: Comparing track '%s' vs '%s'", track, playlist[i]);
|
||||||
if (track.ends_with(playlist[i]))
|
if (track.ends_with(playlist[i]))
|
||||||
{
|
{
|
||||||
first_track = current_track = static_cast<u32>(i);
|
first_track = current_track = static_cast<u32>(i);
|
||||||
|
@ -268,14 +275,14 @@ void music_selection_context::set_track(std::string_view track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cellMusicSelectionContext.error("Track '%s' not found...", track);
|
cellMusicSelectionContext.error("set_track: Track '%s' not found...", track);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 music_selection_context::step_track(bool next)
|
u32 music_selection_context::step_track(bool next)
|
||||||
{
|
{
|
||||||
if (playlist.empty())
|
if (playlist.empty())
|
||||||
{
|
{
|
||||||
cellMusicSelectionContext.error("No tracks to play...");
|
cellMusicSelectionContext.error("step_track: No tracks to play...");
|
||||||
current_track = umax;
|
current_track = umax;
|
||||||
return umax;
|
return umax;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +297,7 @@ u32 music_selection_context::step_track(bool next)
|
||||||
if (++current_track >= playlist.size())
|
if (++current_track >= playlist.size())
|
||||||
{
|
{
|
||||||
// We are at the end of the playlist.
|
// We are at the end of the playlist.
|
||||||
cellMusicSelectionContext.notice("No more tracks to play in playlist...");
|
cellMusicSelectionContext.notice("step_track: No more tracks to play in playlist...");
|
||||||
current_track = umax;
|
current_track = umax;
|
||||||
return umax;
|
return umax;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +308,7 @@ u32 music_selection_context::step_track(bool next)
|
||||||
if (current_track == 0)
|
if (current_track == 0)
|
||||||
{
|
{
|
||||||
// We are at the start of the playlist.
|
// We are at the start of the playlist.
|
||||||
cellMusicSelectionContext.notice("No more tracks to play in playlist...");
|
cellMusicSelectionContext.notice("step_track: No more tracks to play in playlist...");
|
||||||
current_track = umax;
|
current_track = umax;
|
||||||
return umax;
|
return umax;
|
||||||
}
|
}
|
||||||
|
@ -339,13 +346,13 @@ u32 music_selection_context::step_track(bool next)
|
||||||
case CELL_SEARCH_REPEATMODE_NOREPEAT1:
|
case CELL_SEARCH_REPEATMODE_NOREPEAT1:
|
||||||
{
|
{
|
||||||
// We are done. We only wanted to decode a single track.
|
// We are done. We only wanted to decode a single track.
|
||||||
cellMusicSelectionContext.notice("No more tracks to play...");
|
cellMusicSelectionContext.notice("step_track: No more tracks to play...");
|
||||||
current_track = umax;
|
current_track = umax;
|
||||||
return umax;
|
return umax;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
fmt::throw_exception("Unknown repeat mode %d", static_cast<u32>(repeat_mode));
|
fmt::throw_exception("step_track: Unknown repeat mode %d", static_cast<u32>(repeat_mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +361,7 @@ u32 music_selection_context::step_track(bool next)
|
||||||
if (next ? current_track == 0 : current_track == (playlist.size() - 1))
|
if (next ? current_track == 0 : current_track == (playlist.size() - 1))
|
||||||
{
|
{
|
||||||
// We reached the first or last track again. Let's shuffle!
|
// We reached the first or last track again. Let's shuffle!
|
||||||
cellMusicSelectionContext.notice("Shuffling playlist...");
|
cellMusicSelectionContext.notice("step_track: Shuffling playlist...");
|
||||||
auto engine = std::default_random_engine{};
|
auto engine = std::default_random_engine{};
|
||||||
std::shuffle(std::begin(playlist), std::end(playlist), engine);
|
std::shuffle(std::begin(playlist), std::end(playlist), engine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "Emu/Cell/Modules/cellMusic.h"
|
#include "Emu/Cell/Modules/cellMusic.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "util/logs.hpp"
|
#include "util/logs.hpp"
|
||||||
|
#include "Utilities/File.h"
|
||||||
|
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -117,13 +118,18 @@ void qt_music_handler::play(const std::string& path)
|
||||||
|
|
||||||
Emu.BlockingCallFromMainThread([&path, this]()
|
Emu.BlockingCallFromMainThread([&path, this]()
|
||||||
{
|
{
|
||||||
|
if (!fs::is_file(path))
|
||||||
|
{
|
||||||
|
music_log.error("play: File does not exist: '%s'", path);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_path != path)
|
if (m_path != path)
|
||||||
{
|
{
|
||||||
m_path = path;
|
m_path = path;
|
||||||
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
music_log.notice("Playing music: %s", path);
|
music_log.notice("Playing music: '%s'", path);
|
||||||
m_media_player->setPlaybackRate(1.0);
|
m_media_player->setPlaybackRate(1.0);
|
||||||
m_media_player->play();
|
m_media_player->play();
|
||||||
});
|
});
|
||||||
|
@ -137,13 +143,18 @@ void qt_music_handler::fast_forward(const std::string& path)
|
||||||
|
|
||||||
Emu.BlockingCallFromMainThread([&path, this]()
|
Emu.BlockingCallFromMainThread([&path, this]()
|
||||||
{
|
{
|
||||||
|
if (!fs::is_file(path))
|
||||||
|
{
|
||||||
|
music_log.error("fast_forward: File does not exist: '%s'", path);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_path != path)
|
if (m_path != path)
|
||||||
{
|
{
|
||||||
m_path = path;
|
m_path = path;
|
||||||
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
music_log.notice("Fast-forwarding music...");
|
music_log.notice("Fast-forwarding music: '%s'", path);
|
||||||
m_media_player->setPlaybackRate(2.0);
|
m_media_player->setPlaybackRate(2.0);
|
||||||
m_media_player->play();
|
m_media_player->play();
|
||||||
});
|
});
|
||||||
|
@ -157,13 +168,18 @@ void qt_music_handler::fast_reverse(const std::string& path)
|
||||||
|
|
||||||
Emu.BlockingCallFromMainThread([&path, this]()
|
Emu.BlockingCallFromMainThread([&path, this]()
|
||||||
{
|
{
|
||||||
|
if (!fs::is_file(path))
|
||||||
|
{
|
||||||
|
music_log.error("fast_reverse: File does not exist: '%s'", path);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_path != path)
|
if (m_path != path)
|
||||||
{
|
{
|
||||||
m_path = path;
|
m_path = path;
|
||||||
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
m_media_player->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
music_log.notice("Fast-reversing music...");
|
music_log.notice("Fast-reversing music: '%s'", path);
|
||||||
m_media_player->setPlaybackRate(-2.0); // NOTE: This doesn't work on the current Qt version
|
m_media_player->setPlaybackRate(-2.0); // NOTE: This doesn't work on the current Qt version
|
||||||
m_media_player->play();
|
m_media_player->play();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue