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
8da3f8c6
Commit
8da3f8c6
authored
Aug 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/oss: oss_try_ioctl() throws on EINVAL
Eliminate some duplicate code.
parent
c8c553c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
OssOutputPlugin.cxx
src/output/plugins/OssOutputPlugin.cxx
+12
-18
No files found.
src/output/plugins/OssOutputPlugin.cxx
View file @
8da3f8c6
...
...
@@ -255,14 +255,16 @@ oss_try_ioctl_r(FileDescriptor fd, unsigned long request, int *value_r,
* Invoke an ioctl on the OSS file descriptor.
*
* Throws on error.
*
* @return true success, false if the parameter is not supported
*/
static
bool
static
void
oss_try_ioctl
(
FileDescriptor
fd
,
unsigned
long
request
,
int
value
,
const
char
*
msg
)
{
return
oss_try_ioctl_r
(
fd
,
request
,
&
value
,
msg
);
assert
(
fd
.
IsDefined
());
assert
(
msg
!=
nullptr
);
if
(
ioctl
(
fd
.
Get
(),
request
,
&
value
)
<
0
)
throw
MakeErrno
(
msg
);
}
/**
...
...
@@ -527,20 +529,12 @@ try {
if
(
!
fd
.
Open
(
device
,
O_WRONLY
))
throw
FormatErrno
(
"Error opening OSS device
\"
%s
\"
"
,
device
);
const
char
*
const
msg1
=
"Failed to set channel count"
;
if
(
!
oss_try_ioctl
(
fd
,
SNDCTL_DSP_CHANNELS
,
audio_format
.
channels
,
msg1
))
throw
std
::
runtime_error
(
msg1
);
const
char
*
const
msg2
=
"Failed to set sample rate"
;
if
(
!
oss_try_ioctl
(
fd
,
SNDCTL_DSP_SPEED
,
audio_format
.
sample_rate
,
msg2
))
throw
std
::
runtime_error
(
msg2
);
const
char
*
const
msg3
=
"Failed to set sample format"
;
if
(
!
oss_try_ioctl
(
fd
,
SNDCTL_DSP_SAMPLESIZE
,
oss_format
,
msg3
))
throw
std
::
runtime_error
(
msg3
);
oss_try_ioctl
(
fd
,
SNDCTL_DSP_CHANNELS
,
audio_format
.
channels
,
"Failed to set channel count"
);
oss_try_ioctl
(
fd
,
SNDCTL_DSP_SPEED
,
audio_format
.
sample_rate
,
"Failed to set sample rate"
);
oss_try_ioctl
(
fd
,
SNDCTL_DSP_SAMPLESIZE
,
oss_format
,
"Failed to set sample format"
);
}
catch
(...)
{
DoClose
();
throw
;
...
...
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