Hi!
I am trying to notify a high priority (nice -20 or nice -19) thread from
a realtime thread (from a jack callback to be precise). Of course I want
the realtime thread to not block, but I want the high priority thread to
react as soon as possible. For the first implementation, I used a
condition, and pthread_cond_signal. But as I can't aquire a mutex within
the realtime thread, at least not always (at most with trylock()), this
results in racy code.
Also, it doesn't integrate well with poll(), which the high priority
process should be able to use. So basically I want to switch to a pipe
write() instead of pthread_cond_signal.
Now the question is: am I producing priority inversion, then? I've seen
that the kernel code of pipe write has code like
mutex_lock(PIPE_MUTEX(*inode));
(in fs/pipe.c, linux-2.6.16.16), so can this mutex cause priority
inversion?
However, on the other hand, I examined the code of
glibc-2.3.6/ntpl/sysdeps/pthread, and found in pthread_cond_signal.c:
__pthread_cond_signal (cond)
pthread_cond_t *cond;
{
/* Make sure we are alone. */
lll_mutex_lock (cond->__data.__lock);
/* Are there any waiters to be woken? */
if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
{
/* Yes. Mark one of them as woken. */
++cond->__data.__wakeup_seq;
++cond->__data.__futex;
/* Wake one. */
lll_futex_wake (&cond->__data.__futex, 1);
}
/* We are done. */
lll_mutex_unlock (cond->__data.__lock);
return 0;
}
So it looks like there is some kind of low level mutex locking involved
even when signalling a condition. Can't this also lead to priority
inversion?
So what is the best way to achieve that some lower priority thread will
definitely wakeup from a realtime priority thread, without causing
priority inversion, under recent linux kernels?
Cu... Stefan
--
Stefan Westerfeld, Hamburg/Germany, http://space.twc.de/~stefan
Hello,
I am looking for a cross-platform implementation of an atomic
integer.
Under Linux, a build an c++ class "atomic" around asm/atomic.h,
(which I can use as if it where an int), but I'd like to have a
solution that also works on Windows XP and Mac OS X.
Thanks for any suggestions,
Maarten
> > In any case, Linux Sampler and Kontakt are
> > different sorts of samplers at this point. Linux Sampler is more in the spirit
> > of Gigasampler, and Kontakt is more like an emulation of a hardware sampler (but
> > vastly more flexible).
>
> The key words there are "at this point." As noted, the *long-term*
> potential of Linux Sampler is probably still much greater than Kontakt-in-wine.
Agreed. Maybe time is best spent improving linux sampler. Then again, good VST
has benefits, although I do see how it may hurt the long term goals of free
software. I'm just not sure if the best way to help free software is to limit
it's ability to integrate with proprietary software.
> >
> > Noted. However, I remain unconvinced that Linux Sampler is intended to be a
> > drop-in replacement for something like Kontakt.
>
> I don't think it's intended to be a drop-in replacement for Kontakt; I
> think it's just intended to be cool.
I can appreciate that.
-Forest
http://ccrma.stanford.edu/~kjetil/src/
jack_capture
*************************************************************************
jack_capture is a small program to capture whatever sound is going out to
your speakers into a file without having to patch jack connections, fiddle
around with fileformats, or set options on the argument line.
This is the program I always wanted to have for jack, but no
one made. So here it is.
Changes 0.2.4 -> 0.3.1:
-----------------------
*Reduced CPU usage a lot because of better disk handling. (25% -> 1%)
*Make sure the rest of the recorded file is not garbage in case of an
overrun.
*Added the port argument, which can be specified many times and accepts
both input and output port names (including regexp expressions). This
makes jack_capture to completely replace jackrec.
*Rewrote buffer handling. Silence is now inserted when underruns occure.
Previously, the file became shorter than the recording in case of
underrun. It can still happen though, but much more seldom, and a
warning about that will be printed to the terminal.
*Last rests of jackrec code has been rewritten. Well, all the code with
substance, at least.
*Nicified code a lot.
*More efficient way of handling overruns.
*Fixed really stupid compilation error. Thanks to Dragan Noveski for
spotting it.
das_watchdog
*************************************************************************
Whenever a program locks up the machine, das_watchdog will temporarily
sets all realtime process to non-realtime for 8 seconds. You will get an
xmessage window up on the screen whenever that happens.
Changes 0.2.2->0.2.3
--------------------
*Fixed commandline arguments for increasetime, checktime and waittime.
*Nicified source a bit
Mammut
*************************************************************************
Mammut will FFT your sound in one single gigantic analysis (no windows).
These spectral data, where the development in time is incorporated in
mysterious ways, may then be transformed by different algorithms prior to
resynthesis. An interesting aspect of Mammut is its completely
non-intuitive sound transformation approach.
Changes 0.21->0.22
------------------
*Added patch and instructions from Owen Green on how to make mammut
compile on OSX. Thanks! (Sorry, I forgot to release this version for
almost a year...)
A bit late, but maybe still of interest.
A number of pictures from LAC2006 may be downloaded from
<URL: www.q2s.ntnu.no/~asbjs/pictures_lac2006_asbjorn-sabo.tar >.
(The file is around 9MB.)
* netjack workshop
* Linux sound night
* various
With thanks for and interesting conference and nice company there!
Asbjørn Sæbø
james(a)dis-dot-dat.net wrote:
>Howdy peeps.
>
>Not really much of a release, so not much fanfare, but in the
>interests of sharing effort I give you...
>
>Powernap!
>
>http://dis-dot-dat.net/?item=code/powernap/
>
>If, like me, you need to drive an app from a Python interface,
>powernap can help. It's a small extension that switches to the
>real-time scheduler and provides two handy sleep-like functions:
>
>nap() naps for a given number of milliseconds, timed with the RTC
>
>rnap() is a "rolling nap" that tries to make the time between calls
>the given number of milliseconds. A padding nap, if you will.
>
>It works for me and it might come in handy for someone else.
Nice, this will definitely come in handy for me.
Have you done any benchmarking on what kind of timing precision you can
get?
-DR-
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Oi,
I am currently writing on a modular synth with great emphasis on
sequencing (but allowing tight interaction between both parts)
in a comparable modular way (pattern creation/algortihmic
composition/chord filters etc),
I wrote some parts of the core of the application but I am not really
keen on coding something that has been done several times before;
that's why I thought about
joining/"forking" a more complete modular synthesizing environment and
adding the core components I need/have. The point is, that I don't
know enough about
the existant modular synthesizers to evaluate how modular their
sourcecode is written so that my modifications are easily applicable
in their source.
Here are some parts/functionalities that I already have (partially)
implemented and would like to add to the core:
- - the main graph of interconnected modules supports heterogene module
types for example it could support FAUST code-pieces represented in
modules as well as ladspa-modules,
the subgraph created by interconnected modules of the same type is the
sent to the type-specific "compiler" creating executable signal paths
- - the executable graph of interconnected modules is analyzed and split
up in parts that can be executed in parallel, locks in the necessary
parts are added and the whole graph can be
executed in several threads
- - modules are mainly connected using a zoomable patch-matrix; the
zoomlevel corresponds to the level of typing (of connections)
As I mainly write QT-Applications I'd prefer a project that can be
either easily extended to use QT or which already uses it. I think it
is better to work on an existing project, since
I am currently busy with releasing an album and university-shiznit and
I can not imagine doing everything in a prolific way in parallel.
Thanks in advance for any input!
So long...
Niklas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEq/F++k24EnBNzsMRAlNrAJ97l5nZeqM8B86w4FDrh34joLvZEQCeOxpn
1VD/QOT47Nfd2X6kEItBFRw=
=jz9s
-----END PGP SIGNATURE-----
Howdy peeps.
Not really much of a release, so not much fanfare, but in the
interests of sharing effort I give you...
Powernap!
http://dis-dot-dat.net/?item=code/powernap/
If, like me, you need to drive an app from a Python interface,
powernap can help. It's a small extension that switches to the
real-time scheduler and provides two handy sleep-like functions:
nap() naps for a given number of milliseconds, timed with the RTC
rnap() is a "rolling nap" that tries to make the time between calls
the given number of milliseconds. A padding nap, if you will.
It works for me and it might come in handy for someone else.
James
Hi everybody!
I am a newbie to alsa programming.
I am trying to follow the article which locates at
http://www.suse.de/~mana/alsa090_howto.html to develop a playback program.
My code here:
snd_pcm_t*pcm_handle;
unsigned int rate = 8000;
// Sample rate returned by
// snd_pcm_hw_params_set_rate_near
int exact_rate;
// exact_rate == rate ----> dir =0
//exact_rate < rate ----> dir =-1
//exact_rate > rate ----> dir =1
int dir = 0;
// Number of periods
int periods = 2;
snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
// This structure contains information about the hardware
//and can be used to specify the configuration to be used for the
PCM stream.
snd_pcm_hw_params_t *hwparams;
// Name of the PCM device, like plughw:0,0
//The first number is the number of the soundcard,
//the second number is the number of the device.
char *pcm_name;
// Init pcm_name. Of course, later you
//will make this configurable ;-)
pcm_name = strdup("plughw:0,0");
printf("Device name:%s\n",pcm_name);
//Allocate the snd_pcm_hw_params_t structure on the stack.
snd_pcm_hw_params_alloca(&hwparams);
// Open PCM. The last parameter of this function is the mode.
// If this is set to 0, the standard mode is used. Possible
// other values are SND_PCM_NONBLOCK and SND_PCM_ASYNC.
// If SND_PCM_NONBLOCK is used, read / write access to the
// PCM device will return immediately. If SND_PCM_ASYNC is
// specified, SIGIO will be emitted whenever a period has
//been completely processed by the soundcard.
if (snd_pcm_open(&pcm_handle, pcm_name, stream, 0) <
0){//SND_PCM_NONBLOCK
fprintf(stderr, "Error opening PCM device %s\n", pcm_name);
return;
}
// Init hwparams with full configuration space
if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
fprintf(stderr, "Can not configure this PCM device.\n");
return;
}
// Set access type. This can be either
SND_PCM_ACCESS_RW_INTERLEAVED or
// SND_PCM_ACCESS_RW_NONINTERLEAVED.There are also access types for
// MMAPed access, but this is beyond the scope of this introduction.
if (snd_pcm_hw_params_set_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {
fprintf(stderr, "Error setting access.\n");
return;
}
//Set sample format
if (snd_pcm_hw_params_set_format(pcm_handle, hwparams,
SND_PCM_FORMAT_S16_LE) < 0) {
fprintf(stderr, "Error setting format.\n");
return;
}
// Set sample rate. If the exact rate is not supported by the
hardware, use nearest possible rate.
exact_rate = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams,
&rate, &dir);
if (exact_rate < 0) {
fprintf(stderr, "Error setting rate.\n");
return;
}
if (rate != exact_rate) {
fprintf(stderr, "The rate %d Hz is not supported by your
hardware.\n=> Using %d Hz instead.\n", rate, exact_rate);
}
// Set number of channels
if (snd_pcm_hw_params_set_channels(pcm_handle, hwparams, 2) < 0) {
fprintf(stderr, "Error setting channels.\n");
return;
}
// Set number of periods. Periods used to be called fragments.
if (snd_pcm_hw_params_set_periods(pcm_handle, hwparams, periods, 0)
< 0)
{
fprintf(stderr, "Error setting periods.\n");
return;
}
// Set buffer size (in frames). The resulting latency is given by
// latency = periodsize * periods / (rate * bytes_per_frame)
snd_pcm_uframes_t buffersize = ( snd_pcm_uframes_t )(
number_of_frames * periods );
if (snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams,
&buffersize) < 0){
fprintf(stderr, "Error setting buffersize.\n");
return;
}
printf("Buffer size asked for %d, set %d \n",buffersize,exact_rate);
// Apply HW parameter settings to
// PCM device and prepare device
if (snd_pcm_hw_params(pcm_handle, hwparams) < 0) {
fprintf(stderr, "Error setting HW params.\n");
return;
}
snd_pcm_prepare(pcm_handle);
Unfortunately, exact_rate is zero.The following lines were printed out:
The rate 8000 Hz is not supported by your hardware.
=> Using 0 Hz instead.
If exact_rate > 0 is OK but it is zero.
I don't know how to solve the problem.
Please help me.
Thanks!
Phuoc Nguyen
Hi,
Is there a standard way of converting a 24bit sample to 16bit?
I ask because I think that in different scenarios, one would want a
different result.
1) scale a 24bit value to a 16bit by simple multiplication by a fraction.
2) bit shift the 24bit value, so that the "most useful 16bits" are
returned to the user. The problem here is what are the "most useful
16bits"? I have one application where just using the lower 16bits of the
24bit value is ideal, due to extremely low input signals.
Option (1) looses information due to compression of the signal.
Option (2) is more likely to loose information through clipping.
James