#96 Error Initializing Jack or ALSA

Davy Durham

I am thinking a problem in the code, but from what it
looks like it may also be a problem in my Alsa config,
not real sure so I apoligize if its not truly a bug.

I have come across a problem, when I open Rezound after
emerging it I get this....

Error occurred while initializing audio output method
'alsa' -- virtual void CALSASoundPlayer::initialize()
-- cannot set channel count -- Invalid argument
Error occurred while initializing audio output method
'jack' -- virtual void CJACKSoundPlayer::initialize()
-- error connecting to jack server -- jackd not running?

Now that is without Jack running. With Jack running it
hangs until I stop Jack, and then gives me the above.
I am running ALSA 1.09b right now. This happens with
both Rezound 0.12.1 and 0.12.0 so I cant really figure
it out since i Dont know how to program ALSA or Jack
programs yet sorry;) I will be more than happy to
answer any questions you mighthave though if you email
me or post here. Email is seablade@softhome.net



  • Davy Durham
    Davy Durham

    • assigned_to: nobody --> ddurham
  • Davy Durham
    Davy Durham

    Logged In: YES

    The jack support is rather infantile at present. I've got
    to take some time to address the issues. When I implemented
    jack support, it was a long time ago, so I'm not sure it
    still works with the newer versions.

    I will get back to you when I address issues in the jack

    Hopefully, it won't be too long

  • Logged In: NO

    Any ideas on the ALSA problem then?

    Great product by the way, when I get a little better at
    coding Ill take a look and see if I can help you out a bit,
    as it stands right now my familiarity with your program code
    is minimal though so I cant give much help.


  • Logged In: NO

    Hmm it seems I can confirm the problem exists with 12.2 as
    well as I just emerged that.


  • Logged In: NO

    Hmm ok some more info on that...

    If I launch rezound specifying Jack for an output I get a
    dialog asking me to choose an output for channel 1, but it
    hangs before channel 2 gets set. Channel 1 gets set fine as
    I can go into QJackctl and see the connection that is made,
    but channel 2 is left without one, and the program hangs
    until I kill it, killing Jack does nothing to stop it from
    hanging in this instance.

    Doing this with ALSA as the option though I get the same
    thing, with an extra Error message saying it cant initialize

    I will be digging through your code for a while, do you have
    a preferred method for someone not familair with working on
    group projects to ask questions on the code? I do have some
    familiarity with C++ but not in any of the libraries here, I
    am just going to look around and see if anything stands out
    to me and do a little research and learning while I am at it.


  • Logged In: YES

    Ok more fun info for you...

    After taking a look through your code I decided to try only
    initializing one jack channel... Worked great... well not

    Rezound Started up fine then, however after generating 30
    seconds of white noise to test it, and hitting play I came
    back to an old error I bugged a while back that it killed
    itself the moment I hit play.

    So one problem in the Jack initialization seems to be in the
    initializing more than one port, and past that something odd
    seems to be happening to where it wont even get one port
    unless you specify jack for the audio-method.

    The killing itself seems to be a seperate problem still
    though unfortunatly and I dont have much information on that
    yet, except to guess that it might be related to the
    playback of the file into Jack off of little to no
    information.. Yea for hunches.

    I havent gotten any farther on the ALSA side of things yet


  • Logged In: YES

    Ya know you are probably gonna get sick of my posting soon;)
    I keep finding new things.

    Ok I noticed a new error message after the Rezound UI starts

    cannot write to working directory canididate: / --
    Permission Denied

    So it appears to be trying to use the root directory of the
    filesystem to write to for created files and the like, that
    may definitly cause some problems. There is a related
    problem where it tries to load shared data from
    /usr/share/rezound which most users dont have access to by
    default, so it appears to be a few problems with where
    things are being set up to read from. Where can I change
    those configurations at? I dont remember seeing them in the
    registry, though I can look again.


  • Davy Durham
    Davy Durham

    Logged In: YES

    try deleting your ~/.rezound/registry.dat file (or move it
    to another filename)

  • Logged In: YES

    Ok Moved registry.dat from ~/.rezound

    I am still getting theprogram using /usr/share/rezound at
    It is still having problems initializing audio devices.
    And when I create a new file it still tries to create it by
    default in /

    I think in as far as that last item it is using the filename
    as an exact reference to the file and attempting to put it
    in root by default unless the full path is typed in. I make
    this assumption because if I navigate using that dialog to a
    different directory(For instance my home directory) and
    click on a file there to overwrite it works fine. Also
    works fine as long as the full path is typed in, and even
    defaults to that from then on, so it seems to be just the
    initial create that has these problems. Might be best to
    have it default instead to a home directory, at least for
    creating files. Minor fix there though.

    I think what is causing it to crash(Once it is started up)
    is somewhere in the playback sequence as I dont have the
    problem when the audio engines are not initialized, in fact
    it runs rather well until I hit play and get the error about
    the playback engine not being initialized if it is not, or
    it crashes if it is.


  • Logged In: YES

    Well good news and bad news...

    The good news is that following a different open bug report...


    And commenting out that loop for jack ports seems to work
    wonders when launching the program with --audio-method=jack
    It launches up beautifully. At least with jack, not sure
    why I am having problems with alsa.

    Of course it still dies when attempting playback though.
    The only feedback I get to the console is one word


    So this seems to be going back to a previous bug report I
    hadput in some time ago(Several months cant remember exactly
    when) about Rezound Killing itself.

    However since the presetup of a jackport(in
    CJackSoundPlayer.cpp) doesnt seem to be required commenting
    it out seems to be a good solution till a chance gets taken
    to look at it. I dont believe this is causing my problem
    with it killing itself, I think that is somewhere in the
    playback calls, and once I figure out a good debugger I will
    be seeing if I can track that down. The catch is learning a
    good debugger in linux(I guess that means either gdb or
    ddd), always seems easier when I develop it from scratch in
    an IDE;)


  • Logged In: YES

    And apparently I spoke to soon I think, after running gdb on
    it it stopped working, now it seems to hang(Wether or not
    gdb is running) from within the asound file a call to
    pthread open() Ill try to get more info, looking for a cheap
    way out and finding a Graphical frontend to gdb so I can
    keep track of things a little better, will try recompiling
    in just a bit to see if that restarts it.


  • Logged In: NO

    Ok so where the playback seems to be dieing is in an if/then
    statement in


    The If statement is located in a for loop line 721,

    for(unsigned i=0;i<channelCount;i++)
    if(!muted[i]) // ??? this memory needs to be locked for
    Jack's sake

    It seems to die on the first statement in that if statement
    if I am using the debugger correct anyways;) Unfortunatly I
    cant seem to do a core dump to get all the relevant variable
    information to say exactly why it is dieing, though looking
    at your comment there I am not sure if it was locked or not
    since this is using Jack for output.

    I cant seem to get ALSA output working to be able to test it
    with that and see if it still dies there though.

    This is all with the aforementioned patch to remove the
    output channels and patch them by hand with qjackctl

    I should also note that a good majority if not all the time
    when Rezound dies here it seems to kill jackd with it and as
    a result also kills qjackctl. Or at least does while I am
    running it in the debugger.

    Hope this helps you a bit. Hopefully eventually I will
    remember enough of my actual coding and understand enough of
    yours to be able to help you fix it.


  • Logged In: YES

    I yes the problems I had before with running rezound after
    removing the troublesome for loop to assign jack ports was
    because I was using the wrong argument on the commandline...
    Yea for my own stupidity. Removing that for loop seems to
    work to start up ReZound and then it has to be patched by
    hand afterwards.

    If you have Jack running and start the program with the no
    argument on the commandline it seems to hang as described
    before. I can get you an entire traceback if you need it
    for that, it doesnt ever seem to get ot the part with
    initializing jack, it seems to hang trying to initialize
    ALSA instead and since that by default comes first, it
    doesnt output any information.


  • Logged In: NO

    OK well you may already know this, but just in case...

    In searching around for a different problem I was having I
    came across this...

    > Gentoo's version in portage has the ebuild for Jack
    marked as Power
    > PC only. Searching around in Gentoo's Bugzilla I ran
    across some notes
    > about Jack's API changing and that has apparently proken
    Jack Rack.
    There has been an API change jack_create_thread() was
    altered in april this
    year i think. You might want to chect the archive. If I
    remember correctly
    only new jamin would work correctly.

    I may well be corrected though.


    Which would make sense since I am seeing some problems in a
    call to pthreads, so if Jack uses this then it may very well
    be related to the problem with using it, but I am not sure,
    as you know your code much better than I could hope to, but
    since you mentioned a needed to stabilize your code a bit
    and the implementation was old I figured I would post it.


  • Logged In: NO

    Ok yea for more testing...

    Compield Jack and Rezound on a 32 Bit chroot, for some
    reason qjackctl wont connect to my X in the chroot so I ran
    Jack by hand using....

    jackd -R -d alsa -r 44100 -d hw:0 &

    and then followed by

    rezound --audio-method=jack

    I tried this both with a patched compile and unpatched
    compile of rezound. Both compiles just hung if I didnt
    specify jack on the command line like above(I believe
    because Jack interferes with te request for an output from
    ALSA, this is the same problem as I was having before).

    The unpatched compile would get to the Jack-Output Port
    selection dialog and hang after I hit ok and never open the
    output port for port 2, I will be trying to run it off one
    output port in a moment to see if that works, it didnt. IN
    fact Jack died completly doing that causing rezound to hang,
    massive xruns were reported before it died though. WHen I
    hit play the first time though it acted the same as the
    patched version did when I amnually connected the ports...
    see below.

    The Patched version loaded up fine and I could connect the
    ports by hand using the command line tools supplied with
    jack, but when I hit play, though the mini-led type
    indicator on the UI for play lit up, and even when I paused
    it it paused and there was a status line that appeared a bit
    to the right of that that indicated playing, the time
    indicated never moved wether or not it was playing and no
    output was recieved.

    It should be noted that for whatever reason rezound could
    not find the Jack daemon if I ran it outside of the chrooted
    environment, so the jack daemon that was run was in fact
    compiled 32 bit along with Rezound.

    The same problem exists with Alsa hardware ports though in
    that it cannot find the alsa drivers though they are there.


  • Logged In: YES

    Heh ok after much recompiling, of both alsa and my kernel,
    and a little of rezound I have gotten a stock install of
    rezound to rezognize Alsa on my machine finally, however I
    still cant get playback. Instead there is an exception
    thrown very early, before an audio file is even loaded into
    rezound(Startup goes fine except for this...

    exception caught in play thread: virtual void
    CALSASoundPlayer::CPlayThread::main() -- frames_to_deliver
    is less than PERIOD_SIZE_FRAMES: 0<1024

    I have a feeling that this may be causing my playback
    problems which mirror what I was able to get Jack to, in as
    far as I could hit play without it crashing, and the counter
    would popup with the paly status message in the lower
    section of the UI, as well as the play led indicator
    lighting, but it wouldnt play, the counter would stay at a
    standstill and not move forward.

    So at least there is some progress.


  • Logged In: YES

    Ok I FINALLY got a Version of Rezound to work, from a 32-Bit
    Chrooted environment, using OSS EMulation for Alsa and
    running rezound with --audio-method=oss

    Only way I have managed to get it working thus far. Once I
    Get caught up on my projects I have been foolishly
    neglecting while trying to dig through this problem to use
    this program in them I will continue working and be looking
    through your code to learn it and hopefully submit you
    patches to fix some of the other bugs/problems in this
    thread. This of course depends on how well I remember my
    C++ and C, as well as how well I figure out your code and
    teach myself a few new tricks;)


    WOOHOO I LOVE this program all over again.

  • Logged In: YES

    I did find it funny that while it is playing, neither the
    PLaying Status message with the timer pops up in the
    display, nor does the playing LED style indidcator light
    light up;) It works though and I am happy, I can deal with
    no inidcation of where I am in the file for right now;)


  • Logged In: YES

    Ok so I also have Rezound running inside the 32 bit
    environment with Jack also running inside the 32 Bit
    environment, with the patched version where I manually
    connect the jack ports instead of being asked for them. The
    unpatched version still hangs after connecting the first port.

    Now I just need to figure out why qjackctl cant connect to
    my xserver from in the 32 Bit environment, but everything
    else can;)

    Or find a way to pipe audio out to my jack server in the 64
    bit environment, which is preferable.


  • Davy Durham
    Davy Durham

    Logged In: YES

    WOW.. thanks for writing the novel about your issues :) j/k

    Well, some of this I can follow and some not, as it's hard
    to completely understand not being there.

    As for the potential crash point in
    CSoundPlayerChannel.cpp:721.. see if you can get it to crash
    there (either running in the debugger or analyzing a core
    file).. then use ddd/gdb to see what the values of i and
    channelCount are. muted is a static array of size
    MAX_CHANNELS which is usually 8.

    About the --audio-method command line parameter: To explain
    a little in case it's not clear, that command line only
    specifies what to try *first* in the whole set of compiled
    in methods. If you truely only want to try a single method
    (i.e. jack, alsa, oss, etc) then edit
    ~/.rezound/registry.dat and make AudioOutputMethods contain
    only the method you want to try. If you were specifying
    jack on the command line, and jack couldn't be initialized,
    then it probably tried alsa next. I'm thinking that the
    direct also implementation is you problem. Make it try only
    alsa and run that in a debugger to see where/why it's
    crashing (or was that the muted[i] crash?)

    I'm also interested to know why rezound is getting hung
    during the port selection for jack. Your saying that if you
    comment out the loop starting at CJACKSoundPlayer.cpp line
    116 (not 166 like that other message said) then it can
    safely be connected with something like qjackconnect? What
    line is actually stuck (again, use the debugger to interrupt
    the process while it's hung.. change to that thread and see
    where it is in the backtrace)

    Thanks bunches.. as I've not seen any of these problems on
    my machine.

    -- Davy

  • Logged In: YES

    Well the only thing I can check quickly and easily right now
    I did.. the rest Ill come back to as my time at the moment
    is scarce...

    The lines I have commented out in CJackSoundPlayer.cpp are
    lines 117-136 according to my emacs. 116 I believe is just
    a comment before hand so that would work and fit with what
    you have as well.

    If the other bug post I referenced had line 166 then I have
    no clue what I was smoking but obviously I didnt listen to
    it very well and my way seems to work;) Or it may just be a
    typo and supposed to be 116, not sure. I seem to remember
    searching for a statement in that loop though for some
    reason, or I mayhave just started at the start of the file
    and commented it out when I found it,. not real sure. Brain
    dead on little sleep sorry;)

    Anyways ill try to repeat what you want in the next day or
    two if I manage to get a bit of sleep in there as well and
    post up the results.


  • Logged In: YES


    Sorry is there a name you would rather be referenced by?

    Ok sorry I havent been able to check those things for oyu
    though it appearsyou got time on a 64 bit server to check it
    out yourself anyways, the patch is working on my system at
    least, thanks much for your work. I have been trying to
    catch up on a few things including keeping an eye out here,
    and noticed you were looking at the implementation of
    Rezound on OSX that a commercial distro has out, and would
    be more than willing to test that out as well if/when you
    get the edits.

    As I am diving headfirst so to speak into audio programming
    on Linux, specificly Jack I may be able to give you some
    patches eventually, but I gotta get my own project off the
    ground first so I know what I am doing;)


  • Davy Durham
    Davy Durham

    • milestone: --> JACK
    • status: open --> closed-out-of-date
  • Davy Durham
    Davy Durham

    cleaning up tracker