Fixed the Logging system to actually be able to handle errors. Database is also fixed to use directories.
This commit is contained in:
@@ -69,7 +69,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -363,7 +363,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -394,7 +394,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -779,7 +779,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
return;
|
||||
}
|
||||
@@ -878,7 +878,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
|
||||
return result;
|
||||
@@ -901,7 +901,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1927,7 +1927,7 @@ namespace ehs
|
||||
Version version = in.ReadVersion();
|
||||
if (version != Version(1, 0, 0))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Incompatible audio file version.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Incompatible audio file version.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1954,14 +1954,14 @@ namespace ehs
|
||||
|
||||
if (riff.GetType() != "WAVE")
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Data is not in WAVE format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Data is not in WAVE format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
RIFF_Chunk fmt = riff.GetChunk("fmt ");
|
||||
if (!fmt.IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Wave does not have a format chunk.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Wave does not have a format chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1970,59 +1970,59 @@ namespace ehs
|
||||
RIFF_Chunk dChunk = riff.GetChunk("data");
|
||||
if (!dChunk.IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Wave does not have a data chunk.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Wave does not have a data chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_16 compression = fmtSer.Read<UInt_16>();
|
||||
if (compression == 0x2)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Microsoft ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Microsoft ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x6)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "ITU G.711 a-law compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "ITU G.711 a-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x7)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "ITU G.711 µ-law compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "ITU G.711 µ-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x11)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "IMA ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "IMA ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x16)
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x31)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "GSM 6.10 compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "GSM 6.10 compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x40)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x50)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "MPEG compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "MPEG compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0xFFFF)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Experimental compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Experimental compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression != 0x1 && compression != 0x3)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ namespace ehs
|
||||
{
|
||||
if (!encodeCb)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace ehs
|
||||
{
|
||||
if (!decodeCb)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ namespace ehs
|
||||
|
||||
if (snd_pcm_hw_params_set_access(hdl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to set access.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set access.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace ehs
|
||||
}
|
||||
default:
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Invalid data type.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Invalid data type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_set_channels_near(hdl, params, &channels) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to set channels.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to set channels.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -134,26 +134,26 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_set_rate_near(hdl, params, &sampleRate, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to set sample rate.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_period_time_near(hdl, params, &period, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to set period.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to set period.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_buffer_time_near(hdl, params, &latency, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to set latency.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to set latency.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params(hdl, params) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Failed to apply hardware parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to apply hardware parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace ehs
|
||||
snd_pcm_format_t format;
|
||||
if (snd_pcm_hw_params_get_format(params, &format) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "Failed to retrieve audio device properties.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to retrieve audio device properties.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace ehs
|
||||
}
|
||||
default:
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "Format unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "Format unsupported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_get_channels(params, &channels) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "Failed to retrieve channel count.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "Failed to retrieve channel count.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -220,14 +220,14 @@ namespace ehs
|
||||
int dir;
|
||||
if (snd_pcm_hw_params_get_rate(params, &sampleRate, &dir) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "Failed to retrieve sample rate.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "Failed to retrieve sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_get_buffer_size(params, &maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "Failed to retrieve buffer size.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "Failed to retrieve buffer size.");
|
||||
}
|
||||
|
||||
snd_pcm_sw_params_t* swParams = nullptr;
|
||||
@@ -235,31 +235,31 @@ namespace ehs
|
||||
|
||||
if (snd_pcm_sw_params_current(hdl, swParams) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Failed to retrieve software parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Failed to retrieve software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_threshold(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence threshold.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Failed to set silence threshold.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_size(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence size.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Failed to set silence size.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params(hdl, swParams) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 13, "Failed to set software parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 13, "Failed to set software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_prepare(hdl) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 14, "Failed to prepare audio stream.");
|
||||
EHS_LOG_INT(LogType::ERR, 14, "Failed to prepare audio stream.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -281,10 +281,10 @@ namespace ehs
|
||||
snd_pcm_state_t state = snd_pcm_state(hdl);
|
||||
if (state == SND_PCM_STATE_XRUN)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 0, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 0) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
return GetAvailFrames();
|
||||
@@ -293,7 +293,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_start(hdl) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to start audio stream.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to start audio stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -305,10 +305,10 @@ namespace ehs
|
||||
{
|
||||
if (frames == -EPIPE)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 3, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT(LogType::WARN, 3, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 1) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace ehs
|
||||
const snd_pcm_channel_area_t* areas;
|
||||
if (snd_pcm_mmap_begin(hdl, &areas, offset, frames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to map audio buffer.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to map audio buffer.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace ehs
|
||||
snd_pcm_sframes_t committed = snd_pcm_mmap_commit(hdl, offset, frames);
|
||||
if (committed < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to commit mapped audio buffer.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to commit mapped audio buffer.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Wrong value for the audio device type.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Wrong value for the audio device type.");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ namespace ehs
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace ehs
|
||||
|
||||
HRESULT r = hdl->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr, (void**)&client);
|
||||
if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
WAVEFORMATEXTENSIBLE* format;
|
||||
client->GetMixFormat((WAVEFORMATEX**)&format);
|
||||
@@ -146,7 +146,7 @@ namespace ehs
|
||||
{
|
||||
if (r == AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1,
|
||||
EHS_LOG_INT(LogType::ERR, 1,
|
||||
"The audio device, \"" + GetName_8() + "\" doesn't support the format {" +
|
||||
Str_8::FromNum(format->Format.wBitsPerSample) + "-bit, " +
|
||||
Str_8::FromNum(format->Format.nSamplesPerSec) + "Hz, " +
|
||||
@@ -154,14 +154,14 @@ namespace ehs
|
||||
);
|
||||
}
|
||||
else
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3,
|
||||
EHS_LOG_INT(LogType::ERR, 3,
|
||||
"The audio device, \"" + GetName_8() + "\" doesn't support the format {" +
|
||||
Str_8::FromNum(format->Format.wBitsPerSample) + "-bit, " +
|
||||
Str_8::FromNum(format->Format.nSamplesPerSec) + "Hz, " +
|
||||
@@ -185,78 +185,78 @@ namespace ehs
|
||||
|
||||
if (r == AUDCLNT_E_ALREADY_INITIALIZED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Audio client is already initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Audio client is already initialized.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_WRONG_ENDPOINT_TYPE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "The AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but the endpoint device is a capture device, not a rendering device.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "The AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but the endpoint device is a capture device, not a rendering device.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_BUFFER_SIZE_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "Indicates that the buffer duration value requested by an exclusive-mode client is out of range. The requested duration value for pull mode must not be greater than 5000 milliseconds; for push mode the duration value must not be greater than 2 seconds.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "Indicates that the buffer duration value requested by an exclusive-mode client is out of range. The requested duration value for pull mode must not be greater than 5000 milliseconds; for push mode the duration value must not be greater than 2 seconds.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_CPUUSAGE_EXCEEDED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_DEVICE_IN_USE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "The endpoint device is already in use. Either the device is being used in exclusive mode, or the device is being used in shared mode and the caller asked to use the device in exclusive mode.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "The endpoint device is already in use. Either the device is being used in exclusive mode, or the device is being used in shared mode and the caller asked to use the device in exclusive mode.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_ENDPOINT_CREATE_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "The method failed to create the audio endpoint for the render or the capture device. This can occur if the audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "The method failed to create the audio endpoint for the render or the capture device. This can occur if the audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_INVALID_DEVICE_PERIOD)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Indicates that the device period requested by an exclusive-mode client is greater than 5000 milliseconds.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Indicates that the device period requested by an exclusive-mode client is greater than 5000 milliseconds.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "The audio engine (shared mode) or audio endpoint device (exclusive mode) does not support the specified format.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "The audio engine (shared mode) or audio endpoint device (exclusive mode) does not support the specified format.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 13, "The caller is requesting exclusive-mode use of the endpoint device, but the user has disabled exclusive-mode use of the device.");
|
||||
EHS_LOG_INT(LogType::ERR, 13, "The caller is requesting exclusive-mode use of the endpoint device, but the user has disabled exclusive-mode use of the device.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL)
|
||||
{
|
||||
EHS_LOG_INT("Error", 14, "The AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is set but parameters hnsBufferDuration and hnsPeriodicity are not equal.");
|
||||
EHS_LOG_INT(LogType::ERR, 14, "The AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is set but parameters hnsBufferDuration and hnsPeriodicity are not equal.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_SERVICE_NOT_RUNNING)
|
||||
{
|
||||
EHS_LOG_INT("Error", 15, "The Windows audio service is not running.");
|
||||
EHS_LOG_INT(LogType::ERR, 15, "The Windows audio service is not running.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_POINTER)
|
||||
{
|
||||
EHS_LOG_INT("Error", 16, "Parameter pFormat is NULL.");
|
||||
EHS_LOG_INT(LogType::ERR, 16, "Parameter pFormat is NULL.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_INVALIDARG)
|
||||
{
|
||||
EHS_LOG_INT("Error", 17, "Parameter pFormat points to an invalid format description; or the AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but ShareMode is not equal to AUDCLNT_SHAREMODE_SHARED; or the AUDCLNT_STREAMFLAGS_CROSSPROCESS flag is set but ShareMode is equal to AUDCLNT_SHAREMODE_EXCLUSIVE.\n"
|
||||
EHS_LOG_INT(LogType::ERR, 17, "Parameter pFormat points to an invalid format description; or the AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but ShareMode is not equal to AUDCLNT_SHAREMODE_SHARED; or the AUDCLNT_STREAMFLAGS_CROSSPROCESS flag is set but ShareMode is equal to AUDCLNT_SHAREMODE_EXCLUSIVE.\n"
|
||||
"A prior call to SetClientProperties was made with an invalid category for audio/render streams.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_OUTOFMEMORY)
|
||||
{
|
||||
EHS_LOG_INT("Error", 18, "Out of memory.");
|
||||
EHS_LOG_INT(LogType::ERR, 18, "Out of memory.");
|
||||
return;
|
||||
}
|
||||
else if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace ehs
|
||||
r = client->GetService(__uuidof(IAudioRenderClient), (void**)&playbackClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ namespace ehs
|
||||
r = client->GetService(__uuidof(IAudioCaptureClient), (void**)&captureClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -282,14 +282,14 @@ namespace ehs
|
||||
r = client->GetBufferSize((UINT32*)&maxFrames);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
r = client->Start();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace ehs
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -340,9 +340,9 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = client->GetCurrentPadding(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
sampleSize = maxFrames - sampleSize;
|
||||
}
|
||||
@@ -350,9 +350,9 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = captureClient->GetNextPacketSize(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return sampleSize;
|
||||
@@ -367,19 +367,19 @@ namespace ehs
|
||||
|
||||
HRESULT r = client->GetCurrentPadding((UINT32*)&offset);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
if (playbackClient)
|
||||
{
|
||||
r = playbackClient->GetBuffer(*frames, &buffer);
|
||||
if (r == AUDCLNT_E_BUFFER_TOO_LARGE)
|
||||
EHS_LOG_INT("Error", 0, "The given frame size, " + Str_8::FromNum(*frames) + ", must be less than or equal to, " + Str_8::FromNum(maxFrames - *offset) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given frame size, " + Str_8::FromNum(*frames) + ", must be less than or equal to, " + Str_8::FromNum(maxFrames - *offset) + ".");
|
||||
else if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
else if (captureClient)
|
||||
{
|
||||
@@ -387,9 +387,9 @@ namespace ehs
|
||||
|
||||
r = captureClient->GetBuffer(&buffer, (UINT32*)frames, (DWORD*)&flags, nullptr, nullptr);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@@ -404,17 +404,17 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = playbackClient->ReleaseBuffer(frames, 0);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
else if (captureClient)
|
||||
{
|
||||
HRESULT r = captureClient->ReleaseBuffer(frames);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace ehs
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ namespace ehs
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace ehs
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace ehs
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ namespace ehs
|
||||
r = enumerator->GetDefaultAudioEndpoint((EDataFlow)type, eConsole, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace ehs
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ namespace ehs
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ namespace ehs
|
||||
r = enumerator->EnumAudioEndpoints((EDataFlow)type, (DWORD)state, &collection);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ namespace ehs
|
||||
r = collection->GetCount((UINT*)&count);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace ehs
|
||||
r = collection->Item(i, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user