mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 23:49:19 +02:00
AnimModel.cpp reaches cParser through the simulation core, not a direct import, so the previous pass missed it; the propagation now follows the whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call Console:: inside _WIN32 guards without importing eu07.console - invisible on Linux, where those blocks are skipped.
128 lines
3.1 KiB
C++
128 lines
3.1 KiB
C++
module;
|
|
#include <array>
|
|
#include <chrono>
|
|
#include <deque>
|
|
#include <limits>
|
|
#include <mutex>
|
|
#include <ostream>
|
|
#include <sstream>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
#include "global_include/interfaces/ITexture_macros.h"
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#include <OpenAL/al.h>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#include <OpenAL/alc.h>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <AL/al.h>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <AL/alc.h>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <AL/alext.h>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <cstddef>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <string>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <unordered_map>
|
|
#endif
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#include <vector>
|
|
#endif
|
|
|
|
export module eu07.audio.audio;
|
|
|
|
export {
|
|
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
|
|
#if defined(__APPLE__) && !__has_include(<AL/al.h>)
|
|
#else
|
|
#endif
|
|
|
|
namespace audio {
|
|
|
|
ALuint const null_resource{ ~ALuint{0} };
|
|
|
|
// wrapper for audio sample
|
|
struct openal_buffer {
|
|
// members
|
|
ALuint id { null_resource }; // associated AL resource
|
|
unsigned int rate {}; // sample rate of the data
|
|
std::string name;
|
|
std::string caption;
|
|
// constructors
|
|
openal_buffer() = default;
|
|
explicit openal_buffer( std::string const &Filename );
|
|
// methods
|
|
// retrieves sound caption in currently set language
|
|
void
|
|
fetch_caption();
|
|
|
|
};
|
|
|
|
using buffer_handle = std::size_t;
|
|
|
|
|
|
//
|
|
class buffer_manager {
|
|
|
|
public:
|
|
// constructors
|
|
buffer_manager() { m_buffers.emplace_back( openal_buffer() ); } // empty bindings for null buffer
|
|
// destructor
|
|
~buffer_manager();
|
|
// methods
|
|
// creates buffer object out of data stored in specified file. returns: handle to the buffer or null_handle if creation failed
|
|
buffer_handle
|
|
create( std::string const &Filename );
|
|
// provides direct access to a specified buffer
|
|
audio::openal_buffer const &
|
|
buffer( audio::buffer_handle const Buffer ) const;
|
|
|
|
private:
|
|
// types
|
|
using buffer_sequence = std::vector<openal_buffer>;
|
|
using index_map = std::unordered_map<std::string, std::size_t>;
|
|
// methods
|
|
// places in the bank a buffer containing data stored in specified file. returns: handle to the buffer
|
|
buffer_handle
|
|
emplace( std::string Filename );
|
|
// checks whether specified buffer is in the buffer bank. returns: buffer handle, or null_handle.
|
|
buffer_handle
|
|
find_buffer( std::string const &Buffername ) const;
|
|
// checks whether specified file exists. returns: name of the located file, or empty string.
|
|
std::string
|
|
find_file( std::string const &Filename ) const;
|
|
// members
|
|
buffer_sequence m_buffers;
|
|
index_map m_buffermappings;
|
|
};
|
|
|
|
} // audio
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
} // export
|