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
12091fcf
Commit
12091fcf
authored
Sep 04, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/Util: throw exception on error
parent
5598826e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
23 deletions
+17
-23
OutputThread.cxx
src/output/OutputThread.cxx
+8
-5
Util.cxx
src/thread/Util.cxx
+5
-12
Util.hxx
src/thread/Util.hxx
+4
-6
No files found.
src/output/OutputThread.cxx
View file @
12091fcf
...
...
@@ -40,6 +40,8 @@
#include "Log.hxx"
#include "Compiler.h"
#include <stdexcept>
#include <assert.h>
#include <string.h>
...
...
@@ -597,12 +599,13 @@ AudioOutput::Task()
{
FormatThreadName
(
"output:%s"
,
name
);
Error
error
;
if
(
!
SetThreadRealtime
(
error
))
{
LogError
(
error
);
Log
Warning
(
output_domain
,
"OutputThread could not get realtime scheduling, continuing anyway"
);
try
{
SetThreadRealtime
();
}
catch
(
const
std
::
runtime_error
&
e
)
{
Log
Error
(
e
,
"OutputThread could not get realtime scheduling, continuing anyway"
);
}
SetThreadTimerSlackUS
(
100
);
mutex
.
lock
();
...
...
src/thread/Util.cxx
View file @
12091fcf
...
...
@@ -27,9 +27,8 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Util.hxx"
#include "
util
/Error.hxx"
#include "
system
/Error.hxx"
#ifdef __linux__
#include <sched.h>
...
...
@@ -77,8 +76,8 @@ SetThreadIdlePriority()
#endif
};
bool
SetThreadRealtime
(
Error
&
error
)
void
SetThreadRealtime
()
{
#ifdef __linux__
struct
sched_param
sched_param
;
...
...
@@ -89,13 +88,7 @@ SetThreadRealtime(Error& error)
policy
|=
SCHED_RESET_ON_FORK
;
#endif
if
(
sched_setscheduler
(
0
,
policy
,
&
sched_param
)
==
0
)
{
return
true
;
}
else
{
error
.
FormatErrno
(
"sched_setscheduler failed"
);
return
false
;
}
#else
return
true
;
// on non-linux systems, we pretend it worked
if
(
sched_setscheduler
(
0
,
policy
,
&
sched_param
)
<
0
)
throw
MakeErrno
(
"sched_setscheduler failed"
);
#endif // __linux__
};
src/thread/Util.hxx
View file @
12091fcf
...
...
@@ -30,8 +30,6 @@
#ifndef THREAD_UTIL_HXX
#define THREAD_UTIL_HXX
class
Error
;
/**
* Lower the current thread's priority to "idle" (very low).
*/
...
...
@@ -40,10 +38,10 @@ SetThreadIdlePriority();
/**
* Raise the current thread's priority to "real-time" (very high).
*
@param[out] error Receives error information on failure
*
@return true on success (always true on non-linux systems)
*
*
Throws std::system_error on error.
*/
bool
SetThreadRealtime
(
Error
&
error
);
void
SetThreadRealtime
();
#endif
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