Skip to content

Commit

Permalink
Cleanup|Audio: Log levels and domains (continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 9, 2014
1 parent 935df5f commit b6aef6f
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 86 deletions.
31 changes: 15 additions & 16 deletions doomsday/client/src/audio/audiodriver.cpp
Expand Up @@ -150,6 +150,8 @@ static AutoStr* findAudioPluginPath(const char* name)

static boolean loadAudioDriver(driver_t* driver, const char* name)
{
LOG_AS("loadAudioDriver");

boolean ok = false;

if(name && name[0])
Expand All @@ -164,7 +166,7 @@ static boolean loadAudioDriver(driver_t* driver, const char* name)
}
else
{
Con_Message("Warning: loadAudioDriver: Loading of \"%s\" failed.", name);
LOG_AUDIO_WARNING("Loading of \"%s\" failed") << name;
}
}
return ok;
Expand All @@ -183,8 +185,9 @@ static const char* getDriverName(audiodriverid_t id)
};
if(VALID_AUDIODRIVER_IDENTIFIER(id))
return audioDriverNames[id];
Con_Error("S_GetDriverName: Unknown driver id %i.\n", id);
return 0; // Unreachable.

DENG2_ASSERT(!"S_GetDriverName: Unknown driver id");
return ""; // Unreachable.
}

static audiodriverid_t identifierToDriverId(const char* name)
Expand All @@ -193,7 +196,7 @@ static audiodriverid_t identifierToDriverId(const char* name)
{
if(!stricmp(name, driverIdentifier[i])) return (audiodriverid_t) i;
}
Con_Message("'%s' is not a valid audio driver name.", name);
LOG_AUDIO_ERROR("'%s' is not a valid audio driver name") << name;
return AUDIOD_INVALID;
}

Expand All @@ -212,11 +215,7 @@ static boolean initDriver(audiodriverid_t id)
{
driver_t* d = &drivers[id];

if(!VALID_AUDIODRIVER_IDENTIFIER(id))
{
Con_Error("initDriver: Unknown audio driver id %i.\n", id);
return false;
}
DENG2_ASSERT(VALID_AUDIODRIVER_IDENTIFIER(id));

assert(!isDriverInited(id));
memset(d, 0, sizeof(*d));
Expand Down Expand Up @@ -263,8 +262,8 @@ static boolean initDriver(audiodriverid_t id)
break;
#endif
default:
Con_Error("initDriver: Unknown audio driver id %i.\n", id);
return false; // Unreachable.
DENG2_ASSERT(!"initDriver: Unknown audio driver id");
return false;
}

// All loaded drivers are automatically initialized so they are ready for use.
Expand Down Expand Up @@ -313,7 +312,7 @@ static audiodriverid_t initDriverIfNeeded(const char* identifier)
{
initDriver(drvId);
}
assert(VALID_AUDIODRIVER_IDENTIFIER(drvId));
DENG2_ASSERT(VALID_AUDIODRIVER_IDENTIFIER(drvId));
return drvId;
}

Expand Down Expand Up @@ -375,7 +374,7 @@ static void selectInterfaces(audiodriverid_t defaultDriverId)
drvId = initDriverIfNeeded(CommandLine_At(++p));
if(!drivers[drvId].sfx.gen.Init)
{
Con_Error("Audio driver '%s' does not provide an SFX interface.\n", getDriverName(drvId));
LOG_AUDIO_ERROR("Audio driver '%s' does not provide an SFX interface") << getDriverName(drvId);
}
appendInterface(&pos, AUDIO_ISFX, &drivers[drvId].sfx);
continue;
Expand All @@ -387,7 +386,7 @@ static void selectInterfaces(audiodriverid_t defaultDriverId)
drvId = initDriverIfNeeded(CommandLine_At(++p));
if(!drivers[drvId].music.gen.Init)
{
Con_Error("Audio driver '%s' does not provide a Music interface.\n", getDriverName(drvId));
LOG_AUDIO_ERROR("Audio driver '%s' does not provide a Music interface") << getDriverName(drvId);
}
appendInterface(&pos, AUDIO_IMUSIC, &drivers[drvId].music);
continue;
Expand All @@ -399,7 +398,7 @@ static void selectInterfaces(audiodriverid_t defaultDriverId)
drvId = initDriverIfNeeded(CommandLine_At(++p));
if(!drivers[drvId].cd.gen.Init)
{
Con_Error("Audio driver '%s' does not provide a CD interface.\n", getDriverName(drvId));
LOG_AUDIO_ERROR("Audio driver '%s' does not provide a CD interface") << getDriverName(drvId);
}
appendInterface(&pos, AUDIO_ICD, &drivers[drvId].cd);
continue;
Expand Down Expand Up @@ -467,7 +466,7 @@ boolean AudioDriver_Init(void)
ok = initDriver(defaultDriverId);
if(!ok)
{
Con_Message("Warning: Failed initializing audio driver \"%s\"", getDriverName(defaultDriverId));
LOG_AUDIO_WARNING("Failed initializing audio driver \"%s\"") << getDriverName(defaultDriverId);
}

