mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 05:29:18 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
21
audio.cpp
21
audio.cpp
@@ -159,8 +159,9 @@ buffer_manager::emplace( std::string Filename ) {
|
||||
m_buffers.emplace_back( Filename );
|
||||
|
||||
// NOTE: we store mapping without file type extension, to simplify lookups
|
||||
erase_extension( Filename );
|
||||
m_buffermappings.emplace(
|
||||
Filename.erase( Filename.rfind( '.' ) ),
|
||||
Filename,
|
||||
handle );
|
||||
|
||||
return handle;
|
||||
@@ -169,26 +170,22 @@ buffer_manager::emplace( std::string Filename ) {
|
||||
audio::buffer_handle
|
||||
buffer_manager::find_buffer( std::string const &Buffername ) const {
|
||||
|
||||
auto lookup = m_buffermappings.find( Buffername );
|
||||
if( lookup != m_buffermappings.end() )
|
||||
auto const lookup = m_buffermappings.find( Buffername );
|
||||
if( lookup != std::end( m_buffermappings ) )
|
||||
return lookup->second;
|
||||
else
|
||||
return null_handle;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
buffer_manager::find_file( std::string const &Filename ) const {
|
||||
|
||||
std::vector<std::string> const extensions { ".ogg", ".flac", ".wav" };
|
||||
auto const lookup {
|
||||
FileExists(
|
||||
{ Filename },
|
||||
{ ".ogg", ".flac", ".wav" } ) };
|
||||
|
||||
for( auto const &extension : extensions ) {
|
||||
if( FileExists( Filename + extension ) ) {
|
||||
// valid name on success
|
||||
return Filename + extension;
|
||||
}
|
||||
}
|
||||
return {}; // empty string on failure
|
||||
return lookup.first + lookup.second;
|
||||
}
|
||||
|
||||
} // audio
|
||||
|
||||
Reference in New Issue
Block a user