RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Reicast and ALSA audio backend: Invalid argument

    Scheduled Pinned Locked Moved Help and Support
    reicastx86alsa
    1 Posts 1 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vbsV
      vbs
      last edited by

      I am currently trying to get Reicast work for me (Lubuntu 16.04, Intel NUC x86, latest Retropie). I have problems with Reicast's audio backend. I'll will try to explain but it got a bit complicated as I am not sure where the problem exactly is.
      When I start Reicast then it runs but it is stuttering in a strange way. It already does it in the Dreamcast BIOS animation (CPU usage is fine). It turned out that it is related to the audio backend (but audio playing fine). When I go to ~./reciast/emu.cfg and put [audio]/disabled=1then the stuttering goes away but the emulator runs VERY fast (like 10x fast forward speed).

      Well, basically I want to use ALSA. I noticed that Retropie starts Reicast with 'oss' using 'aoss' to redirect to ALSA. Since I was not sure why, I tried to just use plain ALSA. When switching to ALSA I get get an error message right upon startup of Reicast:

      Using Recompiler
      Initializing audio backend "alsa" (Advanced Linux Sound Architecture)...
      Unable to set hw parameters: Invalid argument
      

      No sound is playing and the emulator runs again at ~10x speed.

      When starting with Retropie (leaving Reicast alone) I had no sound at all (in ES and in emulators) with my Intel NUC HDMI sound device because ALSA did had a wrong audio device as the default device. So I had to create an .asoundrccontaining;

      pcm.!default {
            type hw
            card 0
            device 3
       }
      

      Telling ALSA that "hw:0,3" should be my default device. Sound was working at that point. But ES was always throwing some error because it could not open the mixer "Master" (the HDMI sound device has no hardware mixer). Also I could not control system volume in the ES settings (was always 0). Then I learned I had to define a "softvol" ALSA device which brings a software master volume mixer called "Master". So I changed my .asoundrcto this:

      pcm.softvol {
          type            softvol
          slave {
              pcm         "hw:0,3"
          }
          control {
              name        "Master"
              card        0
          }
      }
      
      pcm.!default {
          type             plug
          slave.pcm       "softvol"
      }
      

      Which worked fine: I had sound and also I could control the system volume in ES.

      But now with this configuration I get that problem with Reicast saying "Invalid argument" when trying to initialize ALSA.
      I found out that this Reicast error disappears when I remove that softvol-device again from my ALSA config and make my hardware device (hw:0,3) default again. Then Reicast can initialize ALSA fine and the emulator runs as expected with sound and with correct speed.

      Since this wasn't a real solution for me (ES needs that mixer 'Master') I looked into the Reicast sources where they initialize ALSA in this function:
      https://github.com/reicast/reicast-emulator/blob/master/core/oslib/audiobackend_alsa.cpp#L8
      As far as I can see it just initializes the device to 16Bit, Stereo, 44.1kHz, so nothing unsual. When I use the same settings and trying speaker-testthen the test works fine.
      (I know Retropie uses a special branch for Reicast but I thought I would give master a try. That other branch had no commits for about a year.)

      Huh, I noticed in the code the use of the variable dir as a parameter to some ALSA functions. AFAIK this parameter controls for the *near-functions if you accept bigger, smaller or only equal values. The parameter is passed as an pointer to an int and I think is treated as input value but also as output value. But in the Reicast code the variable diris not initialized. So when it is used as an input value you basically get something random.
      Initializing the variable dirOR passing just NULLas the dir parameter actually fixes the problem for me! Then I get sound with my softvol-device and the emulator runs fine.

      So, what does it mean:

      • is Reicast using ALSA wrongly? Is it just a bug that they don't initialize that variable dir? But official ALSA examples doing it the same way in some of their *_near-calls (passing pointer to uninitialized int value):
        http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
        But I have really no idea how that can possibly be correct! Initializing the variable definitely changes behavior.
      • Is there something wrong in my softvol device in .asoundrc? Is there some option I can put there to make the initialization work?
      • Why does Retropie use oss instead of ALSA? Something related to this?

      Well, dunno if someone actually read that giant wall of text until here. But if so: Any hints, thoughts or ideas are greatly appreciated. Maybe I should go over to Reicast with this but Reicast does not seem to be maintained very well. Also maybe it is just an ALSA issue?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

      Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.