// Fallback option for the default driver.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/audio/audiodriver_music.cpp
Expand Up @@ -155,9 +155,9 @@ void AudioDriver_Music_Set(int property, void const *ptr)
if(!fn || !fn[0]) return; // No path.

if(F_FileExists(fn))
Con_Message("Current soundfont set to: \"%s\"", fn);
LOG_AUDIO_MSG("Current soundfont set to: \"%s\"") << fn;
else
Con_Message("Warning: Soundfont \"%s\" not found.", fn);
LOG_AUDIO_WARNING("Soundfont \"%s\" not found") << fn;
}
}

Expand Down
7 changes: 5 additions & 2 deletions doomsday/client/src/audio/m_mus2midi.cpp
Expand Up @@ -194,7 +194,9 @@ static boolean getNextEvent(midi_event_t* ev)
return false;

default:
Con_Error("MUS_SongPlayer: Unknown MUS event %d.\n", evDesc.ev);
LOG_RES_WARNING("Invalid MUS format music data");
LOGDEV_RES_WARNING("Unknown MUS event %d while converting MUS to MIDI") << evDesc.ev;
return false;
}

// Choose the channel.
Expand Down Expand Up @@ -231,6 +233,7 @@ boolean M_Mus2Midi(void* data, size_t length, const char* outFile)
FILE* file;

DENG_UNUSED(length);
LOG_AS("M_Mus2Midi");

if(!outFile || !outFile[0]) return false;

Expand All @@ -241,7 +244,7 @@ boolean M_Mus2Midi(void* data, size_t length, const char* outFile)
file = fopen(Str_Text(&nativePath), "wb");
if(!file)
{
Con_Message("Warning: M_Mus2Midi: Failed opening output file \"%s\".", F_PrettyPath(Str_Text(&nativePath)));
LOG_RES_WARNING("Failed opening output file \"%s\"") << F_PrettyPath(Str_Text(&nativePath));
Str_Free(&nativePath);
return false;
}
Expand Down
20 changes: 10 additions & 10 deletions doomsday/client/src/audio/s_main.cpp
Expand Up @@ -127,7 +127,7 @@ boolean S_Init(void)
// Try to load the audio driver plugin(s).
if(!AudioDriver_Init())
{
Con_Message("Music and Sound Effects disabled.");
LOG_AUDIO_NOTE("Music and sound effects are disabled");
return false;
}

Expand All @@ -136,7 +136,7 @@ boolean S_Init(void)

if(!sfxOK || !musOK)
{
Con_Message("Errors during audio subsystem initialization.");
LOG_AUDIO_NOTE("Errors during audio subsystem initialization");
return false;
}
#endif
Expand Down Expand Up @@ -298,12 +298,12 @@ int S_LocalSoundAtVolumeFrom(int soundIdAndFlags, mobj_t *origin,
volume <= 0)
return false; // This won't play...

#if _DEBUG
LOG_AS("S_LocalSoundAtVolumeFrom");

if(volume > 1)
{
Con_Message("S_LocalSoundAtVolumeFrom: Warning! Too high volume (%f).", volume);
LOGDEV_AUDIO_WARNING("Volume is too high (%f > 1)") << volume;
}
#endif

// This is the sound we're going to play.
if((info = S_GetSoundInfo(soundId, &freq, &volume)) == NULL)
Expand Down Expand Up @@ -532,7 +532,7 @@ int S_StartMusicNum(int id, boolean looped)
if(id < 0 || id >= defs.count.music.num) return false;
ded_music_t *def = &defs.music[id];

LOG_AUDIO_VERBOSE("Starting music '%s'...") << def->id;
LOG_AUDIO_MSG("Starting music '%s'") << def->id;

return Mus_Start(def, looped);

Expand Down Expand Up @@ -612,10 +612,10 @@ D_CMD(PlaySound)

if(argc < 2)
{
Con_Printf("Usage: %s (id) (volume) at (x) (y) (z)\n", argv[0]);
Con_Printf("(volume) must be in 0..1, but may be omitted.\n");
Con_Printf("'at (x) (y) (z)' may also be omitted.\n");
Con_Printf("The sound is always played locally.\n");
LOG_SCR_MSG("Usage: %s (id) (volume) at (x) (y) (z)") << argv[0];
LOG_SCR_MSG("(volume) must be in 0..1, but may be omitted.");
LOG_SCR_MSG("'at (x) (y) (z)' may also be omitted.");
LOG_SCR_MSG("The sound is always played locally.");
return true;
}

Expand Down
25 changes: 9 additions & 16 deletions doomsday/client/src/audio/s_mus.cpp
Expand Up @@ -318,18 +318,11 @@ int Mus_StartLump(lumpnum_t lump, boolean looped, boolean canPlayMUS)
// expected.

lumpLength = F_LumpLength(lump);
buf = (uint8_t*) malloc(lumpLength);
if(!buf)
{
Con_Message("Warning: Mus_Start: Failed on allocation of %lu bytes for "
"temporary MUS to MIDI conversion buffer.", (unsigned long) lumpLength);
return 0;
}

