You are not logged in.

#1 2012-08-09 19:36:06

From: sweeden
Registered: 2012-08-09
Posts: 7

How do you really start JACK server before X?(+ my own ugly solution)


I've decided to install the 'jack2' package from [community] because of the following:

1. I can't seem to get dmix to work
2. I don't have any understanding of how dmix is supposed to work
3. I need JACK, as a backend (is that it ?) to the low-latency Steinberg ASIO plugin for WINE
4. A sound server seems like a good thing to have anyway (can probably do stuff that dmix can't)
5. I have a dual core CPU, so going for jack2 (multi-core) seems logical.

I would like to keep things as simple as possible, and according to the wiki page on JACK,  jack2 pretty much shares syntax with the original jack, which I used some time ago, while the jack2-dbus package offers some 'jack_control' voodoo that I don't *think* I need.

Now, I would like to start the server daemon "early", that is, before X. This is mostly to have it as system-wide as possible (although single-user),  but also to be able to handle multiple sound applications in VT, should I need to.

If you already know the solution to this (I would have expected no complications at all or, at the most, an extra flag to jackd), please don't bother reading below. It is ugliness and lack of understanding, but it sort of works.

I first wrote a line in /etc/rc.local (to have it "fire-and-forget" during boot):

su -c 'jackd -d alsa &' user

jackd refuses to start this way, as evident by running the command in a VT after login:

$ jackd -d alsa 
Failed to connect to session bus for device reservation [b]Unable to autolaunch a dbus-daemon without a $DISPLAY for X11[/b]

Failed to acquire device name : Audio0 error : Invalid argument
Audio device hw:0 cannot be acquired...
Jack: ~JackDriver
Cannot initialize driver
Jack: no message buffer overruns
Jack: JackPosixThread::Stop
Jack: ThreadHandler: exit
JackServer::Open() failed with -1
Jack: Succeeded in unlocking 82245916 byte memory area
Jack: JackShmMem::delete size = 0 index = 0
Jack: ~JackDriver
Jack: Succeeded in unlocking 1012 byte memory area
Jack: JackShmMem::delete size = 0 index = 1
Jack: cleaning up shared memory
Jack: cleaning up files
Jack: unregistering server `default'
Failed to open server

So things don't seem as simple as I thought. Why would DISPLAY need to be set? What's this about dbus-launch (I thought this was independent of dbus)?

Anyway, I'm a little blind from this stage on, but jackd seems to start without errors if I supply some variables before launching jackd (I do this in a script called jackstart):

#! /bin/bash
# file: /home/user/data/script/jackstart
# This is ridiculous:
export DISPLAY=:0

# dbus-launch started, DBUS_SESSION_BUS_ADDRESS exported:
export `dbus-launch | grep ADDRESS` 

# dbus-launch started, DBUS_SESSION_BUS_PID exported
export `dbus-launch | grep PID` 
jackd -d alsa > ~/Desktop/jack.log 2>&1 

Furthermore, everything works fine when I run all this from .bash_profile...

# ~/.bash_profile
[[ -f ~/.bashrc ]] && . ~/.bashrc

# run jackstart iff jackd is not already running:
ps -e | grep jack > /dev/null 2>&1 || /home/user/data/script/jackstart

... but not when run from rc.local (via su -c '/path/to/jackstart' user) It then crashes when any second application wants to output sound.

Is this something to pursue, or should I start over? Should the final solution be a run-once command in /etc/rc.local or a run-every-login command in ~/.bash_profile?

That's all I've got. I'm thankful for any suggestions on how to do this properly (this obviously isn't correct), and if you're just desperate to get something like this to work yourself, I hope this might help you in some way.


Board footer

Powered by FluxBB