debug
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <algorithm> // Para find_if, max, find
|
||||
#include <array> // Para array
|
||||
#include <cstdlib> // Para exit
|
||||
#include <cstdlib> // Para exit, getenv
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move
|
||||
#include <fstream> // Para ofstream
|
||||
@@ -26,10 +26,18 @@ struct JA_Sound_t; // lines 12-12
|
||||
// Helper para cargar archivos de audio desde pack o filesystem
|
||||
namespace {
|
||||
std::string createTempAudioFile(const std::string& file_path) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "DEBUG: Trying to load audio file: %s", file_path.c_str());
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "DEBUG: Resource data size: %u", static_cast<unsigned int>(resource_data.size()));
|
||||
if (!resource_data.empty()) {
|
||||
// Crear archivo temporal
|
||||
std::string temp_path = "/tmp/ccae_audio_" + std::to_string(std::hash<std::string>{}(file_path));
|
||||
// Crear archivo temporal usando std::filesystem::temp_directory_path()
|
||||
std::string temp_dir;
|
||||
#ifdef _WIN32
|
||||
temp_dir = std::getenv("TEMP") ? std::getenv("TEMP") : "C:\\temp";
|
||||
#else
|
||||
temp_dir = "/tmp";
|
||||
#endif
|
||||
std::string temp_path = temp_dir + "/ccae_audio_" + std::to_string(std::hash<std::string>{}(file_path));
|
||||
std::ofstream temp_file(temp_path, std::ios::binary);
|
||||
if (!temp_file) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Cannot create temp file %s", temp_path.c_str());
|
||||
@@ -37,7 +45,7 @@ namespace {
|
||||
}
|
||||
temp_file.write(reinterpret_cast<const char*>(resource_data.data()), resource_data.size());
|
||||
temp_file.close();
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Created temp audio file: %s (%zu bytes)", temp_path.c_str(), resource_data.size());
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Created temp audio file: %s (%u bytes)", temp_path.c_str(), static_cast<unsigned int>(resource_data.size()));
|
||||
return temp_path;
|
||||
}
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Using filesystem audio file: %s", file_path.c_str());
|
||||
|
||||
Reference in New Issue
Block a user