5858
5959#include " WAVFileReader.h"
6060
61+ #include < shellapi.h>
62+
6163#define TOOL_VERSION 0
6264#include " CmdLineHelpers.h"
6365
@@ -270,14 +272,14 @@ namespace
270272 static_assert (sizeof (ENTRYCOMPACT) == 4 , " Mismatch with xact3wb.h" );
271273 static_assert (sizeof (BANKDATA) == 96 , " Mismatch with xact3wb.h" );
272274
273- template <typename T> WORD ChannelsSpecifiedInMask (T x)
275+ template <typename T> WORD ChannelsSpecifiedInMask (T x) noexcept
274276 {
275277 WORD bitCount = 0 ;
276278 while (x) { ++bitCount; x &= (x - 1 ); }
277279 return bitCount;
278280 }
279281
280- WORD AdpcmBlockSizeFromPcmFrames (WORD nPcmFrames, WORD nChannels)
282+ WORD AdpcmBlockSizeFromPcmFrames (WORD nPcmFrames, WORD nChannels) noexcept
281283 {
282284 // The full calculation is as follows:
283285 // UINT uHeaderBytes = MSADPCM_HEADER_LENGTH * nChannels;
@@ -305,7 +307,7 @@ namespace
305307 }
306308 }
307309
308- DWORD EncodeWMABlockAlign (DWORD dwBlockAlign, DWORD dwAvgBytesPerSec)
310+ DWORD EncodeWMABlockAlign (DWORD dwBlockAlign, DWORD dwAvgBytesPerSec) noexcept
309311 {
310312 static const uint32_t aWMABlockAlign[17 ] =
311313 {
@@ -354,7 +356,7 @@ namespace
354356 return DWORD (blockAlignIndex | (bytesPerSecIndex << 5 ));
355357 }
356358
357- bool ConvertToMiniFormat (const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt)
359+ bool ConvertToMiniFormat (const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt) noexcept
358360 {
359361 if (!wfx)
360362 return false ;
@@ -787,6 +789,7 @@ namespace
787789
788790 const wchar_t * g_ToolName = L" xwbtool" ;
789791 const wchar_t * g_Description = L" Microsoft (R) XACT-style Wave Bank Tool [DirectXTK]" ;
792+ const wchar_t * g_FeedbackURL = L" https://github.com/microsoft/DirectXTK/issues" ;
790793
791794 enum OPTIONS : uint32_t
792795 {
@@ -828,7 +831,7 @@ namespace
828831 WaveFile (WaveFile&&) = default ;
829832 };
830833
831- void FileNameToIdentifier (_Inout_updates_all_(count) wchar_t* str, size_t count)
834+ void FileNameToIdentifier (_Inout_updates_all_(count) wchar_t* str, size_t count) noexcept
832835 {
833836 size_t j = 0 ;
834837 for (wchar_t * c = str; j < count && *c != 0 ; ++c, ++j)
@@ -880,13 +883,14 @@ namespace
880883 // ////////////////////////////////////////////////////////////////////////////
881884 // ////////////////////////////////////////////////////////////////////////////
882885
883- void PrintUsage ()
886+ void PrintUsage (bool full = false ) noexcept
884887 {
885888 PrintLogo (false , g_ToolName, g_Description);
886889
887890 static const wchar_t * const s_usage =
888- L" Usage: xwbtool <options> [--] <wav-files>\n "
889- L" \n "
891+ L" Usage: xwbtool <options> [--] <wav-files>\n\n " ;
892+
893+ static const wchar_t * const s_fullUsage =
890894 L" -r wildcard filename search is recursive\n "
891895 L" -flist <filename>, --file-list <filename>\n "
892896 L" use text file with a list of input files (one per line)\n "
@@ -909,9 +913,14 @@ namespace
909913 L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n " ;
910914
911915 wprintf (L" %ls" , s_usage);
916+
917+ if (!full)
918+ return ;
919+
920+ wprintf (L" %ls" , s_fullUsage);
912921 }
913922
914- const char * GetFormatTagName (WORD wFormatTag)
923+ const char * GetFormatTagName (WORD wFormatTag) noexcept
915924 {
916925 switch (wFormatTag)
917926 {
@@ -930,7 +939,7 @@ namespace
930939 }
931940 }
932941
933- const char *ChannelDesc (DWORD dwChannelMask)
942+ const char *ChannelDesc (DWORD dwChannelMask) noexcept
934943 {
935944 switch (dwChannelMask)
936945 {
@@ -948,7 +957,7 @@ namespace
948957 }
949958 }
950959
951- void PrintInfo (const WaveFile& wave)
960+ void PrintInfo (const WaveFile& wave) noexcept
952961 {
953962 if (wave.data .wfx ->wFormatTag == WAVE_FORMAT_EXTENSIBLE
954963 && (wave.data .wfx ->cbSize >= (sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX))))
@@ -985,6 +994,24 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
985994 std::locale::global (std::locale (" " ));
986995
987996 // Process command line
997+ if (argc < 2 )
998+ {
999+ PrintUsage ();
1000+ return 0 ;
1001+ }
1002+
1003+ // check for these first
1004+ if (!_wcsicmp (argv[1 ], L" help" ) || !_wcsicmp (argv[1 ], L" /?" ))
1005+ {
1006+ PrintUsage (true );
1007+ return 0 ;
1008+ }
1009+ else if (!_wcsicmp (argv[1 ], L" feedback" ))
1010+ {
1011+ std::ignore = ShellExecuteW (nullptr , L" open" , g_FeedbackURL, nullptr , nullptr , SW_SHOW);
1012+ return 0 ;
1013+ }
1014+
9881015 uint32_t dwOptions = 0 ;
9891016 std::list<SConversion> conversion;
9901017 bool allowOpts = true ;
@@ -1056,7 +1083,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
10561083 return 0 ;
10571084
10581085 case OPT_HELP:
1059- PrintUsage ();
1086+ PrintUsage (true );
10601087 return 0 ;
10611088
10621089 default :
0 commit comments