buf = (uint8_t*) M_Malloc(lumpLength);
file = F_FindFileForLumpNum2(lump, &lumpIdx);
F_ReadLumpSection(file, lumpIdx, buf, 0, lumpLength);
M_Mus2Midi((void*)buf, lumpLength, Str_Text(srcFile));
free(buf);
M_Free(buf);

return AudioDriver_Music_PlayNativeFile(Str_Text(srcFile), looped);
}
Expand Down Expand Up @@ -471,24 +464,24 @@ D_CMD(PlayMusic)

if(!musAvail)
{
Con_Printf("The Music module is not available.\n");
LOG_SCR_WARNING("Music subsystem is not available");
return false;
}

switch(argc)
{
default:
Con_Printf("Usage:\n %s (music-def)\n", argv[0]);
Con_Printf(" %s lump (lumpname)\n", argv[0]);
Con_Printf(" %s file (filename)\n", argv[0]);
Con_Printf(" %s cd (track)\n", argv[0]);
LOG_SCR_MSG("Usage:\n %s (music-def)") << argv[0];
LOG_SCR_MSG(" %s lump (lumpname)") << argv[0];
LOG_SCR_MSG(" %s file (filename)") << argv[0];
LOG_SCR_MSG(" %s cd (track)") << argv[0];
break;

case 2: {
int musIdx = Def_GetMusicNum(argv[1]);
if(musIdx < 0)
{
Con_Printf("Music '%s' not defined.\n", argv[1]);
LOG_SCR_WARNING("Music '%s' not defined") << argv[1];
return false;
}

Expand All @@ -515,7 +508,7 @@ D_CMD(PlayMusic)
{
if(!AudioDriver_CD())
{
Con_Printf("No CD audio interface available.\n");
LOG_SCR_WARNING("No CD audio interface available");
return false;
}

Expand Down
6 changes: 4 additions & 2 deletions doomsday/client/src/audio/s_sfx.cpp
Expand Up @@ -657,7 +657,7 @@ int Sfx_StartSound(sfxsample_t *sample, float volume, float freq, mobj_t *emitte
{
// The new sound can't be played because we were unable to stop
// enough channels to accommodate the limitation.
LOG_AUDIO_XVERBOSE("Not playing %i because all channels are busy")
LOG_AUDIO_XVERBOSE("Not playing #%i because all channels are busy")
<< sample->id;
return false;
}
Expand Down Expand Up @@ -1010,7 +1010,9 @@ void Sfx_StartRefresh()
// Start the refresh thread. It will run until the Sfx module is shut down.
refreshHandle = Sys_StartThread(Sfx_ChannelRefreshThread, NULL);
if(!refreshHandle)
Con_Error("Sfx_StartRefresh: Failed to start refresh.\n");
{
throw de::Error("Sfx_StartRefresh", "Failed to start refresh thread.");
}
}
else
{
Expand Down
12 changes: 7 additions & 5 deletions doomsday/client/src/audio/s_wav.cpp
Expand Up @@ -80,9 +80,11 @@ void* WAV_MemoryLoad(const byte* data, size_t datalength, int* bits, int* rate,
chunk_hdr_t riff_chunk;
wav_format_t wave_format;

LOG_AS("WAV_MemoryLoad");

if(!WAV_CheckFormat((const char*)data))
{
Con_Message("WAV_MemoryLoad: Not a WAV file.");
LOG_RES_WARNING("Not WAV format data");
return NULL;
}

Expand Down Expand Up @@ -123,12 +125,12 @@ void* WAV_MemoryLoad(const byte* data, size_t datalength, int* bits, int* rate,
// Check that it's a format we know how to read.
if(wave_format.wFormatTag != WAVE_FORMAT_PCM)
{
Con_Message("WAV_MemoryLoad: Unsupported format (%i).", wave_format.wFormatTag);
LOG_RES_WARNING("Unsupported format (%i)") << wave_format.wFormatTag;
return NULL;
}
if(wave_format.wChannels != 1)
{
Con_Message("WAV_MemoryLoad: Too many channels (only mono supported).");
LOG_RES_WARNING("Too many channels (only mono supported)");
return NULL;
}
// Read the extra format information.
Expand All @@ -144,7 +146,7 @@ void* WAV_MemoryLoad(const byte* data, size_t datalength, int* bits, int* rate,
if(wave_format.wBitsPerSample != 8 &&
wave_format.wBitsPerSample != 16)
{
Con_Message("WAV_MemoryLoad: Not a 8/16 bit WAVE.");
LOG_RES_WARNING("Must have 8 or 16 bits per sample");
return NULL;
}
// Now we know some information about the sample.
Expand All @@ -155,7 +157,7 @@ void* WAV_MemoryLoad(const byte* data, size_t datalength, int* bits, int* rate,
{
if(!wave_format.wFormatTag)
{
Con_Message("WAV_MemoryLoad: Malformed WAVE data.");
LOG_RES_WARNING("Malformed WAV data");
return NULL;
}
// Read data chunk.
Expand Down

0 comments on commit b6aef6f

Please sign in to comment.