From: <sv...@op...> - 2025-06-09 16:42:16
|
Author: manx Date: Mon Jun 9 18:42:04 2025 New Revision: 23436 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=23436 Log: [Fix] openmpt123: We need to also consider file extensions of subformats. This is necessary because MP3 is a subformat and the major format lists only .m1a as file extension. Modified: trunk/OpenMPT/openmpt123/openmpt123_sndfile.hpp Modified: trunk/OpenMPT/openmpt123/openmpt123_sndfile.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_sndfile.hpp Mon Jun 9 18:37:23 2025 (r23435) +++ trunk/OpenMPT/openmpt123/openmpt123_sndfile.hpp Mon Jun 9 18:42:04 2025 (r23436) @@ -106,7 +106,7 @@ switch ( match_mode ) { case match_print: log << MPT_USTRING("sndfile: ") - << mpt::transcode<mpt::ustring>( sndfile_encoding, ( format_info.name ? format_info.name : "" ) ) << MPT_USTRING(" (.") << mpt::transcode<mpt::ustring>( sndfile_encoding, ( format_info.extension ? format_info.extension : "" ) ) << MPT_USTRING(")") + << mpt::transcode<mpt::ustring>( sndfile_encoding, ( format_info.name ? format_info.name : "" ) ) << MPT_USTRING(" (.") << mpt::transcode<mpt::ustring>( sndfile_encoding, ( subformat_info.extension ? subformat_info.extension : format_info.extension ? format_info.extension : "" ) ) << MPT_USTRING(")") << MPT_USTRING(" / ") << mpt::transcode<mpt::ustring>( sndfile_encoding, ( subformat_info.name ? subformat_info.name : "" ) ) << MPT_USTRING(" [") @@ -117,6 +117,14 @@ case match_recurse: break; case match_exact: + if ( subformat_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == subformat_info.extension ) ) { + if ( flags.use_float && ( subformat_info.format == SF_FORMAT_FLOAT ) ) { + return matched_result( format, format_info, subformat_info, match_mode ); + } else if ( !flags.use_float && ( subformat_info.format == SF_FORMAT_PCM_16 ) ) { + return matched_result( format, format_info, subformat_info, match_mode ); + } + } + break; if ( format_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == format_info.extension ) ) { if ( flags.use_float && ( subformat_info.format == SF_FORMAT_FLOAT ) ) { return matched_result( format, format_info, subformat_info, match_mode ); @@ -126,6 +134,14 @@ } break; case match_better: + if ( subformat_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == subformat_info.extension ) ) { + if ( flags.use_float && ( subformat_info.format == SF_FORMAT_FLOAT || subformat_info.format == SF_FORMAT_DOUBLE ) ) { + return matched_result( format, format_info, subformat_info, match_mode ); + } else if ( !flags.use_float && ( subformat_info.format & ( subformat_info.format == SF_FORMAT_PCM_16 || subformat_info.format == SF_FORMAT_PCM_24 || subformat_info.format == SF_FORMAT_PCM_32 ) ) ) { + return matched_result( format, format_info, subformat_info, match_mode ); + } + } + break; if ( format_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == format_info.extension ) ) { if ( flags.use_float && ( subformat_info.format == SF_FORMAT_FLOAT || subformat_info.format == SF_FORMAT_DOUBLE ) ) { return matched_result( format, format_info, subformat_info, match_mode ); @@ -135,6 +151,9 @@ } break; case match_any: + if ( subformat_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == subformat_info.extension ) ) { + return matched_result( format, format_info, subformat_info, match_mode ); + } if ( format_info.extension && ( mpt::transcode<std::string>( sndfile_encoding, extension ) == format_info.extension ) ) { return matched_result( format, format_info, subformat_info, match_mode ); } |