summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-03-08 13:44:10 +0100
committerMax Kellermann <max@musicpd.org>2021-03-08 13:46:36 +0100
commit6a75c48dba2baacb7ca02a607f5ff80ca2f375d8 (patch)
tree08516fcb3e2b47901bf5a691f4e99c1bbda3da95 /src/output
parent48bdd09f6458b93605fd5700a6e0fe9b8ccd22aa (diff)
win32/HResult: add MakeHResultError()
None of the current FormatHResultError() callers need the format string.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/plugins/wasapi/AudioClient.hxx18
-rw-r--r--src/output/plugins/wasapi/Device.hxx18
-rw-r--r--src/output/plugins/wasapi/WasapiOutputPlugin.cxx15
3 files changed, 25 insertions, 26 deletions
diff --git a/src/output/plugins/wasapi/AudioClient.hxx b/src/output/plugins/wasapi/AudioClient.hxx
index 3ed3da319..70ec56a69 100644
--- a/src/output/plugins/wasapi/AudioClient.hxx
+++ b/src/output/plugins/wasapi/AudioClient.hxx
@@ -33,8 +33,8 @@ GetBufferSizeInFrames(IAudioClient &client)
HRESULT result = client.GetBufferSize(&buffer_size_in_frames);
if (FAILED(result))
- throw FormatHResultError(result,
- "Unable to get audio client buffer size");
+ throw MakeHResultError(result,
+ "Unable to get audio client buffer size");
return buffer_size_in_frames;
}
@@ -46,8 +46,8 @@ GetCurrentPaddingFrames(IAudioClient &client)
HRESULT result = client.GetCurrentPadding(&padding_frames);
if (FAILED(result))
- throw FormatHResultError(result,
- "Failed to get current padding");
+ throw MakeHResultError(result,
+ "Failed to get current padding");
return padding_frames;
}
@@ -59,7 +59,7 @@ GetMixFormat(IAudioClient &client)
HRESULT result = client.GetMixFormat(&f);
if (FAILED(result))
- throw FormatHResultError(result, "GetMixFormat failed");
+ throw MakeHResultError(result, "GetMixFormat failed");
return ComHeapPtr{f};
}
@@ -69,7 +69,7 @@ Start(IAudioClient &client)
{
HRESULT result = client.Start();
if (FAILED(result))
- throw FormatHResultError(result, "Failed to start client");
+ throw MakeHResultError(result, "Failed to start client");
}
inline void
@@ -77,7 +77,7 @@ Stop(IAudioClient &client)
{
HRESULT result = client.Stop();
if (FAILED(result))
- throw FormatHResultError(result, "Failed to stop client");
+ throw MakeHResultError(result, "Failed to stop client");
}
inline void
@@ -85,7 +85,7 @@ SetEventHandle(IAudioClient &client, HANDLE h)
{
HRESULT result = client.SetEventHandle(h);
if (FAILED(result))
- throw FormatHResultError(result, "Unable to set event handle");
+ throw MakeHResultError(result, "Unable to set event handle");
}
template<typename T>
@@ -95,7 +95,7 @@ GetService(IAudioClient &client)
T *p = nullptr;
HRESULT result = client.GetService(IID_PPV_ARGS(&p));
if (FAILED(result))
- throw FormatHResultError(result, "Unable to get service");
+ throw MakeHResultError(result, "Unable to get service");
return ComPtr{p};
}
diff --git a/src/output/plugins/wasapi/Device.hxx b/src/output/plugins/wasapi/Device.hxx
index 863f327a7..87663c0dc 100644
--- a/src/output/plugins/wasapi/Device.hxx
+++ b/src/output/plugins/wasapi/Device.hxx
@@ -33,8 +33,8 @@ GetDefaultAudioEndpoint(IMMDeviceEnumerator &e)
HRESULT result = e.GetDefaultAudioEndpoint(eRender, eMultimedia,
&device);
if (FAILED(result))
- throw FormatHResultError(result,
- "Unable to get default device for multimedia");
+ throw MakeHResultError(result,
+ "Unable to get default device for multimedia");
return ComPtr{device};
}
@@ -47,7 +47,7 @@ EnumAudioEndpoints(IMMDeviceEnumerator &e)
HRESULT result = e.EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE,
&dc);
if (FAILED(result))
- throw FormatHResultError(result, "Unable to enumerate devices");
+ throw MakeHResultError(result, "Unable to enumerate devices");
return ComPtr{dc};
}
@@ -59,7 +59,7 @@ GetCount(IMMDeviceCollection &dc)
HRESULT result = dc.GetCount(&count);
if (FAILED(result))
- throw FormatHResultError(result, "Collection->GetCount failed");
+ throw MakeHResultError(result, "Collection->GetCount failed");
return count;
}
@@ -71,7 +71,7 @@ Item(IMMDeviceCollection &dc, UINT i)
auto result = dc.Item(i, &device);
if (FAILED(result))
- throw FormatHResultError(result, "Collection->Item failed");
+ throw MakeHResultError(result, "Collection->Item failed");
return ComPtr{device};
}
@@ -83,7 +83,7 @@ GetState(IMMDevice &device)
HRESULT result = device.GetState(&state);;
if (FAILED(result))
- throw FormatHResultError(result, "Unable to get device status");
+ throw MakeHResultError(result, "Unable to get device status");
return state;
}
@@ -96,7 +96,7 @@ Activate(IMMDevice &device)
HRESULT result = device.Activate(__uuidof(T), CLSCTX_ALL,
nullptr, (void **)&p);
if (FAILED(result))
- throw FormatHResultError(result, "Unable to activate device");
+ throw MakeHResultError(result, "Unable to activate device");
return ComPtr{p};
}
@@ -108,8 +108,8 @@ OpenPropertyStore(IMMDevice &device)
HRESULT result = device.OpenPropertyStore(STGM_READ, &property_store);
if (FAILED(result))
- throw FormatHResultError(result,
- "Device->OpenPropertyStore failed");
+ throw MakeHResultError(result,
+ "Device->OpenPropertyStore failed");
return ComPtr{property_store};
}
diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
index f9dfb5429..f49d9748b 100644
--- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
@@ -336,7 +336,7 @@ void WasapiOutputThread::Work() noexcept {
if (HRESULT result =
render_client->GetBuffer(write_in_frames, &data);
FAILED(result)) {
- throw FormatHResultError(result, "Failed to get buffer");
+ throw MakeHResultError(result, "Failed to get buffer");
}
AtScopeExit(&) {
@@ -457,7 +457,7 @@ void WasapiOutput::DoOpen(AudioFormat &audio_format) {
if (HRESULT result =
client->GetDevicePeriod(&default_device_period, &min_device_period);
FAILED(result)) {
- throw FormatHResultError(result, "Unable to get device period");
+ throw MakeHResultError(result, "Unable to get device period");
}
FormatDebug(wasapi_output_domain,
"Default device period: %I64u ns, Minimum device period: "
@@ -505,8 +505,7 @@ void WasapiOutput::DoOpen(AudioFormat &audio_format) {
}
if (FAILED(result)) {
- throw FormatHResultError(
- result, "Unable to initialize audio client");
+ throw MakeHResultError(result, "Unable to initialize audio client");
}
}
} else {
@@ -515,8 +514,8 @@ void WasapiOutput::DoOpen(AudioFormat &audio_format) {
buffer_duration, 0,
reinterpret_cast<WAVEFORMATEX *>(&device_format), nullptr);
FAILED(result)) {
- throw FormatHResultError(result,
- "Unable to initialize audio client");
+ throw MakeHResultError(result,
+ "Unable to initialize audio client");
}
}
@@ -773,7 +772,7 @@ void WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format) {
}
if (FAILED(result) && result != AUDCLNT_E_UNSUPPORTED_FORMAT) {
- throw FormatHResultError(result, "IsFormatSupported failed");
+ throw MakeHResultError(result, "IsFormatSupported failed");
}
switch (result) {
@@ -802,7 +801,7 @@ void WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format) {
result_string.c_str());
}
if (FAILED(result)) {
- throw FormatHResultError(result, "Format is not supported");
+ throw MakeHResultError(result, "Format is not supported");
}
break;
case S_FALSE: