Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6a75c48d
Commit
6a75c48d
authored
4 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32/HResult: add MakeHResultError()
None of the current FormatHResultError() callers need the format string.
parent
48bdd09f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
35 deletions
+41
-35
WasapiMixerPlugin.cxx
src/mixer/plugins/WasapiMixerPlugin.cxx
+6
-6
AudioClient.hxx
src/output/plugins/wasapi/AudioClient.hxx
+9
-9
Device.hxx
src/output/plugins/wasapi/Device.hxx
+9
-9
WasapiOutputPlugin.cxx
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+7
-8
Com.hxx
src/win32/Com.hxx
+2
-2
ComPtr.hxx
src/win32/ComPtr.hxx
+1
-1
HResult.hxx
src/win32/HResult.hxx
+7
-0
No files found.
src/mixer/plugins/WasapiMixerPlugin.cxx
View file @
6a75c48d
...
...
@@ -59,9 +59,9 @@ public:
result
=
endpoint_volume
->
GetMasterVolumeLevelScalar
(
&
volume_level
);
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
result
,
"Unable to get master "
"volume level"
);
throw
Make
HResultError
(
result
,
"Unable to get master "
"volume level"
);
}
}
else
{
auto
session_volume
=
...
...
@@ -69,7 +69,7 @@ public:
result
=
session_volume
->
GetMasterVolume
(
&
volume_level
);
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
throw
Make
HResultError
(
result
,
"Unable to get master volume"
);
}
}
...
...
@@ -95,7 +95,7 @@ public:
result
=
endpoint_volume
->
SetMasterVolumeLevelScalar
(
volume_level
,
nullptr
);
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
throw
Make
HResultError
(
result
,
"Unable to set master volume level"
);
}
...
...
@@ -106,7 +106,7 @@ public:
result
=
session_volume
->
SetMasterVolume
(
volume_level
,
nullptr
);
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
throw
Make
HResultError
(
result
,
"Unable to set master volume"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/output/plugins/wasapi/AudioClient.hxx
View file @
6a75c48d
...
...
@@ -33,8 +33,8 @@ GetBufferSizeInFrames(IAudioClient &client)
HRESULT
result
=
client
.
GetBufferSize
(
&
buffer_size_in_frames
);
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Unable to get audio client buffer size"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Failed to get current padding"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"GetMixFormat failed"
);
throw
Make
HResultError
(
result
,
"GetMixFormat failed"
);
return
ComHeapPtr
{
f
};
}
...
...
@@ -69,7 +69,7 @@ Start(IAudioClient &client)
{
HRESULT
result
=
client
.
Start
();
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Failed to start client"
);
throw
Make
HResultError
(
result
,
"Failed to start client"
);
}
inline
void
...
...
@@ -77,7 +77,7 @@ Stop(IAudioClient &client)
{
HRESULT
result
=
client
.
Stop
();
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Failed to stop client"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to set event handle"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to get service"
);
throw
Make
HResultError
(
result
,
"Unable to get service"
);
return
ComPtr
{
p
};
}
...
...
This diff is collapsed.
Click to expand it.
src/output/plugins/wasapi/Device.hxx
View file @
6a75c48d
...
...
@@ -33,8 +33,8 @@ GetDefaultAudioEndpoint(IMMDeviceEnumerator &e)
HRESULT
result
=
e
.
GetDefaultAudioEndpoint
(
eRender
,
eMultimedia
,
&
device
);
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Unable to get default device for multimedia"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to enumerate devices"
);
throw
Make
HResultError
(
result
,
"Unable to enumerate devices"
);
return
ComPtr
{
dc
};
}
...
...
@@ -59,7 +59,7 @@ GetCount(IMMDeviceCollection &dc)
HRESULT
result
=
dc
.
GetCount
(
&
count
);
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Collection->GetCount failed"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Collection->Item failed"
);
throw
Make
HResultError
(
result
,
"Collection->Item failed"
);
return
ComPtr
{
device
};
}
...
...
@@ -83,7 +83,7 @@ GetState(IMMDevice &device)
HRESULT
result
=
device
.
GetState
(
&
state
);;
if
(
FAILED
(
result
))
throw
Format
HResultError
(
result
,
"Unable to get device status"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to activate device"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Device->OpenPropertyStore failed"
);
throw
Make
HResultError
(
result
,
"Device->OpenPropertyStore failed"
);
return
ComPtr
{
property_store
};
}
...
...
This diff is collapsed.
Click to expand it.
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
View file @
6a75c48d
...
...
@@ -336,7 +336,7 @@ void WasapiOutputThread::Work() noexcept {
if
(
HRESULT
result
=
render_client
->
GetBuffer
(
write_in_frames
,
&
data
);
FAILED
(
result
))
{
throw
Format
HResultError
(
result
,
"Failed to get buffer"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to get device period"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"Unable to initialize audio client"
);
throw
Make
HResultError
(
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
Format
HResultError
(
result
,
"IsFormatSupported failed"
);
throw
Make
HResultError
(
result
,
"IsFormatSupported failed"
);
}
switch
(
result
)
{
...
...
@@ -802,7 +801,7 @@ void WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format) {
result_string
.
c_str
());
}
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
result
,
"Format is not supported"
);
throw
Make
HResultError
(
result
,
"Format is not supported"
);
}
break
;
case
S_FALSE
:
...
...
This diff is collapsed.
Click to expand it.
src/win32/Com.hxx
View file @
6a75c48d
...
...
@@ -31,7 +31,7 @@ public:
COM
()
{
if
(
HRESULT
result
=
CoInitializeEx
(
nullptr
,
COINIT_MULTITHREADED
);
FAILED
(
result
))
{
throw
Format
HResultError
(
throw
Make
HResultError
(
result
,
"Unable to initialize COM with COINIT_MULTITHREADED"
);
}
...
...
@@ -39,7 +39,7 @@ public:
COM
(
bool
)
{
if
(
HRESULT
result
=
CoInitializeEx
(
nullptr
,
COINIT_APARTMENTTHREADED
);
FAILED
(
result
))
{
throw
Format
HResultError
(
throw
Make
HResultError
(
result
,
"Unable to initialize COM with COINIT_APARTMENTTHREADED"
);
}
...
...
This diff is collapsed.
Click to expand it.
src/win32/ComPtr.hxx
View file @
6a75c48d
...
...
@@ -85,7 +85,7 @@ public:
::
CoCreateInstance
(
class_id
,
unknown_outer
,
class_context
,
__uuidof
(
T
),
reinterpret_cast
<
void
**>
(
&
ptr
));
if
(
FAILED
(
result
))
{
throw
Format
HResultError
(
result
,
"Unable to create instance"
);
throw
Make
HResultError
(
result
,
"Unable to create instance"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/win32/HResult.hxx
View file @
6a75c48d
...
...
@@ -74,6 +74,13 @@ static inline const std::error_category &hresult_category() noexcept {
return
hresult_category_instance
;
}
inline
std
::
system_error
MakeHResultError
(
HRESULT
result
,
const
char
*
msg
)
noexcept
{
return
std
::
system_error
(
std
::
error_code
(
result
,
hresult_category
()),
msg
);
}
gcc_printf
(
2
,
3
)
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment