Skip to content

Commit 519927d

Browse files
Suppress the default error messages from AlsaLib
1 parent 36d76cd commit 519927d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

test/StormTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ const char * GetFileText(PFILE_DATA pFileData)
355355
return szFileText;
356356
}
357357

358+
#ifdef STORMLIB_LINUX
359+
static void alsa_silent_error_handler(const char * file, int line, const char * function, int err, const char * fmt, ...)
360+
{
361+
// Suppress ALSA error output, so do nothing
362+
}
363+
#endif
364+
358365
static void PlayWaveSound(PFILE_DATA pFileData)
359366
{
360367
#ifdef STORMLIB_WINDOWS
@@ -367,6 +374,10 @@ static void PlayWaveSound(PFILE_DATA pFileData)
367374
snd_pcm_t *pcm_handle;
368375
unsigned int bitrate = pHeader->dwSamplesPerSec;
369376

377+
// Suppress ALSA error printing
378+
snd_lib_error_set_handler(alsa_silent_error_handler);
379+
380+
// Open the default sound device and play the sound
370381
if(snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0) >= 0)
371382
{
372383
snd_pcm_format_t format = (pHeader->wBitsPerSample == 16) ? SND_PCM_FORMAT_S16_LE : SND_PCM_FORMAT_S8;

test/TLogHelper.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ inline DWORD TestInterlockedIncrement(DWORD * PtrValue)
108108

109109
inline DWORD Test_GetLastError()
110110
{
111-
#if defined(CASCLIB_PLATFORM_WINDOWS)
112-
return GetCascError();
113-
#else
114-
return GetLastError();
115-
#endif
111+
return SErrGetLastError();
116112
}
117113

118114
#ifdef TEST_PLATFORM_WINDOWS

0 commit comments

Comments
 (0)