migrate from std::filesystem::path to io::path (WIP)
This commit is contained in:
+10
-9
@@ -4,6 +4,7 @@
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include "io/io.hpp"
|
||||
#include "coders/ogg.hpp"
|
||||
#include "coders/wav.hpp"
|
||||
#include "AL/ALAudio.hpp"
|
||||
@@ -181,11 +182,11 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<PCM> audio::load_PCM(const fs::path& file, bool headerOnly) {
|
||||
if (!fs::exists(file)) {
|
||||
throw std::runtime_error("file not found '" + file.u8string() + "'");
|
||||
std::unique_ptr<PCM> audio::load_PCM(const io::path& file, bool headerOnly) {
|
||||
if (!io::exists(file)) {
|
||||
throw std::runtime_error("file not found '" + file.string() + "'");
|
||||
}
|
||||
std::string ext = file.extension().u8string();
|
||||
std::string ext = file.extension();
|
||||
if (ext == ".wav" || ext == ".WAV") {
|
||||
return wav::load_pcm(file, headerOnly);
|
||||
} else if (ext == ".ogg" || ext == ".OGG") {
|
||||
@@ -194,7 +195,7 @@ std::unique_ptr<PCM> audio::load_PCM(const fs::path& file, bool headerOnly) {
|
||||
throw std::runtime_error("unsupported audio format");
|
||||
}
|
||||
|
||||
std::unique_ptr<Sound> audio::load_sound(const fs::path& file, bool keepPCM) {
|
||||
std::unique_ptr<Sound> audio::load_sound(const io::path& file, bool keepPCM) {
|
||||
std::shared_ptr<PCM> pcm(
|
||||
load_PCM(file, !keepPCM && backend->isDummy()).release()
|
||||
);
|
||||
@@ -207,8 +208,8 @@ std::unique_ptr<Sound> audio::create_sound(
|
||||
return backend->createSound(std::move(pcm), keepPCM);
|
||||
}
|
||||
|
||||
std::unique_ptr<PCMStream> audio::open_PCM_stream(const fs::path& file) {
|
||||
std::string ext = file.extension().u8string();
|
||||
std::unique_ptr<PCMStream> audio::open_PCM_stream(const io::path& file) {
|
||||
std::string ext = file.extension();
|
||||
if (ext == ".wav" || ext == ".WAV") {
|
||||
return wav::create_stream(file);
|
||||
} else if (ext == ".ogg" || ext == ".OGG") {
|
||||
@@ -218,7 +219,7 @@ std::unique_ptr<PCMStream> audio::open_PCM_stream(const fs::path& file) {
|
||||
}
|
||||
|
||||
std::unique_ptr<Stream> audio::open_stream(
|
||||
const fs::path& file, bool keepSource
|
||||
const io::path& file, bool keepSource
|
||||
) {
|
||||
if (!keepSource && backend->isDummy()) {
|
||||
auto header = load_PCM(file, true);
|
||||
@@ -338,7 +339,7 @@ speakerid_t audio::play(
|
||||
}
|
||||
|
||||
speakerid_t audio::play_stream(
|
||||
const fs::path& file,
|
||||
const io::path& file,
|
||||
glm::vec3 position,
|
||||
bool relative,
|
||||
float volume,
|
||||
|
||||
+6
-8
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "typedefs.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
#include "io/fwd.hpp"
|
||||
|
||||
namespace audio {
|
||||
/// @brief playing speaker uid
|
||||
@@ -365,7 +363,7 @@ namespace audio {
|
||||
/// @param headerOnly read header only
|
||||
/// @throws std::runtime_error if I/O error ocurred or format is unknown
|
||||
/// @return PCM audio data
|
||||
std::unique_ptr<PCM> load_PCM(const fs::path& file, bool headerOnly);
|
||||
std::unique_ptr<PCM> load_PCM(const io::path& file, bool headerOnly);
|
||||
|
||||
/// @brief Load sound from file
|
||||
/// @param file audio file path
|
||||
@@ -373,7 +371,7 @@ namespace audio {
|
||||
/// Sound::getPCM
|
||||
/// @throws std::runtime_error if I/O error ocurred or format is unknown
|
||||
/// @return new Sound instance
|
||||
std::unique_ptr<Sound> load_sound(const fs::path& file, bool keepPCM);
|
||||
std::unique_ptr<Sound> load_sound(const io::path& file, bool keepPCM);
|
||||
|
||||
/// @brief Create new sound from PCM data
|
||||
/// @param pcm PCM data
|
||||
@@ -386,14 +384,14 @@ namespace audio {
|
||||
/// @param file audio file path
|
||||
/// @throws std::runtime_error if I/O error ocurred or format is unknown
|
||||
/// @return new PCMStream instance
|
||||
std::unique_ptr<PCMStream> open_PCM_stream(const fs::path& file);
|
||||
std::unique_ptr<PCMStream> open_PCM_stream(const io::path& file);
|
||||
|
||||
/// @brief Open new audio stream from file
|
||||
/// @param file audio file path
|
||||
/// @param keepSource store PCMStream in stream to make it accessible with
|
||||
/// Stream::getSource
|
||||
/// @return new Stream instance
|
||||
std::unique_ptr<Stream> open_stream(const fs::path& file, bool keepSource);
|
||||
std::unique_ptr<Stream> open_stream(const io::path& file, bool keepSource);
|
||||
|
||||
/// @brief Open new audio stream from source
|
||||
/// @param stream PCM data source
|
||||
@@ -464,7 +462,7 @@ namespace audio {
|
||||
/// @param channel channel index
|
||||
/// @return speaker id or 0
|
||||
speakerid_t play_stream(
|
||||
const fs::path& file,
|
||||
const io::path& file,
|
||||
glm::vec3 position,
|
||||
bool relative,
|
||||
float volume,
|
||||
|
||||
Reference in New Issue
Block a user