Hello mpd developers, after using mpd for quite some time I would like to contribute a little to its development.
Under certain circumstances, on linux systems OutputThread fails to get realtime scheduling. I think it would be useful to inform the user when this happens. Therefore I'm submitting 2 patches. Patch 1/2. Check the return value of sched_setscheduler() in SetThreadRealtime. Report to the caller, if we were successful. To this end SetThreadRealtime now returns false, if ached_setschedluer failed or true on all other cases. On non-linux systems SetThreadRealtime does not do anything and will always return true. Patch 2/2. In OutputThread (seems to be the only caller of SetThreadRelatime) the return value is checked. If SetThreadRealtime failed, a warning is logged using LogWarning. I decide to put LogWarning here, since the caller of SetThreadRealtime should decide how to handle this. Please let me know what you think about this. Best, Christian Halaszovich --- src/thread/Util.hxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread/Util.hxx b/src/thread/Util.hxx index ff8dbbe..5e63e44 100644 --- a/src/thread/Util.hxx +++ b/src/thread/Util.hxx @@ -81,10 +81,12 @@ SetThreadIdlePriority() /** * Raise the current thread's priority to "real-time" (very high). + * return value: true on success */ -static inline void +static inline bool SetThreadRealtime() { + bool success = true; #ifdef __linux__ struct sched_param sched_param; sched_param.sched_priority = 50; @@ -94,8 +96,9 @@ SetThreadRealtime() policy |= SCHED_RESET_ON_FORK; #endif - sched_setscheduler(0, policy, &sched_param); + success = 0==sched_setscheduler(0, policy, &sched_param); #endif + return success; // on non-linux machines we will always pretend it worked }; #endif -- 1.9.1
_______________________________________________ mpd-devel mailing list mpd-devel@musicpd.org http://mailman.blarg.de/listinfo/mpd-devel