From 3d3422f9b952dd43bcb6b3d23a952b169fa1cf68 Mon Sep 17 00:00:00 2001 From: "rafael@riseup.net" Date: Mon, 19 Jul 2010 21:05:31 +0000 Subject: [PATCH] darkice macosx in sync with trunk --- darkice/branches/darkice-macosx/ChangeLog | 27 ++++++++++++------- darkice/branches/darkice-macosx/darkice.cfg | 2 ++ .../branches/darkice-macosx/man/darkice.cfg.5 | 4 +++ .../branches/darkice-macosx/src/DarkIce.cpp | 15 +++++++++-- darkice/branches/darkice-macosx/src/DarkIce.h | 5 ++++ .../darkice-macosx/src/JackDspSource.cpp | 2 +- 6 files changed, 43 insertions(+), 12 deletions(-) diff --git a/darkice/branches/darkice-macosx/ChangeLog b/darkice/branches/darkice-macosx/ChangeLog index 619620e..6140c5a 100644 --- a/darkice/branches/darkice-macosx/ChangeLog +++ b/darkice/branches/darkice-macosx/ChangeLog @@ -1,14 +1,23 @@ -Next release - o fixed a bug in BufferedSink.cpp that leads to some buffers - being written twice, causing corruption of datastream, - thanks to Edwin van den Oetelaar - o implemented samplerate conversion for all codecs using libsamplerate, - and keeping internal aflibConverter as fallback, - thanks to Sergiy - o bugfix: fix for alsa driver - closes ticked #8 - thanks to Clemens Ladisch +Darkice next release + o Added rtprio parameter and revisited realtime priority + closes ticket #21 + thanks to Cheerio + o Fixed a call to a deprecated jack call + closes ticket #22 + thanks to Cheerio again. o Implemented CoreAudio driver for MacOS X +09-05-2010 Darkice 1.0 released + o fixed a bug in BufferedSink.cpp that leads to some buffers + being written twice, causing corruption of datastream, + closes ticked #20 + thanks to Edwin van den Oetelaar + o implemented samplerate conversion for all codecs using libsamplerate, + and keeping internal aflibConverter as fallback, + thanks to Sergiy + o bugfix: fix for alsa driver - closes ticked #8 + thanks to Clemens Ladisch + 14-11-2009 Darkice 0.20.1 released o added rc.darkice init script thanks to Niels Dettenbach diff --git a/darkice/branches/darkice-macosx/darkice.cfg b/darkice/branches/darkice-macosx/darkice.cfg index 0c7f935..4ccf1c6 100644 --- a/darkice/branches/darkice-macosx/darkice.cfg +++ b/darkice/branches/darkice-macosx/darkice.cfg @@ -6,6 +6,8 @@ duration = 60 # duration of encoding, in seconds. 0 means forever bufferSecs = 5 # size of internal slip buffer, in seconds reconnect = yes # reconnect to the server(s) if disconnected +realtime = yes # run the encoder with POSIX realtime priority +rtprio = 3 # scheduling priority for the realtime threads # this section describes the audio input that will be streamed [input] diff --git a/darkice/branches/darkice-macosx/man/darkice.cfg.5 b/darkice/branches/darkice-macosx/man/darkice.cfg.5 index 37ffba9..18396c6 100644 --- a/darkice/branches/darkice-macosx/man/darkice.cfg.5 +++ b/darkice/branches/darkice-macosx/man/darkice.cfg.5 @@ -62,6 +62,10 @@ streaming, "yes" or "no". (optional parameter, defaults to "yes") .I realtime Use POSIX realtime scheduling, "yes" or "no". (optional parameter, defaults to "yes") +.TP +.I rtprio +Scheduling priority for the realtime threads. +(optional parameter, defaults to 4) .PP diff --git a/darkice/branches/darkice-macosx/src/DarkIce.cpp b/darkice/branches/darkice-macosx/src/DarkIce.cpp index 88e74cd..c48c298 100644 --- a/darkice/branches/darkice-macosx/src/DarkIce.cpp +++ b/darkice/branches/darkice-macosx/src/DarkIce.cpp @@ -164,6 +164,13 @@ DarkIce :: init ( const Config & config ) throw ( Exception ) str = cs->get( "realtime" ); enableRealTime = str ? (Util::strEq( str, "yes") ? true : false) : true; + // get realtime scheduling priority. If unspecified, set it to 4. + // Why 4? jackd's default priority is 10, jackd client threads run + // at 5, so make the encoder thread use 4. jackd automatically sets + // the process callback priority to the right value, so all we have + // to care about is the encoder priority. + str = cs->get( "rtprio" ); + realTimeSchedPriority = (str != NULL) ? Util::strToL( str ) : 4; // the [input] section if ( !(cs = config.get( "input")) ) { @@ -1111,13 +1118,17 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception ) } origSchedPriority = param.sched_priority; - /* set SCHED_FIFO with max - 1 priority */ + /* set SCHED_FIFO with max - 1 priority or user configured value */ if ( (high_priority = sched_get_priority_max(SCHED_FIFO)) == -1 ) { throw Exception(__FILE__,__LINE__,"sched_get_priority_max",errno); } reportEvent( 8, "scheduler high priority", high_priority); - param.sched_priority = high_priority - 1; + if (realTimeSchedPriority > high_priority) { + param.sched_priority = high_priority - 1; + } else { + param.sched_priority = realTimeSchedPriority; + } if ( sched_setscheduler( 0, SCHED_FIFO, ¶m) == -1 ) { reportEvent( 1, diff --git a/darkice/branches/darkice-macosx/src/DarkIce.h b/darkice/branches/darkice-macosx/src/DarkIce.h index f8f1f21..4f9ee96 100644 --- a/darkice/branches/darkice-macosx/src/DarkIce.h +++ b/darkice/branches/darkice-macosx/src/DarkIce.h @@ -124,6 +124,11 @@ class DarkIce : public virtual Referable, public virtual Reporter */ int enableRealTime; + /** + * Scheduling priority for the realtime threads + */ + int realTimeSchedPriority; + /** * Original scheduling policy */ diff --git a/darkice/branches/darkice-macosx/src/JackDspSource.cpp b/darkice/branches/darkice-macosx/src/JackDspSource.cpp index f2cb5f6..14fcd66 100644 --- a/darkice/branches/darkice-macosx/src/JackDspSource.cpp +++ b/darkice/branches/darkice-macosx/src/JackDspSource.cpp @@ -206,7 +206,7 @@ JackDspSource :: open ( void ) throw ( Exception ) snprintf(client_name, 255, "darkice-%d", getpid()); } - if ((client = jack_client_new(client_name)) == NULL) { + if ((client = jack_client_open(client_name, (jack_options_t)0, NULL)) == NULL) { throw Exception( __FILE__, __LINE__, "JACK server not running?"); } Reporter::reportEvent( 1, "Registering as JACK client", client_name);