From: <sv...@op...> - 2024-09-23 21:06:47
|
Author: manx Date: Mon Sep 23 23:06:33 2024 New Revision: 21726 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21726 Log: [Ref] openmpt123: Simplify error printing for audio backends. Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123_allegro42.hpp trunk/OpenMPT/openmpt123/openmpt123_portaudio.hpp trunk/OpenMPT/openmpt123/openmpt123_pulseaudio.hpp trunk/OpenMPT/openmpt123/openmpt123_sdl2.hpp trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp Mon Sep 23 23:06:33 2024 (r21726) @@ -2371,30 +2371,6 @@ std_err << MPT_USTRING("Error parsing command line.") << lf; std_err.writeout(); return 1; -#ifdef MPT_WITH_ALLEGRO42 - } catch ( allegro42_exception & e ) { - std_err << MPT_USTRING("Allegro-4.2 error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf; - std_err.writeout(); - return 1; -#endif -#ifdef MPT_WITH_PULSEAUDIO - } catch ( pulseaudio_exception & e ) { - std_err << MPT_USTRING("PulseAudio error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf; - std_err.writeout(); - return 1; -#endif -#ifdef MPT_WITH_PORTAUDIO - } catch ( portaudio_exception & e ) { - std_err << MPT_USTRING("PortAudio error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf; - std_err.writeout(); - return 1; -#endif -#ifdef MPT_WITH_SDL2 - } catch ( sdl2_exception & e ) { - std_err << MPT_USTRING("SDL2 error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf; - std_err.writeout(); - return 1; -#endif } catch ( silent_exit_exception & ) { return 0; } catch ( exception & e ) { Modified: trunk/OpenMPT/openmpt123/openmpt123_allegro42.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_allegro42.hpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123_allegro42.hpp Mon Sep 23 23:06:33 2024 (r21726) @@ -39,7 +39,7 @@ } } allegro42_exception() - : exception( error_to_string() ) + : exception( MPT_USTRING("Allegro-4.2: ") + error_to_string() ) { } }; Modified: trunk/OpenMPT/openmpt123/openmpt123_portaudio.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_portaudio.hpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123_portaudio.hpp Mon Sep 23 23:06:33 2024 (r21726) @@ -30,7 +30,7 @@ inline constexpr auto portaudio_encoding = mpt::common_encoding::utf8; struct portaudio_exception : public exception { - portaudio_exception( PaError code ) : exception( mpt::transcode<mpt::ustring>( portaudio_encoding, Pa_GetErrorText( code ) ) ) { } + portaudio_exception( PaError code ) : exception( MPT_USTRING("PortAudio: ") + mpt::transcode<mpt::ustring>( portaudio_encoding, Pa_GetErrorText( code ) ) ) { } }; typedef void (*PaUtilLogCallback ) (const char *log); Modified: trunk/OpenMPT/openmpt123/openmpt123_pulseaudio.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_pulseaudio.hpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123_pulseaudio.hpp Mon Sep 23 23:06:33 2024 (r21726) @@ -44,7 +44,7 @@ return mpt::ustring(); } } - pulseaudio_exception( int error ) : exception( error_to_string( error ) ) { } + pulseaudio_exception( int error ) : exception( MPT_USTRING("PulseAudio: ") + error_to_string( error ) ) { } }; class pulseaudio_stream_raii : public write_buffers_interface { Modified: trunk/OpenMPT/openmpt123/openmpt123_sdl2.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_sdl2.hpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123_sdl2.hpp Mon Sep 23 23:06:33 2024 (r21726) @@ -46,7 +46,7 @@ return s.str(); } public: - sdl2_exception( int code, const char * error ) : exception( text_from_code( code ) + MPT_USTRING(" (") + mpt::transcode<mpt::ustring>( sdl2_encoding, error ? std::string(error) : std::string("NULL") ) + MPT_USTRING(")") ) { } + sdl2_exception( int code, const char * error ) : exception( MPT_USTRING("SDL2: ") + text_from_code( code ) + MPT_USTRING(" (") + mpt::transcode<mpt::ustring>( sdl2_encoding, error ? std::string(error) : std::string("NULL") ) + MPT_USTRING(")") ) { } }; static void check_sdl2_error( int e ) { Modified: trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp ============================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp Mon Sep 23 23:02:15 2024 (r21725) +++ trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp Mon Sep 23 23:06:33 2024 (r21726) @@ -20,7 +20,7 @@ namespace openmpt123 { struct waveout_exception : public exception { - waveout_exception() : exception( MPT_USTRING("waveout") ) { } + waveout_exception() : exception( MPT_USTRING("WaveOut: ") + MPT_USTRING("waveout") ) { } }; class waveout_stream_raii : public write_buffers_interface { |