alsa_in/out: Convert between sample rates when necessary
alsa_in and alsa_out set the playback latency of their ports to the target delay. The problem is the target delay is in terms of the ALSA sample rate, so it should be converted to JACK's sample rate.
Example: Imagine JACK is running at 48 kHz, and alsa_out is invoked like:
alsa_out -r 96000 -t 512
Currently, alsa_out will report 512 frames of playback latency. After the fix, it converts to 48kHz and correctly reports 256.
Also converts the result of jack_frames_since_cycle_start to ALSA sample rate.
* detect version option before all other oprion parsing
jackd now checks its arguments for "-V" and "--version" before all other
option parsing happens.
* remove some dead code from option parsing
Version options are detected before optparse runs, the removed code
paths thus became obsolete.
* remove rest of version option from optparse
Detection of the version option is now handled outside of optparse, thus
left over stings and variables are removed.
* switch to string comparison for detection version option
Demanding an exact match for the option strings reflects the original
behavior more closely than a search for substrings.
The ucontext functionality is not available on all CPUs with all C
libraries. Instead of making just assumptions based on the CPU
architecture, this commit adds the necessary checks in wscript to verify
the availability of the ucontext functionality, before using it in
dbus/sigsegv.c.
This avoids the long list of architecture exclusions, and make it more
robust when building jack2 for new CPU architectures.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
With glibc 2.16, we get following build error when building jack2:
[193/247] cxx: tests/iodelay.cpp -> build/tests/iodelay.cpp.4.o
../tests/iodelay.cpp:171:43: error: 'UINT32_MAX' was not declared in this scope
../tests/iodelay.cpp:171:55: error: 'UINT32_MAX' was not declared in this scope
../tests/iodelay.cpp:172:44: error: 'UINT32_MAX' was not declared in this scope
../tests/iodelay.cpp:172:56: error: 'UINT32_MAX' was not declared in this scope
In glibc 2.17 or older version, Header <stdint.h> defines these macros
for C++ only if explicitly requested by defining __STDC_LIMIT_MACROS.
We can't use <cstdint> since it requires C++11 standard.
This build issue found by Buildroot autobuilder.
http://autobuild.buildroot.net/results/369/369ce208ffea43dad75ba0a13469159b341e3bf5/
Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
jack_latency_range_t is
struct _jack_latency_range {
jack_nframes_t min;
jack_nframes_t max;
};
and jack_nframes_t is
typedef uint32_t jack_nframes_t;
so it's unsigned. Initialising it with -1 is invalid (at least in C++14). We cannot use {0, 0}, because latency_cb has
jack_latency_range_t range;
range.min = range.max = 0;
if ((range.min != capture_latency.min) || (range.max !=
capture_latency.max)) {
capture_latency = range;
}
so we must not have {0, 0}, otherwise the condition would never be true.
Using UINT32_MAX should be equivalent to the previous -1.
If configured with --clients=512 (translates to CLIENT_NUM), we exceed
the maximum stack size. CLIENT_NUM==500 still works, but let's allocate
the matrix on the heap to be safe.
Kudos to Markus Seeber for the initial bug triage.
Fixes#212
In some C-libraries (like uclibc), backtrace support is optional, so the
execinfo.h may not exist.
This change adds the check for execinfo.h header and conditionaly enable
backtrace support.
This issue has been triggered by Buildroot farms:
http://autobuild.buildroot.org/results/391/391e71a988250ea66ec4dbee6f60fdce9eaf2766/build-end.log
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reported by valgrind using the command below:
$ valgrind jackd -p128 -t2000 -dalsa -dhw:0 -r44100 -p2048 -n2 -S
==17496== Memcheck, a memory error detector
==17496== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==17496== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==17496== Command: jackd -p128 -t2000 -dalsa -dhw:0 -r44100 -p2048 -n2 -S
==17496==
jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:0|hw:0|2048|2|44100|0|0|nomon|swmeter|-|16bit
configuring for 44100Hz, period = 2048 frames (46.4 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 16bit little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback
==17496== Thread 3:
==17496== Conditional jump or move depends on uninitialised value(s)
==17496== at 0x4E91CC9: Jack::JackEngineControl::CalcCPULoad(Jack::JackClientInterface**, Jack::JackGraphManager*, unsigned long, unsigned long) (JackEngineControl.cpp:58)
==17496== by 0x4EB3256: Jack::JackEngineControl::CycleBegin(Jack::JackClientInterface**, Jack::JackGraphManager*, unsigned long, unsigned long) (JackEngineControl.h:153)
==17496== by 0x4EAF54A: Jack::JackEngine::Process(unsigned long, unsigned long) (JackEngine.cpp:166)
==17496== by 0x4EA922E: Jack::JackLockedEngine::Process(unsigned long, unsigned long) (JackLockedEngine.h:261)
==17496== by 0x4EA8819: Jack::JackAudioDriver::ProcessGraphAsyncMaster() (JackAudioDriver.cpp:250)
==17496== by 0x4EA87D0: Jack::JackAudioDriver::ProcessGraphAsync() (JackAudioDriver.cpp:236)
==17496== by 0x4EA8795: Jack::JackAudioDriver::ProcessAsync() (JackAudioDriver.cpp:225)
==17496== by 0x4EA870E: Jack::JackAudioDriver::Process() (JackAudioDriver.cpp:202)
==17496== by 0x4EBA5DA: Jack::JackThreadedDriver::Process() (JackThreadedDriver.cpp:71)
==17496== by 0x4EBAC52: Jack::JackThreadedDriver::Execute() (JackThreadedDriver.cpp:244)
==17496== by 0x4EA4B63: Jack::JackPosixThread::ThreadHandler(void*) (JackPosixThread.cpp:61)
==17496== by 0x59F5181: start_thread (pthread_create.c:312)
==17496==
^CJack main caught signal 2
==17496==
==17496== HEAP SUMMARY:
==17496== in use at exit: 95,475 bytes in 1,441 blocks
==17496== total heap usage: 2,793 allocs, 1,352 frees, 7,217,645 bytes allocated
==17496==
==17496== LEAK SUMMARY:
==17496== definitely lost: 1,458 bytes in 10 blocks
==17496== indirectly lost: 7,680 bytes in 4 blocks
==17496== possibly lost: 42,998 bytes in 1,314 blocks
==17496== still reachable: 43,339 bytes in 113 blocks
==17496== suppressed: 0 bytes in 0 blocks
==17496== Rerun with --leak-check=full to see details of leaked memory
==17496==
==17496== For counts of detected and suppressed errors, rerun with: -v
==17496== Use --track-origins=yes to see where uninitialised values come from
==17496== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
When compiling jack on nios2, compilation fails because NGREGS is not
defined. Since this is only for debug output on segmentation faults, stub
the debug print out like it's been done for other platforms before.
Inspired by
d11bb09529
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>