<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum]]></title>
		<link>https://dev1galaxy.org/index.php</link>
		<description><![CDATA[The most recent topics at Dev1 Galaxy Forum.]]></description>
		<lastBuildDate>Fri, 10 Jul 2026 16:39:50 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Basic GUI man-page browser/viewer]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8071&amp;action=new</link>
			<description><![CDATA[<p>&quot;I don&#039;t know squat about writing man pages though, the raw format is weird. Seems like they could have just used .txt files.&quot;</p><p>As in a MS DOS / Windows format?</p>]]></description>
			<author><![CDATA[dummy@example.com (blackhole)]]></author>
			<pubDate>Fri, 10 Jul 2026 16:39:50 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8071&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Running older games]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8090&amp;action=new</link>
			<description><![CDATA[<p>Hi! Unfortunately I cannot help with the Nvidia side of things, but regarding Wine:</p><p>Yes, you will absolutely need to add 32-bit architecture before installing Wine and its dependencies if you want to run Win32 games/programs:</p><div class="codebox"><pre><code># dpkg --add-architecture i386</code></pre></div><p>After installing Wine, <span class="bbu">do not</span> launch <strong>winecfg</strong> or Windows applications straight away. Instead, create your own 32-bit prefix that will be your default $WINEPREFIX (it&#039;s probably more convenient as many old games are Win32 applications).</p><div class="codebox"><pre><code>$ WINEARCH=win32 WINEPREFIX=~/.wine winecfg</code></pre></div><p>Now create a separate 64-bit prefix for your Win64 games:</p><div class="codebox"><pre><code>$ WINEARCH=win64 WINEPREFIX=~/.wine64 winecfg</code></pre></div><p>Since this second prefix is <em>not</em> the default, you will need to define it via the WINEPREFIX variable every time you need to use it. It should look like this:</p><div class="codebox"><pre><code>$ WINEPREFIX=~/.wine64 wine game64.exe</code></pre></div><p>Note that while you <em>can</em> use 64-bit prefix for 32-bit applications, with earlier versions of Wine - including Wine 10 that is in the Excalibur repositories - you will run into many bugs. So it&#039;s highly recommended to keep a separate 32-bit prefix and use it as default (any prefix in <span class="bbc">~/.wine</span> folder is always considered to be the default).</p><p>Another option is to enable WineHQ repositories and install a newer version of Wine. These have added <a href="https://dev1galaxy.org/viewtopic.php?id=7751" rel="nofollow">proper WoW64 support</a>, which means the 32-bit stuff is no longer needed and everything can be run in the default 64-bit prefix. I have not tested this personally but I imagine it should work fine.</p><p>From general experience, games from the early-mid 2000s (think <strong>American McGee&#039;s Alice, Deus Ex, Rune, ZanZarah, No One Lives Forever, The Punisher, FlatOut 1 and 2</strong>...) run great in Wine. Especially true of 3D titles if you got the driver support sorted out. I found that some 2D games and programs actually run <em>worse</em>. </p><p>Regarding drivers - I play on Intel, so it was an easy ride for me. For <a href="https://en.wiktionary.org/wiki/invidia#Latin" rel="nofollow">Nvidia</a> I wish you lots of luck, since you got the driver working I think there should be no issues.</p><p>See these threads for some Wine-specific tips and tricks:</p><p><a href="https://dev1galaxy.org/viewtopic.php?id=7676" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=7676</a><br /><a href="https://dev1galaxy.org/viewtopic.php?id=7685" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=7685</a></p><p>I recommend reading the Wine manual and FAQ pages to get familiar with Wine registry, DLL overrides and uninstaller. It should be pretty straightforward, but feel free to ask for any advice. <strong>Winetricks</strong> is now in the repositories and is useful in certain specific cases. It&#039;s probably not as necessary if you opt for Wine 11+.</p><p>As I also don&#039;t use Steam, I recommend installing <strong>Lutris</strong> to manage your game collection (but <span class="bbu">not</span> to install your games, see this <a href="https://dev1galaxy.org/viewtopic.php?pid=60815#p60815" rel="nofollow">post</a>). You may also want to install <strong>gamemode</strong>, disable screensavers, display power management, Spectre mitigation (in GRUB) and increase ulimit if you haven&#039;t done so already.</p><p>Oh, and you may also find the <strong>bchunk</strong> and <strong>iat</strong> tools very handy when working with disk images.</p>]]></description>
			<author><![CDATA[dummy@example.com (Calamity)]]></author>
			<pubDate>Fri, 10 Jul 2026 15:23:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8090&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Music]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=1643&amp;action=new</link>
			<description><![CDATA[<p>It&#039;s Julyyy<br />Blood and Thunder!<br /><a href="https://youtu.be/v-Su1YXQYek" rel="nofollow">https://youtu.be/v-Su1YXQYek</a></p>]]></description>
			<author><![CDATA[dummy@example.com (Kristof12)]]></author>
			<pubDate>Fri, 10 Jul 2026 11:21:39 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=1643&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Why not use runit? Do you guys use runit?]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8029&amp;action=new</link>
			<description><![CDATA[<p>Kinda like da way that OpenRC is, I just use that</p><div class="quotebox"><blockquote><div><p>The harsh reality is that if you&#039;re just a desktop user, and not a server admin, you may see no benefits from something like runit, where the main focus is service supervision, except for perhaps slightly faster boot times.</p></div></blockquote></div><p>I just use on desktop then would be no difference anyway I guess</p>]]></description>
			<author><![CDATA[dummy@example.com (Kristof12)]]></author>
			<pubDate>Fri, 10 Jul 2026 11:17:03 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8029&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[HexChat's GTK3 Successor: ZoiteChat]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=7832&amp;action=new</link>
			<description><![CDATA[<p>Zoitechat on stable backports, then noice</p>]]></description>
			<author><![CDATA[dummy@example.com (Kristof12)]]></author>
			<pubDate>Fri, 10 Jul 2026 11:10:29 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=7832&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Firefox: Dialectics of Antagonistic Security Bugs]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8012&amp;action=new</link>
			<description><![CDATA[<h5>New version of Firefox/Cubeb ALSA backend</h5><div class="codebox"><pre><code>Date:   Wed Jul 8 22:22:55 2026 +0200

    ALSA backend: Implement proper device enumeration using snd_device_name_hint()
    
    Replace the minimal placeholder enumeration that returned hardcoded
    values with proper device enumeration using snd_device_name_hint() API.
    This now correctly enumerates both physical hardware devices and virtual
    devices (BlueALSA, rate converters, plugins) with accurate format capabilities,
    channel counts, and rate ranges queried from actual hardware.</code></pre></div><div class="codebox"><pre class="vscroll"><code>$ cat firefox/media/libcubeb/src/cubeb_alsa.c
/*
 * Copyright © 2011 Mozilla Foundation
 *
 * This program is made available under an ISC-style license.  See the
 * accompanying file LICENSE for details.
 */
#undef NDEBUG
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#if defined(__NetBSD__)
#define _NETBSD_SOURCE /* timersub() */
#endif
#define _XOPEN_SOURCE 500
#include &quot;cubeb-internal.h&quot;
#include &quot;cubeb/cubeb.h&quot;
#include &quot;cubeb_tracing.h&quot;
#include &lt;alsa/asoundlib.h&gt;
#include &lt;assert.h&gt;
#include &lt;dlfcn.h&gt;
#include &lt;limits.h&gt;
#include &lt;poll.h&gt;
#include &lt;pthread.h&gt;
#include &lt;sys/time.h&gt;
#include &lt;unistd.h&gt;

#ifdef DISABLE_LIBASOUND_DLOPEN
#define WRAP(x) x
#else
#define WRAP(x) (*cubeb_##x)
#define LIBASOUND_API_VISIT(X)                                                 \
  X(snd_config)                                                                \
  X(snd_config_add)                                                            \
  X(snd_config_copy)                                                           \
  X(snd_config_delete)                                                         \
  X(snd_config_get_id)                                                         \
  X(snd_config_get_string)                                                     \
  X(snd_config_imake_integer)                                                  \
  X(snd_config_search)                                                         \
  X(snd_config_search_definition)                                              \
  X(snd_lib_error_set_handler)                                                 \
  X(snd_pcm_avail_update)                                                      \
  X(snd_pcm_close)                                                             \
  X(snd_pcm_delay)                                                             \
  X(snd_pcm_drain)                                                             \
  X(snd_pcm_frames_to_bytes)                                                   \
  X(snd_pcm_get_params)                                                        \
  X(snd_pcm_hw_params_any)                                                     \
  X(snd_pcm_hw_params_get_channels_max)                                        \
  X(snd_pcm_hw_params_get_rate)                                                \
  X(snd_pcm_hw_params_set_rate_near)                                           \
  X(snd_pcm_hw_params_sizeof)                                                  \
  X(snd_pcm_nonblock)                                                          \
  X(snd_pcm_open)                                                              \
  X(snd_pcm_open_lconf)                                                        \
  X(snd_pcm_pause)                                                             \
  X(snd_pcm_poll_descriptors)                                                  \
  X(snd_pcm_poll_descriptors_count)                                            \
  X(snd_pcm_poll_descriptors_revents)                                          \
  X(snd_pcm_readi)                                                             \
  X(snd_pcm_recover)                                                           \
  X(snd_pcm_set_params)                                                        \
  X(snd_pcm_start)                                                             \
  X(snd_pcm_state)                                                             \
  X(snd_pcm_writei)                                                            \
  X(snd_device_name_hint)                                                      \
	X(snd_device_name_get_hint)                                                  \
	X(snd_device_name_free_hint)                                                 \
	X(snd_pcm_hw_params_test_format)                                             \
	X(snd_pcm_hw_params_get_rate_min)                                            \
	X(snd_pcm_hw_params_get_rate_max)                                            \
	X(snd_pcm_hw_params_get_channels_min)                                        \
	X(snd_pcm_hw_params_get_channels_max)

#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x;
LIBASOUND_API_VISIT(MAKE_TYPEDEF);
#undef MAKE_TYPEDEF
/* snd_pcm_hw_params_alloca is actually a macro */
#define snd_pcm_hw_params_sizeof cubeb_snd_pcm_hw_params_sizeof
#endif

#define CUBEB_STREAM_MAX 16
#define CUBEB_WATCHDOG_MS 10000

#define CUBEB_ALSA_PCM_NAME &quot;default&quot;

#define ALSA_PA_PLUGIN &quot;ALSA &lt;-&gt; PulseAudio PCM I/O Plugin&quot;

/* ALSA is not thread-safe.  snd_pcm_t instances are individually protected
   by the owning cubeb_stream&#039;s mutex.  snd_pcm_t creation and destruction
   is not thread-safe until ALSA 1.0.24 (see alsa-lib.git commit 91c9c8f1),
   so those calls must be wrapped in the following mutex. */
static pthread_mutex_t cubeb_alsa_mutex = PTHREAD_MUTEX_INITIALIZER;
static int cubeb_alsa_error_handler_set = 0;

static struct cubeb_ops const alsa_ops;

struct cubeb {
  struct cubeb_ops const * ops;
  void * libasound;

  pthread_t thread;

  /* Mutex for streams array, must not be held while blocked in poll(2). */
  pthread_mutex_t mutex;

  /* Sparse array of streams managed by this context. */
  cubeb_stream * streams[CUBEB_STREAM_MAX];

  /* fds and nfds are only updated by alsa_run when rebuild is set. */
  struct pollfd * fds;
  nfds_t nfds;
  int rebuild;

  int shutdown;

  /* Control pipe for forcing poll to wake and rebuild fds or recalculate the
   * timeout. */
  int control_fd_read;
  int control_fd_write;

  /* Track number of active streams.  This is limited to CUBEB_STREAM_MAX
     due to resource contraints. */
  unsigned int active_streams;

  /* Local configuration with handle_underrun workaround set for PulseAudio
     ALSA plugin.  Will be NULL if the PA ALSA plugin is not in use or the
     workaround is not required. */
  snd_config_t * local_config;
  int is_pa;
};

enum stream_state { INACTIVE, RUNNING, DRAINING, PROCESSING, ERROR };

struct cubeb_stream {
  /* Note: Must match cubeb_stream layout in cubeb.c. */
  cubeb * context;
  void * user_ptr;
  /**/
  pthread_mutex_t mutex;
  snd_pcm_t * pcm;
  cubeb_data_callback data_callback;
  cubeb_state_callback state_callback;
  snd_pcm_uframes_t stream_position;
  snd_pcm_uframes_t last_position;
  snd_pcm_uframes_t buffer_size;
  cubeb_stream_params params;

  /* Every member after this comment is protected by the owning context&#039;s
     mutex rather than the stream&#039;s mutex, or is only used on the context&#039;s
     run thread. */
  pthread_cond_t cond; /* Signaled when the stream&#039;s state is changed. */

  enum stream_state state;

  struct pollfd * saved_fds; /* A copy of the pollfds passed in at init time. */
  struct pollfd *
      fds; /* Pointer to this waitable&#039;s pollfds within struct cubeb&#039;s fds. */
  nfds_t nfds;

  struct timeval drain_timeout;

  /* XXX: Horrible hack -- if an active stream has been idle for
     CUBEB_WATCHDOG_MS it will be disabled and the error callback will be
     called.  This works around a bug seen with older versions of ALSA and
     PulseAudio where streams would stop requesting new data despite still
     being logically active and playing. */
  struct timeval last_activity;
  float volume;

  char * buffer;
  snd_pcm_uframes_t bufframes;
  snd_pcm_stream_t stream_type;

  struct cubeb_stream * other_stream;
};

static int
any_revents(struct pollfd * fds, nfds_t nfds)
{
  nfds_t i;

  for (i = 0; i &lt; nfds; ++i) {
    if (fds[i].revents) {
      return 1;
    }
  }

  return 0;
}

static int
cmp_timeval(struct timeval * a, struct timeval * b)
{
  if (a-&gt;tv_sec == b-&gt;tv_sec) {
    if (a-&gt;tv_usec == b-&gt;tv_usec) {
      return 0;
    }
    return a-&gt;tv_usec &gt; b-&gt;tv_usec ? 1 : -1;
  }
  return a-&gt;tv_sec &gt; b-&gt;tv_sec ? 1 : -1;
}

static int
timeval_to_relative_ms(struct timeval * tv)
{
  struct timeval now;
  struct timeval dt;
  long long t;
  int r;

  gettimeofday(&amp;now, NULL);
  r = cmp_timeval(tv, &amp;now);
  if (r &gt;= 0) {
    timersub(tv, &amp;now, &amp;dt);
  } else {
    timersub(&amp;now, tv, &amp;dt);
  }
  t = dt.tv_sec;
  t *= 1000;
  t += (dt.tv_usec + 500) / 1000;

  if (t &gt; INT_MAX) {
    t = INT_MAX;
  } else if (t &lt; INT_MIN) {
    t = INT_MIN;
  }

  return r &gt;= 0 ? t : -t;
}

static int
ms_until(struct timeval * tv)
{
  return timeval_to_relative_ms(tv);
}

static int
ms_since(struct timeval * tv)
{
  return -timeval_to_relative_ms(tv);
}

static void
rebuild(cubeb * ctx)
{
  nfds_t nfds;
  int i;
  nfds_t j;
  cubeb_stream * stm;

  assert(ctx-&gt;rebuild);

  /* Always count context&#039;s control pipe fd. */
  nfds = 1;
  for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
    stm = ctx-&gt;streams[i];
    if (stm) {
      stm-&gt;fds = NULL;
      if (stm-&gt;state == RUNNING) {
        nfds += stm-&gt;nfds;
      }
    }
  }

  free(ctx-&gt;fds);
  ctx-&gt;fds = calloc(nfds, sizeof(struct pollfd));
  assert(ctx-&gt;fds);
  ctx-&gt;nfds = nfds;

  /* Include context&#039;s control pipe fd. */
  ctx-&gt;fds[0].fd = ctx-&gt;control_fd_read;
  ctx-&gt;fds[0].events = POLLIN | POLLERR;

  for (i = 0, j = 1; i &lt; CUBEB_STREAM_MAX; ++i) {
    stm = ctx-&gt;streams[i];
    if (stm &amp;&amp; stm-&gt;state == RUNNING) {
      memcpy(&amp;ctx-&gt;fds[j], stm-&gt;saved_fds, stm-&gt;nfds * sizeof(struct pollfd));
      stm-&gt;fds = &amp;ctx-&gt;fds[j];
      j += stm-&gt;nfds;
    }
  }

  ctx-&gt;rebuild = 0;
}

static void
poll_wake(cubeb * ctx)
{
  if (write(ctx-&gt;control_fd_write, &quot;x&quot;, 1) &lt; 0) {
    /* ignore write error */
  }
}

static void
set_timeout(struct timeval * timeout, unsigned int ms)
{
  gettimeofday(timeout, NULL);
  timeout-&gt;tv_sec += ms / 1000;
  timeout-&gt;tv_usec += (ms % 1000) * 1000;
}

static void
stream_buffer_decrement(cubeb_stream * stm, long count)
{
  if (count &lt; 0 || (snd_pcm_uframes_t)count &gt; stm-&gt;bufframes) {
    count = stm-&gt;bufframes;
  }
  char * bufremains =
      stm-&gt;buffer + WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, count);
  memmove(stm-&gt;buffer, bufremains,
          WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, stm-&gt;bufframes - count));
  stm-&gt;bufframes -= count;
}

static void
alsa_set_stream_state(cubeb_stream * stm, enum stream_state state)
{
  cubeb * ctx;
  int r;

  ctx = stm-&gt;context;
  stm-&gt;state = state;
  r = pthread_cond_broadcast(&amp;stm-&gt;cond);
  assert(r == 0);
  ctx-&gt;rebuild = 1;
  poll_wake(ctx);
}

static void
alsa_set_draining(cubeb_stream * stm)
{
  alsa_set_stream_state(stm, DRAINING);
  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp; stm-&gt;other_stream &amp;&amp;
      stm-&gt;other_stream-&gt;state == RUNNING) {
    alsa_set_stream_state(stm-&gt;other_stream, DRAINING);
  }
}

static enum stream_state
alsa_process_stream(cubeb_stream * stm, int other_stream_running)
{
  unsigned short revents;
  snd_pcm_sframes_t avail;
  int draining;

  draining = 0;

  pthread_mutex_lock(&amp;stm-&gt;mutex);

  /* Call _poll_descriptors_revents() even if we don&#039;t use it
     to let underlying plugins clear null events.  Otherwise poll()
     may wake up again and again, producing unnecessary CPU usage. */
  WRAP(snd_pcm_poll_descriptors_revents)
  (stm-&gt;pcm, stm-&gt;fds, stm-&gt;nfds, &amp;revents);

  avail = WRAP(snd_pcm_avail_update)(stm-&gt;pcm);

  /* Got null event? Bail and wait for another wakeup. */
  if (avail == 0) {
    pthread_mutex_unlock(&amp;stm-&gt;mutex);
    return RUNNING;
  }

  /* This could happen if we were suspended with SIGSTOP/Ctrl+Z for a long time.
   */
  if ((unsigned int)avail &gt; stm-&gt;buffer_size) {
    avail = stm-&gt;buffer_size;
  }

  /* Capture: Read available frames */
  if (stm-&gt;stream_type == SND_PCM_STREAM_CAPTURE &amp;&amp; avail &gt; 0) {
    snd_pcm_sframes_t got;

    if (avail + stm-&gt;bufframes &gt; stm-&gt;buffer_size) {
      /* Buffer overflow. Skip and overwrite with new data. */
      stm-&gt;bufframes = 0;
      // TODO: should it be marked as DRAINING?
    }

    got = WRAP(snd_pcm_readi)(stm-&gt;pcm, stm-&gt;buffer + stm-&gt;bufframes, avail);

    if (got &lt; 0) {
      avail = got; // the error handler below will recover us
    } else {
      stm-&gt;bufframes += got;
      stm-&gt;stream_position += got;

      gettimeofday(&amp;stm-&gt;last_activity, NULL);
    }
  }

  /* Capture: Pass read frames to callback function */
  if (stm-&gt;stream_type == SND_PCM_STREAM_CAPTURE &amp;&amp; stm-&gt;bufframes &gt; 0 &amp;&amp;
      (!stm-&gt;other_stream ||
       stm-&gt;other_stream-&gt;bufframes &lt; stm-&gt;other_stream-&gt;buffer_size)) {
    snd_pcm_sframes_t wrote = stm-&gt;bufframes;
    snd_pcm_sframes_t requested;
    struct cubeb_stream * mainstm = stm-&gt;other_stream ? stm-&gt;other_stream : stm;
    void * other_buffer = stm-&gt;other_stream ? stm-&gt;other_stream-&gt;buffer +
                                                  stm-&gt;other_stream-&gt;bufframes
                                            : NULL;

    /* Correct write size to the other stream available space */
    if (stm-&gt;other_stream &amp;&amp;
        wrote &gt; (snd_pcm_sframes_t)(stm-&gt;other_stream-&gt;buffer_size -
                                    stm-&gt;other_stream-&gt;bufframes)) {
      wrote = stm-&gt;other_stream-&gt;buffer_size - stm-&gt;other_stream-&gt;bufframes;
    }

    requested = wrote;
    pthread_mutex_unlock(&amp;stm-&gt;mutex);
    wrote = stm-&gt;data_callback(mainstm, stm-&gt;user_ptr, stm-&gt;buffer,
                               other_buffer, wrote);
    pthread_mutex_lock(&amp;stm-&gt;mutex);

    if (wrote &lt; 0) {
      avail = wrote; // the error handler below will recover us
    } else {
      stream_buffer_decrement(stm, wrote);

      if (stm-&gt;other_stream) {
        stm-&gt;other_stream-&gt;bufframes += wrote;
      }
      if (wrote &lt; requested) {
        if (!stm-&gt;other_stream) {
          pthread_mutex_unlock(&amp;stm-&gt;mutex);
          return INACTIVE;
        }
        draining = 1;
        set_timeout(&amp;stm-&gt;drain_timeout, 0);
      }
    }
  }

  /* Playback: Don&#039;t have enough data? Let&#039;s ask for more. */
  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp;
      avail &gt; (snd_pcm_sframes_t)stm-&gt;bufframes &amp;&amp;
      (!stm-&gt;other_stream ||
       (other_stream_running &amp;&amp; stm-&gt;other_stream-&gt;bufframes &gt; 0))) {
    long got = avail - stm-&gt;bufframes;
    void * other_buffer = stm-&gt;other_stream ? stm-&gt;other_stream-&gt;buffer : NULL;
    char * buftail =
        stm-&gt;buffer + WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, stm-&gt;bufframes);
    long requested;

    /* Correct read size to the other stream available frames */
    if (stm-&gt;other_stream &amp;&amp;
        got &gt; (snd_pcm_sframes_t)stm-&gt;other_stream-&gt;bufframes) {
      got = stm-&gt;other_stream-&gt;bufframes;
    }

    requested = got;
    pthread_mutex_unlock(&amp;stm-&gt;mutex);
    got = stm-&gt;data_callback(stm, stm-&gt;user_ptr, other_buffer, buftail, got);
    pthread_mutex_lock(&amp;stm-&gt;mutex);

    if (got &lt; 0) {
      avail = got; // the error handler below will recover us
    } else {
      stm-&gt;bufframes += got;

      if (stm-&gt;other_stream) {
        stream_buffer_decrement(stm-&gt;other_stream, got);
      }
      if (got &lt; requested) {
        draining = 1;
      }
    }
  }

  /* Playback: Still don&#039;t have enough data? Add some silence. */
  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp;
      avail &gt; (snd_pcm_sframes_t)stm-&gt;bufframes) {
    long drain_frames = avail - stm-&gt;bufframes;
    double drain_time = (double)drain_frames / stm-&gt;params.rate;

    char * buftail =
        stm-&gt;buffer + WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, stm-&gt;bufframes);
    memset(buftail, 0, WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, drain_frames));
    stm-&gt;bufframes = avail;

    /* Mark as draining, unless we&#039;re waiting for capture */
    if (!stm-&gt;other_stream || draining || stm-&gt;other_stream-&gt;bufframes &gt; 0) {
      set_timeout(&amp;stm-&gt;drain_timeout, drain_time * 1000);

      draining = 1;
    }
  }

  /* Playback: Have enough data and no errors. Let&#039;s write it out. */
  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp; avail &gt; 0) {
    snd_pcm_sframes_t wrote;

    if (stm-&gt;params.format == CUBEB_SAMPLE_FLOAT32NE) {
      float * b = (float *)stm-&gt;buffer;
      for (uint32_t i = 0; i &lt; avail * stm-&gt;params.channels; i++) {
        b[i] *= stm-&gt;volume;
      }
    } else {
      short * b = (short *)stm-&gt;buffer;
      for (uint32_t i = 0; i &lt; avail * stm-&gt;params.channels; i++) {
        b[i] *= stm-&gt;volume;
      }
    }

    wrote = WRAP(snd_pcm_writei)(stm-&gt;pcm, stm-&gt;buffer, avail);
    if (wrote &lt; 0) {
      avail = wrote; // the error handler below will recover us
    } else {
      stream_buffer_decrement(stm, wrote);

      stm-&gt;stream_position += wrote;
      gettimeofday(&amp;stm-&gt;last_activity, NULL);
    }
  }

  /* Got some error? Let&#039;s try to recover the stream. */
  if (avail &lt; 0) {
    avail = WRAP(snd_pcm_recover)(stm-&gt;pcm, avail, 0);

    /* Capture pcm must be started after initial setup/recover */
    if (avail &gt;= 0 &amp;&amp; stm-&gt;stream_type == SND_PCM_STREAM_CAPTURE &amp;&amp;
        WRAP(snd_pcm_state)(stm-&gt;pcm) == SND_PCM_STATE_PREPARED) {
      avail = WRAP(snd_pcm_start)(stm-&gt;pcm);
    }
  }

  /* Failed to recover, this stream must be broken. */
  if (avail &lt; 0) {
    pthread_mutex_unlock(&amp;stm-&gt;mutex);
    stm-&gt;state_callback(stm, stm-&gt;user_ptr, CUBEB_STATE_ERROR);
    return ERROR;
  }

  pthread_mutex_unlock(&amp;stm-&gt;mutex);
  return draining ? DRAINING : RUNNING;
}

static int
alsa_run(cubeb * ctx)
{
  int r;
  int timeout;
  int i;
  char dummy;
  cubeb_stream * stm;
  enum stream_state state;

  pthread_mutex_lock(&amp;ctx-&gt;mutex);

  if (ctx-&gt;rebuild) {
    rebuild(ctx);
  }

  /* Wake up at least once per second for the watchdog. */
  timeout = 1000;
  for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
    stm = ctx-&gt;streams[i];
    if (stm &amp;&amp; stm-&gt;state == DRAINING) {
      r = ms_until(&amp;stm-&gt;drain_timeout);
      if (r &lt; 0) {
        r = 0;
      }
      if (timeout &gt; r) {
        timeout = r;
      }
    }
  }

  pthread_mutex_unlock(&amp;ctx-&gt;mutex);
  r = poll(ctx-&gt;fds, ctx-&gt;nfds, timeout);
  pthread_mutex_lock(&amp;ctx-&gt;mutex);

  if (r &gt; 0) {
    if (ctx-&gt;fds[0].revents &amp; POLLIN) {
      if (read(ctx-&gt;control_fd_read, &amp;dummy, 1) &lt; 0) {
        /* ignore read error */
      }

      if (ctx-&gt;shutdown) {
        pthread_mutex_unlock(&amp;ctx-&gt;mutex);
        return -1;
      }
    }

    for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
      stm = ctx-&gt;streams[i];
      /* We can&#039;t use snd_pcm_poll_descriptors_revents here because of
         https://github.com/kinetiknz/cubeb/issues/135. */
      if (stm &amp;&amp; stm-&gt;state == RUNNING &amp;&amp; stm-&gt;fds &amp;&amp;
          any_revents(stm-&gt;fds, stm-&gt;nfds)) {
        int other_stream_running =
            !stm-&gt;other_stream || stm-&gt;other_stream-&gt;state == RUNNING;
        alsa_set_stream_state(stm, PROCESSING);
        pthread_mutex_unlock(&amp;ctx-&gt;mutex);
        state = alsa_process_stream(stm, other_stream_running);
        pthread_mutex_lock(&amp;ctx-&gt;mutex);
        if (state == DRAINING) {
          alsa_set_draining(stm);
        } else if (state == INACTIVE) {
          alsa_set_stream_state(stm, state);
          stm-&gt;state_callback(stm, stm-&gt;user_ptr, CUBEB_STATE_STOPPED);
        } else {
          alsa_set_stream_state(stm, state);
        }
      }
    }
  } else if (r == 0) {
    for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
      stm = ctx-&gt;streams[i];
      if (stm) {
        if (stm-&gt;state == DRAINING &amp;&amp; ms_since(&amp;stm-&gt;drain_timeout) &gt;= 0) {
          alsa_set_stream_state(stm, INACTIVE);
          if (!stm-&gt;other_stream ||
              stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK) {
            stm-&gt;state_callback(stm, stm-&gt;user_ptr, CUBEB_STATE_DRAINED);
          }
        } else if (stm-&gt;state == RUNNING &amp;&amp;
                   ms_since(&amp;stm-&gt;last_activity) &gt; CUBEB_WATCHDOG_MS) {
          alsa_set_stream_state(stm, ERROR);
          stm-&gt;state_callback(stm, stm-&gt;user_ptr, CUBEB_STATE_ERROR);
        }
      }
    }
  }

  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  return 0;
}

static void *
alsa_run_thread(void * context)
{
  cubeb * ctx = context;
  int r;

  CUBEB_REGISTER_THREAD(&quot;cubeb rendering thread&quot;);

  do {
    r = alsa_run(ctx);
  } while (r &gt;= 0);

  CUBEB_UNREGISTER_THREAD();

  return NULL;
}

static snd_config_t *
get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
{
  int r;
  snd_config_t * slave_pcm;
  snd_config_t * slave_def;
  snd_config_t * pcm;
  char const * string;
  char node_name[64];

  slave_def = NULL;

  r = WRAP(snd_config_search)(root_pcm, &quot;slave&quot;, &amp;slave_pcm);
  if (r &lt; 0) {
    return NULL;
  }

  r = WRAP(snd_config_get_string)(slave_pcm, &amp;string);
  if (r &gt;= 0) {
    r = WRAP(snd_config_search_definition)(lconf, &quot;pcm_slave&quot;, string,
                                           &amp;slave_def);
    if (r &lt; 0) {
      return NULL;
    }
  }

  do {
    r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, &quot;pcm&quot;, &amp;pcm);
    if (r &lt; 0) {
      break;
    }

    r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &amp;string);
    if (r &lt; 0) {
      break;
    }

    r = snprintf(node_name, sizeof(node_name), &quot;pcm.%s&quot;, string);
    if (r &lt; 0 || r &gt; (int)sizeof(node_name)) {
      break;
    }
    r = WRAP(snd_config_search)(lconf, node_name, &amp;pcm);
    if (r &lt; 0) {
      break;
    }

    return pcm;
  } while (0);

  if (slave_def) {
    WRAP(snd_config_delete)(slave_def);
  }

  return NULL;
}

/* Work around PulseAudio ALSA plugin bug where the PA server forces a
   higher than requested latency, but the plugin does not update its (and
   ALSA&#039;s) internal state to reflect that, leading to an immediate underrun
   situation.  Inspired by WINE&#039;s make_handle_underrun_config.
   Reference: http://mailman.alsa-project.org/pipermail/alsa-devel/2012-July/05
 */
static snd_config_t *
init_local_config_with_workaround(char const * pcm_name)
{
  int r;
  snd_config_t * lconf;
  snd_config_t * pcm_node;
  snd_config_t * node;
  char const * string;
  char node_name[64];

  lconf = NULL;

  if (WRAP(snd_config) == NULL) {
    return NULL;
  }

  r = WRAP(snd_config_copy)(&amp;lconf, WRAP(snd_config));
  if (r &lt; 0) {
    return NULL;
  }

  do {
    r = WRAP(snd_config_search_definition)(lconf, &quot;pcm&quot;, pcm_name, &amp;pcm_node);
    if (r &lt; 0) {
      break;
    }

    r = WRAP(snd_config_get_id)(pcm_node, &amp;string);
    if (r &lt; 0) {
      break;
    }

    r = snprintf(node_name, sizeof(node_name), &quot;pcm.%s&quot;, string);
    if (r &lt; 0 || r &gt; (int)sizeof(node_name)) {
      break;
    }
    r = WRAP(snd_config_search)(lconf, node_name, &amp;pcm_node);
    if (r &lt; 0) {
      break;
    }

    /* If this PCM has a slave, walk the slave configurations until we reach the
     * bottom. */
    while ((node = get_slave_pcm_node(lconf, pcm_node)) != NULL) {
      pcm_node = node;
    }

    /* Fetch the PCM node&#039;s type, and bail out if it&#039;s not the PulseAudio
     * plugin. */
    r = WRAP(snd_config_search)(pcm_node, &quot;type&quot;, &amp;node);
    if (r &lt; 0) {
      break;
    }

    r = WRAP(snd_config_get_string)(node, &amp;string);
    if (r &lt; 0) {
      break;
    }

    if (strcmp(string, &quot;pulse&quot;) != 0) {
      break;
    }

    /* Don&#039;t clobber an explicit existing handle_underrun value, set it only
       if it doesn&#039;t already exist. */
    r = WRAP(snd_config_search)(pcm_node, &quot;handle_underrun&quot;, &amp;node);
    if (r != -ENOENT) {
      break;
    }

    /* Disable pcm_pulse&#039;s asynchronous underrun handling. */
    r = WRAP(snd_config_imake_integer)(&amp;node, &quot;handle_underrun&quot;, 0);
    if (r &lt; 0) {
      break;
    }

    r = WRAP(snd_config_add)(pcm_node, node);
    if (r &lt; 0) {
      break;
    }

    return lconf;
  } while (0);

  WRAP(snd_config_delete)(lconf);

  return NULL;
}

static int
alsa_locked_pcm_open(snd_pcm_t ** pcm, char const * pcm_name,
                     snd_pcm_stream_t stream, snd_config_t * local_config)
{
  int r;

  pthread_mutex_lock(&amp;cubeb_alsa_mutex);
  if (local_config) {
    r = WRAP(snd_pcm_open_lconf)(pcm, pcm_name, stream, SND_PCM_NONBLOCK,
                                 local_config);
  } else {
    r = WRAP(snd_pcm_open)(pcm, pcm_name, stream, SND_PCM_NONBLOCK);
  }
  pthread_mutex_unlock(&amp;cubeb_alsa_mutex);

  return r;
}

static int
alsa_locked_pcm_close(snd_pcm_t * pcm)
{
  int r;

  pthread_mutex_lock(&amp;cubeb_alsa_mutex);
  r = WRAP(snd_pcm_close)(pcm);
  pthread_mutex_unlock(&amp;cubeb_alsa_mutex);

  return r;
}

static int
alsa_register_stream(cubeb * ctx, cubeb_stream * stm)
{
  int i;

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
    if (!ctx-&gt;streams[i]) {
      ctx-&gt;streams[i] = stm;
      break;
    }
  }
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  return i == CUBEB_STREAM_MAX;
}

static void
alsa_unregister_stream(cubeb_stream * stm)
{
  cubeb * ctx;
  int i;

  ctx = stm-&gt;context;

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  for (i = 0; i &lt; CUBEB_STREAM_MAX; ++i) {
    if (ctx-&gt;streams[i] == stm) {
      ctx-&gt;streams[i] = NULL;
      break;
    }
  }
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);
}

static void
silent_error_handler(char const * file, int line, char const * function,
                     int err, char const * fmt, ...)
{
  (void)file;
  (void)line;
  (void)function;
  (void)err;
  (void)fmt;
}

/*static*/ int
alsa_init(cubeb ** context, char const * context_name)
{
  (void)context_name;
  void * libasound = NULL;
  cubeb * ctx;
  int r;
  int i;
  int fd[2];
  pthread_attr_t attr;
  snd_pcm_t * dummy;

  assert(context);
  *context = NULL;

#ifndef DISABLE_LIBASOUND_DLOPEN
  libasound = dlopen(&quot;libasound.so.2&quot;, RTLD_LAZY);
  if (!libasound) {
    libasound = dlopen(&quot;libasound.so&quot;, RTLD_LAZY);
    if (!libasound) {
      return CUBEB_ERROR;
    }
  }

#define LOAD(x)                                                                \
  {                                                                            \
    cubeb_##x = dlsym(libasound, #x);                                          \
    if (!cubeb_##x) {                                                          \
      dlclose(libasound);                                                      \
      return CUBEB_ERROR;                                                      \
    }                                                                          \
  }

  LIBASOUND_API_VISIT(LOAD);
#undef LOAD
#endif

  pthread_mutex_lock(&amp;cubeb_alsa_mutex);
  if (!cubeb_alsa_error_handler_set) {
    WRAP(snd_lib_error_set_handler)(silent_error_handler);
    cubeb_alsa_error_handler_set = 1;
  }
  pthread_mutex_unlock(&amp;cubeb_alsa_mutex);

  ctx = calloc(1, sizeof(*ctx));
  assert(ctx);

  ctx-&gt;ops = &amp;alsa_ops;
  ctx-&gt;libasound = libasound;

  r = pthread_mutex_init(&amp;ctx-&gt;mutex, NULL);
  assert(r == 0);

  r = pipe(fd);
  assert(r == 0);

  for (i = 0; i &lt; 2; ++i) {
    fcntl(fd[i], F_SETFD, fcntl(fd[i], F_GETFD) | FD_CLOEXEC);
    fcntl(fd[i], F_SETFL, fcntl(fd[i], F_GETFL) | O_NONBLOCK);
  }

  ctx-&gt;control_fd_read = fd[0];
  ctx-&gt;control_fd_write = fd[1];

  /* Force an early rebuild when alsa_run is first called to ensure fds and
     nfds have been initialized. */
  ctx-&gt;rebuild = 1;

  r = pthread_attr_init(&amp;attr);
  assert(r == 0);

  r = pthread_attr_setstacksize(&amp;attr, 256 * 1024);
  assert(r == 0);

  r = pthread_create(&amp;ctx-&gt;thread, &amp;attr, alsa_run_thread, ctx);
  assert(r == 0);

  r = pthread_attr_destroy(&amp;attr);
  assert(r == 0);

  /* Open a dummy PCM to force the configuration space to be evaluated so that
     init_local_config_with_workaround can find and modify the default node. */
  r = alsa_locked_pcm_open(&amp;dummy, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK,
                           NULL);
  if (r &gt;= 0) {
    alsa_locked_pcm_close(dummy);
  }
  ctx-&gt;is_pa = 0;
  pthread_mutex_lock(&amp;cubeb_alsa_mutex);
  ctx-&gt;local_config = init_local_config_with_workaround(CUBEB_ALSA_PCM_NAME);
  pthread_mutex_unlock(&amp;cubeb_alsa_mutex);
  if (ctx-&gt;local_config) {
    ctx-&gt;is_pa = 1;
    r = alsa_locked_pcm_open(&amp;dummy, CUBEB_ALSA_PCM_NAME,
                             SND_PCM_STREAM_PLAYBACK, ctx-&gt;local_config);
    /* If we got a local_config, we found a PA PCM.  If opening a PCM with that
       config fails with EINVAL, the PA PCM is too old for this workaround. */
    if (r == -EINVAL) {
      pthread_mutex_lock(&amp;cubeb_alsa_mutex);
      WRAP(snd_config_delete)(ctx-&gt;local_config);
      pthread_mutex_unlock(&amp;cubeb_alsa_mutex);
      ctx-&gt;local_config = NULL;
    } else if (r &gt;= 0) {
      alsa_locked_pcm_close(dummy);
    }
  }

  *context = ctx;

  return CUBEB_OK;
}

static char const *
alsa_get_backend_id(cubeb * ctx)
{
  (void)ctx;
  return &quot;alsa&quot;;
}

static void
alsa_destroy(cubeb * ctx)
{
  int r;

  assert(ctx);

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  ctx-&gt;shutdown = 1;
  poll_wake(ctx);
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  r = pthread_join(ctx-&gt;thread, NULL);
  assert(r == 0);

  close(ctx-&gt;control_fd_read);
  close(ctx-&gt;control_fd_write);
  pthread_mutex_destroy(&amp;ctx-&gt;mutex);
  free(ctx-&gt;fds);

  if (ctx-&gt;local_config) {
    pthread_mutex_lock(&amp;cubeb_alsa_mutex);
    WRAP(snd_config_delete)(ctx-&gt;local_config);
    pthread_mutex_unlock(&amp;cubeb_alsa_mutex);
  }
#ifndef DISABLE_LIBASOUND_DLOPEN
  if (ctx-&gt;libasound) {
    dlclose(ctx-&gt;libasound);
  }
#endif
  free(ctx);
}

static void
alsa_stream_destroy(cubeb_stream * stm);

static int
alsa_stream_init_single(cubeb * ctx, cubeb_stream ** stream,
                        char const * stream_name, snd_pcm_stream_t stream_type,
                        cubeb_devid deviceid,
                        cubeb_stream_params * stream_params,
                        unsigned int latency_frames,
                        cubeb_data_callback data_callback,
                        cubeb_state_callback state_callback, void * user_ptr)
{
  (void)stream_name;
  cubeb_stream * stm;
  int r;
  snd_pcm_format_t format;
  snd_pcm_uframes_t period_size;
  int latency_us = 0;
  char const * pcm_name =
      deviceid ? (char const *)deviceid : CUBEB_ALSA_PCM_NAME;

  assert(ctx &amp;&amp; stream);

  *stream = NULL;

  if (stream_params-&gt;prefs &amp; CUBEB_STREAM_PREF_LOOPBACK) {
    return CUBEB_ERROR_NOT_SUPPORTED;
  }

  switch (stream_params-&gt;format) {
  case CUBEB_SAMPLE_S16LE:
    format = SND_PCM_FORMAT_S16_LE;
    break;
  case CUBEB_SAMPLE_S16BE:
    format = SND_PCM_FORMAT_S16_BE;
    break;
  case CUBEB_SAMPLE_FLOAT32LE:
    format = SND_PCM_FORMAT_FLOAT_LE;
    break;
  case CUBEB_SAMPLE_FLOAT32BE:
    format = SND_PCM_FORMAT_FLOAT_BE;
    break;
  default:
    return CUBEB_ERROR_INVALID_FORMAT;
  }

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  if (ctx-&gt;active_streams &gt;= CUBEB_STREAM_MAX) {
    pthread_mutex_unlock(&amp;ctx-&gt;mutex);
    return CUBEB_ERROR;
  }
  ctx-&gt;active_streams += 1;
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  stm = calloc(1, sizeof(*stm));
  assert(stm);

  stm-&gt;context = ctx;
  stm-&gt;data_callback = data_callback;
  stm-&gt;state_callback = state_callback;
  stm-&gt;user_ptr = user_ptr;
  stm-&gt;params = *stream_params;
  stm-&gt;state = INACTIVE;
  stm-&gt;volume = 1.0;
  stm-&gt;buffer = NULL;
  stm-&gt;bufframes = 0;
  stm-&gt;stream_type = stream_type;
  stm-&gt;other_stream = NULL;

  r = pthread_mutex_init(&amp;stm-&gt;mutex, NULL);
  assert(r == 0);

  r = pthread_cond_init(&amp;stm-&gt;cond, NULL);
  assert(r == 0);

  r = alsa_locked_pcm_open(&amp;stm-&gt;pcm, pcm_name, stm-&gt;stream_type,
                           ctx-&gt;local_config);
  if (r &lt; 0) {
    alsa_stream_destroy(stm);
    return CUBEB_ERROR;
  }

  r = WRAP(snd_pcm_nonblock)(stm-&gt;pcm, 1);
  assert(r == 0);

  latency_us = latency_frames * 1e6 / stm-&gt;params.rate;

  /* Ugly hack: the PA ALSA plugin allows buffer configurations that can&#039;t
     possibly work.  See https://bugzilla.mozilla.org/show_bug.cgi?id=761274.
     Only resort to this hack if the handle_underrun workaround failed. */
  if (!ctx-&gt;local_config &amp;&amp; ctx-&gt;is_pa) {
    const int min_latency = 5e5;
    latency_us = latency_us &lt; min_latency ? min_latency : latency_us;
  }

  r = WRAP(snd_pcm_set_params)(stm-&gt;pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
                               stm-&gt;params.channels, stm-&gt;params.rate, 1,
                               latency_us);
  if (r &lt; 0) {
    alsa_stream_destroy(stm);
    return CUBEB_ERROR_INVALID_FORMAT;
  }

  r = WRAP(snd_pcm_get_params)(stm-&gt;pcm, &amp;stm-&gt;buffer_size, &amp;period_size);
  assert(r == 0);

  /* Double internal buffer size to have enough space when waiting for the other
   * side of duplex connection */
  stm-&gt;buffer_size *= 2;
  stm-&gt;buffer =
      calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm-&gt;pcm, stm-&gt;buffer_size));
  assert(stm-&gt;buffer);

  stm-&gt;nfds = WRAP(snd_pcm_poll_descriptors_count)(stm-&gt;pcm);
  assert(stm-&gt;nfds &gt; 0);

  stm-&gt;saved_fds = calloc(stm-&gt;nfds, sizeof(struct pollfd));
  assert(stm-&gt;saved_fds);
  r = WRAP(snd_pcm_poll_descriptors)(stm-&gt;pcm, stm-&gt;saved_fds, stm-&gt;nfds);
  assert((nfds_t)r == stm-&gt;nfds);

  if (alsa_register_stream(ctx, stm) != 0) {
    alsa_stream_destroy(stm);
    return CUBEB_ERROR;
  }

  *stream = stm;

  return CUBEB_OK;
}

static int
alsa_stream_init(cubeb * ctx, cubeb_stream ** stream, char const * stream_name,
                 cubeb_devid input_device,
                 cubeb_stream_params * input_stream_params,
                 cubeb_devid output_device,
                 cubeb_stream_params * output_stream_params,
                 unsigned int latency_frames, cubeb_data_callback data_callback,
                 cubeb_state_callback state_callback, void * user_ptr)
{
  int result = CUBEB_OK;
  cubeb_stream *instm = NULL, *outstm = NULL;

  if (result == CUBEB_OK &amp;&amp; input_stream_params) {
    result = alsa_stream_init_single(ctx, &amp;instm, stream_name,
                                     SND_PCM_STREAM_CAPTURE, input_device,
                                     input_stream_params, latency_frames,
                                     data_callback, state_callback, user_ptr);
  }

  if (result == CUBEB_OK &amp;&amp; output_stream_params) {
    result = alsa_stream_init_single(ctx, &amp;outstm, stream_name,
                                     SND_PCM_STREAM_PLAYBACK, output_device,
                                     output_stream_params, latency_frames,
                                     data_callback, state_callback, user_ptr);
  }

  if (result == CUBEB_OK &amp;&amp; input_stream_params &amp;&amp; output_stream_params) {
    instm-&gt;other_stream = outstm;
    outstm-&gt;other_stream = instm;
  }

  if (result != CUBEB_OK &amp;&amp; instm) {
    alsa_stream_destroy(instm);
  }

  *stream = outstm ? outstm : instm;

  return result;
}

static void
alsa_stream_destroy(cubeb_stream * stm)
{
  int r;
  cubeb * ctx;

  assert(stm &amp;&amp; (stm-&gt;state == INACTIVE || stm-&gt;state == ERROR ||
                 stm-&gt;state == DRAINING));

  ctx = stm-&gt;context;

  if (stm-&gt;other_stream) {
    stm-&gt;other_stream-&gt;other_stream = NULL; // to stop infinite recursion
    alsa_stream_destroy(stm-&gt;other_stream);
  }

  pthread_mutex_lock(&amp;stm-&gt;mutex);
  if (stm-&gt;pcm) {
    if (stm-&gt;state == DRAINING) {
      WRAP(snd_pcm_drain)(stm-&gt;pcm);
    }
    alsa_locked_pcm_close(stm-&gt;pcm);
    stm-&gt;pcm = NULL;
  }
  free(stm-&gt;saved_fds);
  pthread_mutex_unlock(&amp;stm-&gt;mutex);
  pthread_mutex_destroy(&amp;stm-&gt;mutex);

  r = pthread_cond_destroy(&amp;stm-&gt;cond);
  assert(r == 0);

  alsa_unregister_stream(stm);

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  assert(ctx-&gt;active_streams &gt;= 1);
  ctx-&gt;active_streams -= 1;
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  free(stm-&gt;buffer);

  free(stm);
}

static int
alsa_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
{
  int r;
  cubeb_stream * stm;
  snd_pcm_hw_params_t * hw_params;
  cubeb_stream_params params;
  params.rate = 44100;
  params.format = CUBEB_SAMPLE_FLOAT32NE;
  params.channels = 2;

  snd_pcm_hw_params_alloca(&amp;hw_params);

  assert(ctx);

  r = alsa_stream_init(ctx, &amp;stm, &quot;&quot;, NULL, NULL, NULL, &amp;params, 100, NULL,
                       NULL, NULL);
  if (r != CUBEB_OK) {
    return CUBEB_ERROR;
  }

  assert(stm);

  r = WRAP(snd_pcm_hw_params_any)(stm-&gt;pcm, hw_params);
  if (r &lt; 0) {
    return CUBEB_ERROR;
  }

  r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels);
  if (r &lt; 0) {
    return CUBEB_ERROR;
  }

  /* Cap at reasonable maximum to filter driver placeholder values */  
  if (*max_channels &gt; 64) {  
    *max_channels = 64;  
  }  

  alsa_stream_destroy(stm);

  return CUBEB_OK;
}

static int
alsa_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
{
  (void)ctx;
  int r, dir;
  snd_pcm_t * pcm;
  snd_pcm_hw_params_t * hw_params;

  snd_pcm_hw_params_alloca(&amp;hw_params);

  /* get a pcm, disabling resampling, so we get a rate the
   * hardware/dmix/pulse/etc. supports. */
  r = WRAP(snd_pcm_open)(&amp;pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK,
                         SND_PCM_NO_AUTO_RESAMPLE);
  if (r &lt; 0) {
    return CUBEB_ERROR;
  }

  r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
  if (r &lt; 0) {
    WRAP(snd_pcm_close)(pcm);
    return CUBEB_ERROR;
  }

  r = WRAP(snd_pcm_hw_params_get_rate)(hw_params, rate, &amp;dir);
  if (r &gt;= 0) {
    /* There is a default rate: use it. */
    WRAP(snd_pcm_close)(pcm);
    return CUBEB_OK;
  }

  /* Use a common rate, alsa may adjust it based on hw/etc. capabilities. */
  *rate = 44100;

  r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL);
  if (r &lt; 0) {
    WRAP(snd_pcm_close)(pcm);
    return CUBEB_ERROR;
  }

  WRAP(snd_pcm_close)(pcm);

  return CUBEB_OK;
}

static int
alsa_get_min_latency(cubeb * ctx, cubeb_stream_params params,
                     uint32_t * latency_frames)
{
  (void)ctx;
  /* 40ms is found to be an acceptable minimum, even on a super low-end
   * machine. */
  *latency_frames = 40 * params.rate / 1000;

  return CUBEB_OK;
}

static int
alsa_stream_start(cubeb_stream * stm)
{
  cubeb * ctx;

  assert(stm);
  ctx = stm-&gt;context;

  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp; stm-&gt;other_stream) {
    int r = alsa_stream_start(stm-&gt;other_stream);
    if (r != CUBEB_OK)
      return r;
  }

  pthread_mutex_lock(&amp;stm-&gt;mutex);
  /* Capture pcm must be started after initial setup/recover */
  if (stm-&gt;stream_type == SND_PCM_STREAM_CAPTURE &amp;&amp;
      WRAP(snd_pcm_state)(stm-&gt;pcm) == SND_PCM_STATE_PREPARED) {
    WRAP(snd_pcm_start)(stm-&gt;pcm);
  }
  WRAP(snd_pcm_pause)(stm-&gt;pcm, 0);
  gettimeofday(&amp;stm-&gt;last_activity, NULL);
  pthread_mutex_unlock(&amp;stm-&gt;mutex);

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  if (stm-&gt;state != INACTIVE) {
    pthread_mutex_unlock(&amp;ctx-&gt;mutex);
    return CUBEB_ERROR;
  }
  alsa_set_stream_state(stm, RUNNING);
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  return CUBEB_OK;
}

static int
alsa_stream_stop(cubeb_stream * stm)
{
  cubeb * ctx;
  int r;

  assert(stm);
  ctx = stm-&gt;context;

  if (stm-&gt;stream_type == SND_PCM_STREAM_PLAYBACK &amp;&amp; stm-&gt;other_stream) {
    int r = alsa_stream_stop(stm-&gt;other_stream);
    if (r != CUBEB_OK)
      return r;
  }

  pthread_mutex_lock(&amp;ctx-&gt;mutex);
  while (stm-&gt;state == PROCESSING) {
    r = pthread_cond_wait(&amp;stm-&gt;cond, &amp;ctx-&gt;mutex);
    assert(r == 0);
  }

  alsa_set_stream_state(stm, INACTIVE);
  pthread_mutex_unlock(&amp;ctx-&gt;mutex);

  pthread_mutex_lock(&amp;stm-&gt;mutex);
  WRAP(snd_pcm_pause)(stm-&gt;pcm, 1);
  pthread_mutex_unlock(&amp;stm-&gt;mutex);

  return CUBEB_OK;
}

static int
alsa_stream_get_position(cubeb_stream * stm, uint64_t * position)
{
  snd_pcm_sframes_t delay;

  assert(stm &amp;&amp; position);

  pthread_mutex_lock(&amp;stm-&gt;mutex);

  delay = -1;
  if (WRAP(snd_pcm_state)(stm-&gt;pcm) != SND_PCM_STATE_RUNNING ||
      WRAP(snd_pcm_delay)(stm-&gt;pcm, &amp;delay) != 0) {
    *position = stm-&gt;last_position;
    pthread_mutex_unlock(&amp;stm-&gt;mutex);
    return CUBEB_OK;
  }

  assert(delay &gt;= 0);

  *position = 0;
  if (stm-&gt;stream_position &gt;= (snd_pcm_uframes_t)delay) {
    *position = stm-&gt;stream_position - delay;
  }

  stm-&gt;last_position = *position;

  pthread_mutex_unlock(&amp;stm-&gt;mutex);
  return CUBEB_OK;
}

static int
alsa_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
{
  snd_pcm_sframes_t delay;
  /* This function returns the delay in frames until a frame written using
     snd_pcm_writei is sent to the DAC. The DAC delay should be &lt; 1ms anyways.
   */
  if (WRAP(snd_pcm_delay)(stm-&gt;pcm, &amp;delay)) {
    return CUBEB_ERROR;
  }

  *latency = delay;

  return CUBEB_OK;
}

static int
alsa_stream_set_volume(cubeb_stream * stm, float volume)
{
  /* setting the volume using an API call does not seem very stable/supported */
  pthread_mutex_lock(&amp;stm-&gt;mutex);
  stm-&gt;volume = volume;
  pthread_mutex_unlock(&amp;stm-&gt;mutex);

  return CUBEB_OK;
}

static int
alsa_enumerate_devices(cubeb * context, cubeb_device_type type,
                       cubeb_device_collection * collection)
{
  void **hints = NULL;
  void **hint;
  char *name = NULL;
  char *io = NULL;
  char *desc = NULL;
  cubeb_device_info * devinfop = NULL;
  int collection_cnt = 0;
  int r;

  if (!context)
    return CUBEB_ERROR;

  /* Get device name hints from ALSA */
  r = WRAP(snd_device_name_hint)(-1, &quot;pcm&quot;, &amp;hints);
  if (r &lt; 0) {
    LOG(&quot;Failed to get device name hints: %d&quot;, r);
    return CUBEB_ERROR;
  }

  /* Count devices first */
  for (hint = hints; *hint != NULL; hint++) {
    name = WRAP(snd_device_name_get_hint)(*hint, &quot;NAME&quot;);
    if (!name)
      continue;

    io = WRAP(snd_device_name_get_hint)(*hint, &quot;IOID&quot;);

    /* Filter by device type */
    if (type &amp; CUBEB_DEVICE_TYPE_INPUT &amp;&amp; io &amp;&amp; strcmp(io, &quot;Output&quot;) == 0) {
      free(name);
      if (io) free(io);
      continue;
    }
    if (type &amp; CUBEB_DEVICE_TYPE_OUTPUT &amp;&amp; io &amp;&amp; strcmp(io, &quot;Input&quot;) == 0) {
      free(name);
      if (io) free(io);
      continue;
    }

    free(name);
    if (io) free(io);
    collection_cnt++;
  }

  if (collection_cnt == 0) {
    WRAP(snd_device_name_free_hint)(hints);
    return CUBEB_OK;
  }

  devinfop = calloc(collection_cnt, sizeof(cubeb_device_info));
  if (!devinfop) {
    WRAP(snd_device_name_free_hint)(hints);
    return CUBEB_ERROR;
  }

  collection_cnt = 0;
  for (hint = hints; *hint != NULL; hint++) {
    snd_pcm_t * pcm = NULL;
    snd_pcm_hw_params_t * hw_params;
    snd_pcm_stream_t stream_type;
    cubeb_device_info cdi = {0};
    uint32_t min_rate, max_rate;
    uint32_t min_channels, max_channels;
    int dir;

    name = WRAP(snd_device_name_get_hint)(*hint, &quot;NAME&quot;);
    if (!name)
      continue;

    io = WRAP(snd_device_name_get_hint)(*hint, &quot;IOID&quot;);
    desc = WRAP(snd_device_name_get_hint)(*hint, &quot;DESC&quot;);

    /* Filter by device type */
    if (type &amp; CUBEB_DEVICE_TYPE_INPUT &amp;&amp; io &amp;&amp; strcmp(io, &quot;Output&quot;) == 0) {
      goto cleanup_hint;
    }
    if (type &amp; CUBEB_DEVICE_TYPE_OUTPUT &amp;&amp; io &amp;&amp; strcmp(io, &quot;Input&quot;) == 0) {
      goto cleanup_hint;
    }

    /* Determine stream type */
    if (io &amp;&amp; strcmp(io, &quot;Input&quot;) == 0) {
      stream_type = SND_PCM_STREAM_CAPTURE;
      cdi.type = CUBEB_DEVICE_TYPE_INPUT;
    } else if (io &amp;&amp; strcmp(io, &quot;Output&quot;) == 0) {
      stream_type = SND_PCM_STREAM_PLAYBACK;
      cdi.type = CUBEB_DEVICE_TYPE_OUTPUT;
    } else {
      /* Try both if IOID is not specified */
      stream_type = (type &amp; CUBEB_DEVICE_TYPE_OUTPUT) ? 
                     SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE;
      cdi.type = (type &amp; CUBEB_DEVICE_TYPE_OUTPUT) ? 
                 CUBEB_DEVICE_TYPE_OUTPUT : CUBEB_DEVICE_TYPE_INPUT;
    }

    /* Open device to query capabilities */
    r = WRAP(snd_pcm_open)(&amp;pcm, name, stream_type, SND_PCM_NONBLOCK);
    if (r &lt; 0) {
      LOG(&quot;Failed to open device %s: %d&quot;, name, r);
      goto cleanup_hint;
    }

    snd_pcm_hw_params_alloca(&amp;hw_params);
    r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
    if (r &lt; 0) {
      LOG(&quot;Failed to get hw params for device %s: %d&quot;, name, r);
      WRAP(snd_pcm_close)(pcm);
      goto cleanup_hint;
    }

    /* Query format capabilities */
    cdi.format = 0;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_S16_LE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_S16LE;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_S16_BE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_S16BE;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_S32_LE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_S32LE;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_S32_BE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_S32BE;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_FLOAT_LE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_F32LE;
    if (WRAP(snd_pcm_hw_params_test_format)(pcm, hw_params, SND_PCM_FORMAT_FLOAT_BE) == 0)
      cdi.format |= CUBEB_DEVICE_FMT_F32BE;

    /* Set default format - prefer S32 for high-quality audio */
#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
    if (cdi.format &amp; CUBEB_DEVICE_FMT_S32BE)
      cdi.default_format = CUBEB_DEVICE_FMT_S32BE;
    else if (cdi.format &amp; CUBEB_DEVICE_FMT_S16BE)
      cdi.default_format = CUBEB_DEVICE_FMT_S16BE;
    else if (cdi.format &amp; CUBEB_DEVICE_FMT_F32BE)
      cdi.default_format = CUBEB_DEVICE_FMT_F32BE;
    else
      cdi.default_format = CUBEB_DEVICE_FMT_S16BE;
#else
    if (cdi.format &amp; CUBEB_DEVICE_FMT_S32LE)
      cdi.default_format = CUBEB_DEVICE_FMT_S32LE;
    else if (cdi.format &amp; CUBEB_DEVICE_FMT_S16LE)
      cdi.default_format = CUBEB_DEVICE_FMT_S16LE;
    else if (cdi.format &amp; CUBEB_DEVICE_FMT_F32LE)
      cdi.default_format = CUBEB_DEVICE_FMT_F32LE;
    else
      cdi.default_format = CUBEB_DEVICE_FMT_S16LE;
#endif

    /* Query rate range */
    r = WRAP(snd_pcm_hw_params_get_rate_min)(hw_params, &amp;min_rate, &amp;dir);
    if (r &lt; 0)
      min_rate = 44100;
    r = WRAP(snd_pcm_hw_params_get_rate_max)(hw_params, &amp;max_rate, &amp;dir);
    if (r &lt; 0)
      max_rate = 48000;

    /* Query channel range */
    r = WRAP(snd_pcm_hw_params_get_channels_min)(hw_params, &amp;min_channels);
    if (r &lt; 0)
      min_channels = 1;
    r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, &amp;max_channels);
    if (r &lt; 0)
      max_channels = 2;

    /* Get default rate */
    r = WRAP(snd_pcm_hw_params_get_rate)(hw_params, &amp;cdi.default_rate, &amp;dir);
    if (r &lt; 0)
      cdi.default_rate = 44100;

    WRAP(snd_pcm_close)(pcm);

    /* Fill device info */
    cdi.device_id = strdup(name);
    cdi.devid = (cubeb_devid)cdi.device_id;
    cdi.friendly_name = desc ? strdup(desc) : strdup(name);
    cdi.group_id = strdup(name);
    cdi.vendor_name = NULL;
    cdi.state = CUBEB_DEVICE_STATE_ENABLED;
    cdi.preferred = CUBEB_DEVICE_PREF_NONE;
    cdi.max_channels = max_channels;
    cdi.min_rate = min_rate;
    cdi.max_rate = max_rate;
    cdi.latency_lo = 0;
    cdi.latency_hi = 0;

    if (!cdi.device_id || !cdi.friendly_name || !cdi.group_id) {
      free((void *)cdi.device_id);
      free((void *)cdi.friendly_name);
      free((void *)cdi.group_id);
      goto cleanup_hint;
    }

    devinfop[collection_cnt++] = cdi;

cleanup_hint:
    free(name);
    if (io) free(io);
    if (desc) free(desc);
  }

  WRAP(snd_device_name_free_hint)(hints);

  collection-&gt;device = devinfop;
  collection-&gt;count = collection_cnt;

  return CUBEB_OK;
}

static int  
alsa_device_collection_destroy(cubeb * context,  
                               cubeb_device_collection * collection)  
{  
  size_t i;  
  
  (void)context;  
  
  for (i = 0; i &lt; collection-&gt;count; ++i) {  
    free((void *)collection-&gt;device[i].device_id);  
    free((void *)collection-&gt;device[i].friendly_name);  
    free((void *)collection-&gt;device[i].group_id);  
    free((void *)collection-&gt;device[i].vendor_name);  
  }  
  free(collection-&gt;device);  
  return CUBEB_OK;  
}

static struct cubeb_ops const alsa_ops = {
    .init = alsa_init,
    .get_backend_id = alsa_get_backend_id,
    .get_max_channel_count = alsa_get_max_channel_count,
    .get_min_latency = alsa_get_min_latency,
    .get_preferred_sample_rate = alsa_get_preferred_sample_rate,
    .get_supported_input_processing_params = NULL,
    .enumerate_devices = alsa_enumerate_devices,
    .device_collection_destroy = alsa_device_collection_destroy,
    .destroy = alsa_destroy,
    .stream_init = alsa_stream_init,
    .stream_destroy = alsa_stream_destroy,
    .stream_start = alsa_stream_start,
    .stream_stop = alsa_stream_stop,
    .stream_get_position = alsa_stream_get_position,
    .stream_get_latency = alsa_stream_get_latency,
    .stream_get_input_latency = NULL,
    .stream_set_volume = alsa_stream_set_volume,
    .stream_set_name = NULL,
    .stream_get_current_device = NULL,
    .stream_set_input_mute = NULL,
    .stream_set_input_processing_params = NULL,
    .stream_device_destroy = NULL,
    .stream_register_device_changed_callback = NULL,
    .register_device_collection_changed = NULL};</code></pre></div><p><strong>Patches for Firefox</strong></p><div class="codebox"><pre class="vscroll"><code>$ cat 0001-Add-S32-format-to-the-Firefox-API.patch
From 80bbf447a62e6136f54c4938b99487135383276b Mon Sep 17 00:00:00 2001
From: Devuan
Date: Tue, 7 Jul 2026 22:35:36 +0200
Subject: [PATCH 1/2] Add S32 format to the Firefox API

- Add FMT_S32LE and FMT_S32BE constants to nsIAudioDeviceInfo.idl
- Update AudioDeviceInfo.cpp assertions to accept S32 formats
- Add S32 format conversion in CubebDeviceEnumerator.cpp
- Add local S32 format definitions for external cubeb support
- Update aboutSupport.js to display S32 format information
---
 dom/media/AudioDeviceInfo.cpp              |  5 +++--
 dom/media/CubebUtils.cpp                   |  1 +
 dom/media/nsIAudioDeviceInfo.idl           |  4 +++-
 dom/media/webrtc/CubebDeviceEnumerator.cpp | 14 ++++++++++++++
 toolkit/content/aboutSupport.js            |  4 ++++
 5 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/dom/media/AudioDeviceInfo.cpp b/dom/media/AudioDeviceInfo.cpp
index 072dd43d4ec1..a09e0adf71c3 100644
--- a/dom/media/AudioDeviceInfo.cpp
+++ b/dom/media/AudioDeviceInfo.cpp
@@ -49,10 +49,11 @@ AudioDeviceInfo::AudioDeviceInfo(
       mPreferred == PREF_NONE || mPreferred == PREF_ALL ||
           mPreferred &amp; (PREF_MULTIMEDIA | PREF_VOICE | PREF_NOTIFICATION),
       &quot;Wrong preferred value&quot;);
-  MOZ_ASSERT(mSupportedFormat &amp; (FMT_S16LE | FMT_S16BE | FMT_F32LE | FMT_F32BE),
+  MOZ_ASSERT(mSupportedFormat &amp; (FMT_S16LE | FMT_S16BE | FMT_F32LE | FMT_F32BE | FMT_S32LE | FMT_S32BE),
              &quot;Wrong supported format&quot;);
   MOZ_ASSERT(mDefaultFormat == FMT_S16LE || mDefaultFormat == FMT_S16BE ||
-                 mDefaultFormat == FMT_F32LE || mDefaultFormat == FMT_F32BE,
+                 mDefaultFormat == FMT_F32LE || mDefaultFormat == FMT_F32BE ||  
+                 mDefaultFormat == FMT_S32LE || mDefaultFormat == FMT_S32BE,  
              &quot;Wrong default format&quot;);
 }
 
diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp
index 72551b795af3..a9edab7bc358 100644
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -143,6 +143,7 @@ MOZ_RUNINIT std::unordered_map&lt;std::string, BackendLabel&gt;
         {&quot;alsa&quot;, BackendLabel::eAlsa},
         {&quot;jack&quot;, BackendLabel::eJack},
         {&quot;oss&quot;, BackendLabel::eOss},
+        {&quot;oss-fft&quot;, BackendLabel::eOss},
         {&quot;pulse&quot;, BackendLabel::ePulse},
         {&quot;pulse-rust&quot;, BackendLabel::ePulseRust},
         {&quot;sndio&quot;, BackendLabel::eSndio},
diff --git a/dom/media/nsIAudioDeviceInfo.idl b/dom/media/nsIAudioDeviceInfo.idl
index 0458ec1eb927..59d90a0ad3f5 100644
--- a/dom/media/nsIAudioDeviceInfo.idl
+++ b/dom/media/nsIAudioDeviceInfo.idl
@@ -33,11 +33,13 @@ interface nsIAudioDeviceInfo : nsISupports
   const unsigned short PREF_ALL           = 0x0F;
   readonly attribute unsigned short preferred;
 
-  // supported format, default format: S16LE/S16BE/F32LE/F32BE
+  // supported format, default format: S16LE/S16BE/F32LE/F32BE/S32LE/S32BE
   const unsigned short FMT_S16LE = 0x0010;
   const unsigned short FMT_S16BE = 0x0020;
   const unsigned short FMT_F32LE = 0x1000;
   const unsigned short FMT_F32BE = 0x2000;
+  const unsigned short FMT_S32LE = 0x0040;
+  const unsigned short FMT_S32BE = 0x0080;
   readonly attribute unsigned short supportedFormat;
   readonly attribute unsigned short defaultFormat;
 
diff --git a/dom/media/webrtc/CubebDeviceEnumerator.cpp b/dom/media/webrtc/CubebDeviceEnumerator.cpp
index 6e1520c3c714..0d2043cb497c 100644
--- a/dom/media/webrtc/CubebDeviceEnumerator.cpp
+++ b/dom/media/webrtc/CubebDeviceEnumerator.cpp
@@ -17,6 +17,14 @@
 #  include &quot;mozilla/mscom/EnsureMTA.h&quot;
 #endif
 
+// S32 format constants for external cubeb libraries that support them  
+#ifndef CUBEB_DEVICE_FMT_S32LE  
+#define CUBEB_DEVICE_FMT_S32LE 0x0040  
+#endif  
+#ifndef CUBEB_DEVICE_FMT_S32BE  
+#define CUBEB_DEVICE_FMT_S32BE 0x0080  
+#endif
+
 namespace mozilla {
 
 using namespace CubebUtils;
@@ -183,6 +191,12 @@ static uint16_t ConvertCubebFormat(cubeb_device_fmt aFormat) {
   if (aFormat &amp; CUBEB_DEVICE_FMT_F32BE) {
     format |= nsIAudioDeviceInfo::FMT_F32BE;
   }
+  if (aFormat &amp; CUBEB_DEVICE_FMT_S32LE) {  
+    format |= nsIAudioDeviceInfo::FMT_S32LE;  
+  }  
+  if (aFormat &amp; CUBEB_DEVICE_FMT_S32BE) {  
+    format |= nsIAudioDeviceInfo::FMT_S32BE;  
+  }  
   return format;
 }
 
diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js
index 388f8048201f..af6e396feb7d 100644
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -974,6 +974,8 @@ var snapshotFormatters = {
       formats[deviceInfo.FMT_S16BE] = &quot;S16BE&quot;;
       formats[deviceInfo.FMT_F32LE] = &quot;F32LE&quot;;
       formats[deviceInfo.FMT_F32BE] = &quot;F32BE&quot;;
+      formats[deviceInfo.FMT_S32LE] = &quot;S32LE&quot;;
+      formats[deviceInfo.FMT_S32BE] = &quot;S32BE&quot;;
 
       function toPreferredString(preferred) {
         if (preferred == deviceInfo.PREF_NONE) {
@@ -1001,6 +1003,8 @@ var snapshotFormatters = {
           deviceInfo.FMT_S16BE,
           deviceInfo.FMT_F32LE,
           deviceInfo.FMT_F32BE,
+          deviceInfo.FMT_S32LE,
+          deviceInfo.FMT_S32BE,
         ]) {
           if (dev.supportedFormat &amp; fmt) {
             str += &quot; &quot; + formats[fmt];
-- 
2.39.5</code></pre></div><div class="codebox"><pre class="vscroll"><code>$ cat 0002-Add-S32-format-to-the-Cubeb-API.patch
From f8d402971731b6729daf47624fe74a7e7466ee24 Mon Sep 17 00:00:00 2001
From: Devuan
Date: Thu, 9 Jul 2026 17:48:56 +0200
Subject: [PATCH 2/2] Add S32 format to the Cubeb API

- Add CUBEB_DEVICE_FMT_S32LE and CUBEB_DEVICE_FMT_S32BE constants to API
- Update log_device function to handle S32 formats in logging
- Update test_devices to handle S32 format display
---
 media/libcubeb/include/cubeb/cubeb.h | 17 ++++++++++++-----
 media/libcubeb/src/cubeb.c           | 23 +++++++++++++++++++++++
 media/libcubeb/test/test_devices.cpp | 10 ++++++++++
 3 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/media/libcubeb/include/cubeb/cubeb.h b/media/libcubeb/include/cubeb/cubeb.h
index ff2f8b7b987d..322230a2df11 100644
--- a/media/libcubeb/include/cubeb/cubeb.h
+++ b/media/libcubeb/include/cubeb/cubeb.h
@@ -340,6 +340,8 @@ typedef enum {
 typedef enum {
   CUBEB_DEVICE_FMT_S16LE = 0x0010, /**&lt; 16-bit integers, Little Endian. */
   CUBEB_DEVICE_FMT_S16BE = 0x0020, /**&lt; 16-bit integers, Big Endian. */
+  CUBEB_DEVICE_FMT_S32LE = 0x0040, /**&lt; 32-bit integers, Little Endian. */
+  CUBEB_DEVICE_FMT_S32BE = 0x0080, /**&lt; 32-bit integers, Big Endian. */
   CUBEB_DEVICE_FMT_F32LE = 0x1000, /**&lt; 32-bit floating point, Little Endian. */
   CUBEB_DEVICE_FMT_F32BE = 0x2000  /**&lt; 32-bit floating point, Big Endian. */
 } cubeb_device_fmt;
@@ -347,25 +349,30 @@ typedef enum {
 #if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
 /** 16-bit integers, native endianess, when on a Big Endian environment. */
 #define CUBEB_DEVICE_FMT_S16NE CUBEB_DEVICE_FMT_S16BE
-/** 32-bit floating points, native endianess, when on a Big Endian environment.
- */
+/** 32-bit integers, native endianess, when on a Big Endian environment. */
+#define CUBEB_DEVICE_FMT_S32NE CUBEB_DEVICE_FMT_S32BE
+/** 32-bit floating points, native endianess, when on a Big Endian environment. */
 #define CUBEB_DEVICE_FMT_F32NE CUBEB_DEVICE_FMT_F32BE
 #else
 /** 16-bit integers, native endianess, when on a Little Endian environment. */
 #define CUBEB_DEVICE_FMT_S16NE CUBEB_DEVICE_FMT_S16LE
-/** 32-bit floating points, native endianess, when on a Little Endian
- *  environment. */
+/** 32-bit integers, native endianess, when on a Little Endian environment. */
+#define CUBEB_DEVICE_FMT_S32NE CUBEB_DEVICE_FMT_S32LE
+/** 32-bit floating points, native endianess, when on a Little Endian environment. */
 #define CUBEB_DEVICE_FMT_F32NE CUBEB_DEVICE_FMT_F32LE
 #endif
 /** All the 16-bit integers types. */
 #define CUBEB_DEVICE_FMT_S16_MASK                                              \
   (CUBEB_DEVICE_FMT_S16LE | CUBEB_DEVICE_FMT_S16BE)
+/** All the 32-bit integers types. */
+#define CUBEB_DEVICE_FMT_S32_MASK                                              \
+  (CUBEB_DEVICE_FMT_S32LE | CUBEB_DEVICE_FMT_S32BE)
 /** All the 32-bit floating points types. */
 #define CUBEB_DEVICE_FMT_F32_MASK                                              \
   (CUBEB_DEVICE_FMT_F32LE | CUBEB_DEVICE_FMT_F32BE)
 /** All the device formats types. */
 #define CUBEB_DEVICE_FMT_ALL                                                   \
-  (CUBEB_DEVICE_FMT_S16_MASK | CUBEB_DEVICE_FMT_F32_MASK)
+  (CUBEB_DEVICE_FMT_S16_MASK | CUBEB_DEVICE_FMT_S32_MASK | CUBEB_DEVICE_FMT_F32_MASK)
 
 /** Channel type for a `cubeb_stream`. Depending on the backend and platform
  * used, this can control inter-stream interruption, ducking, and volume
diff --git a/media/libcubeb/src/cubeb.c b/media/libcubeb/src/cubeb.c
index 4fdead389354..1ca8582bab71 100644
--- a/media/libcubeb/src/cubeb.c
+++ b/media/libcubeb/src/cubeb.c
@@ -75,6 +75,10 @@ opensl_init(cubeb ** context, char const * context_name);
 int
 oss_init(cubeb ** context, char const * context_name);
 #endif
+#if defined(USE_OSS_FFT)  
+int  
+oss_fft_init(cubeb ** context, char const * context_name);  
+#endif
 #if defined(USE_AAUDIO)
 int
 aaudio_init(cubeb ** context, char const * context_name);
@@ -195,6 +199,10 @@ cubeb_init(cubeb ** context, char const * context_name,
     } else if (!strcmp(backend_name, &quot;oss&quot;)) {
 #if defined(USE_OSS)
       init_oneshot = oss_init;
+#endif
+} else if (!strcmp(backend_name, &quot;oss-fft&quot;)) {  
+#if defined(USE_OSS_FFT)  
+  init_oneshot = oss_fft_init;  
 #endif
     } else if (!strcmp(backend_name, &quot;aaudio&quot;)) {
 #if defined(USE_AAUDIO)
@@ -237,6 +245,9 @@ cubeb_init(cubeb ** context, char const * context_name,
 #if defined(USE_OSS)
       oss_init,
 #endif
+#if defined(USE_OSS_FFT)  
+  oss_fft_init,  
+#endif
 #if defined(USE_AUDIOUNIT_RUST)
       audiounit_rust_init,
 #endif
@@ -690,6 +701,12 @@ log_device(cubeb_device_info * device_info)
   case CUBEB_DEVICE_FMT_F32BE:
     devdeffmt = &quot;F32BE&quot;;
     break;
+	case CUBEB_DEVICE_FMT_S32LE:  
+		devdeffmt = &quot;S32LE&quot;;  
+		break;  
+	case CUBEB_DEVICE_FMT_S32BE:  
+		devdeffmt = &quot;S32BE&quot;;  
+		break;
   default:
     devdeffmt = &quot;unknown?&quot;;
     break;
@@ -707,6 +724,12 @@ log_device(cubeb_device_info * device_info)
   if (device_info-&gt;format &amp; CUBEB_DEVICE_FMT_F32BE) {
     strcat(devfmts, &quot; F32BE&quot;);
   }
+  if (device_info-&gt;format &amp; CUBEB_DEVICE_FMT_S32LE) {
+    strcat(devfmts, &quot; S32LE&quot;);
+  }
+  if (device_info-&gt;format &amp; CUBEB_DEVICE_FMT_S32BE) {
+    strcat(devfmts, &quot; S32BE&quot;);
+  }
 
   LOG(&quot;DeviceID: \&quot;%s\&quot;%s\n&quot;
       &quot;\tName:\t\&quot;%s\&quot;\n&quot;
diff --git a/media/libcubeb/test/test_devices.cpp b/media/libcubeb/test/test_devices.cpp
index d0eab2da67e6..4a8da1a4113b 100644
--- a/media/libcubeb/test/test_devices.cpp
+++ b/media/libcubeb/test/test_devices.cpp
@@ -79,6 +79,12 @@ print_device_info(cubeb_device_info * info, FILE * f)
   case CUBEB_DEVICE_FMT_F32BE:
     devdeffmt = &quot;F32BE&quot;;
     break;
+  case CUBEB_DEVICE_FMT_S32LE:  // Add this  
+    devdeffmt = &quot;S32LE&quot;;  
+    break;  
+  case CUBEB_DEVICE_FMT_S32BE:  // Add this  
+    devdeffmt = &quot;S32BE&quot;;  
+    break;  
   default:
     devdeffmt = &quot;unknown?&quot;;
     break;
@@ -92,6 +98,10 @@ print_device_info(cubeb_device_info * info, FILE * f)
     strcat(devfmts, &quot; F32LE&quot;);
   if (info-&gt;format &amp; CUBEB_DEVICE_FMT_F32BE)
     strcat(devfmts, &quot; F32BE&quot;);
+	if (info-&gt;format &amp; CUBEB_DEVICE_FMT_S32LE)  // Add this  
+		strcat(devfmts, &quot; S32LE&quot;);  
+	if (info-&gt;format &amp; CUBEB_DEVICE_FMT_S32BE)  // Add this  
+		strcat(devfmts, &quot; S32BE&quot;);
 
   fprintf(f,
           &quot;dev: \&quot;%s\&quot;%s\n&quot;
-- 
2.39.5</code></pre></div><p><strong>EXAMPLE:</strong> Firefox <span class="bbc">about:support</span></p><div class="codebox"><pre class="vscroll"><code>$ firefox-dev about:support
...
Name 	Firefox Developer Edition
Version 	154.0a1
...
Update Channel 	aurora
User Agent 	Mozilla/5.0 (X11; Linux x86_64; rv:154.0) Gecko/20100101 Firefox/154.0
...
Application Binary 	/usr/lib/firefox-dev/firefox-dev
Profile Directory 	$HOME/.firefox-dev/uf30avtz.dev-edition-default
...
Audio Backend: alsa
Max Channels: 64
Preferred Sample Rate: 44100
Roundtrip latency (standard deviation): NaNms (NaN)
...
Output Devices
Name: Group, Vendor, State, Preferred, Format, Channels, Rate, Latency
Discard all samples (playback) or generate zero samples (capture): null, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 1073741823, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Libav/FFmpeg Library: lavrate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Samplerate Library: samplerate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Speex Resampler: speexrate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Bluetooth Audio: bluealsa, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
Plugin using Speex DSP (resample, agc, denoise, echo, dereverb): speex, Enabled, None, default: S16LE, support: S16LE, 1, default: 44100, support: 4000 - 4294967295, 0 - 0
Plugin for channel upmix (4,6,8): upmix, Enabled, None, default: S16LE, support: S16LE, 8, default: 44100, support: 4000 - 4294967295, 0 - 0
Plugin for channel downmix (stereo) with a simple spacialization: vdownmix, Enabled, None, default: S16LE, support: S16LE, 6, default: 44100, support: 4000 - 4294967295, 0 - 0
Default device: default, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Direct hardware device without any conversions: hw:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, HDMI 0 Direct hardware device without any conversions: hw:CARD=PCH,DEV=3, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 1 Direct hardware device without any conversions: hw:CARD=PCH,DEV=7, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 2 Direct hardware device without any conversions: hw:CARD=PCH,DEV=8, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 3 Direct hardware device without any conversions: hw:CARD=PCH,DEV=9, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog Hardware device with all software conversions: plughw:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, HDMI 0 Hardware device with all software conversions: plughw:CARD=PCH,DEV=3, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, HDMI 1 Hardware device with all software conversions: plughw:CARD=PCH,DEV=7, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, HDMI 2 Hardware device with all software conversions: plughw:CARD=PCH,DEV=8, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, HDMI 3 Hardware device with all software conversions: plughw:CARD=PCH,DEV=9, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Default Audio Device: sysdefault:CARD=PCH, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Front output / input: front:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog 4.0 Surround output to Front and Rear speakers: surround40:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers: surround51:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers: surround71:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, HDMI 0 HDMI Audio Output: hdmi:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 1 HDMI Audio Output: hdmi:CARD=PCH,DEV=1, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 2 HDMI Audio Output: hdmi:CARD=PCH,DEV=2, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, HDMI 3 HDMI Audio Output: hdmi:CARD=PCH,DEV=3, Enabled, None, default: S32LE, support: S16LE S32LE, 8, default: 44100, support: 32000 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog Direct sample mixing device: dmix:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0
HDA Intel PCH, HDMI 0 Direct sample mixing device: dmix:CARD=PCH,DEV=3, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0
HDA Intel PCH, HDMI 1 Direct sample mixing device: dmix:CARD=PCH,DEV=7, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0
HDA Intel PCH, HDMI 2 Direct sample mixing device: dmix:CARD=PCH,DEV=8, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0
HDA Intel PCH, HDMI 3 Direct sample mixing device: dmix:CARD=PCH,DEV=9, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0
Input Devices
Name: Group, Vendor, State, Preferred, Format, Channels, Rate, Latency
Discard all samples (playback) or generate zero samples (capture): null, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 1073741823, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Libav/FFmpeg Library: lavrate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Samplerate Library: samplerate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Rate Converter Plugin Using Speex Resampler: speexrate, Enabled, None, default: S32LE, support: S16LE S16BE S32LE S32BE, 10000, default: 44100, support: 1 - 4294967295, 0 - 0
Plugin using Speex DSP (resample, agc, denoise, echo, dereverb): speex, Enabled, None, default: S16LE, support: S16LE, 1, default: 44100, support: 4000 - 4294967295, 0 - 0
Plugin for channel upmix (4,6,8): upmix, Enabled, None, default: S16LE, support: S16LE, 8, default: 44100, support: 4000 - 4294967295, 0 - 0
Plugin for channel downmix (stereo) with a simple spacialization: vdownmix, Enabled, None, default: S16LE, support: S16LE, 6, default: 44100, support: 4000 - 4294967295, 0 - 0
Default device: default, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Direct hardware device without any conversions: hw:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog Hardware device with all software conversions: plughw:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Default Audio Device: sysdefault:CARD=PCH, Enabled, None, default: S32LE, support: S16LE S16BE F32LE F32BE S32LE S32BE, 10000, default: 44100, support: 4000 - 4294967295, 0 - 0
HDA Intel PCH, 92HD95 Analog Front output / input: front:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S16LE S32LE, 2, default: 44100, support: 44100 - 192000, 0 - 0
HDA Intel PCH, 92HD95 Analog Direct sample snooping device: dsnoop:CARD=PCH,DEV=0, Enabled, None, default: S32LE, support: S32LE, 2, default: 48000, support: 48000 - 48000, 0 - 0</code></pre></div><p><strong>NOTE:</strong> ALSA device enumeration is now exact, but ALSA drives might be buggy. Therefore, &quot;digital&quot; may mean &quot;analog&quot; and other way round. The word &quot;virtual&quot; usually implies linear interpolation or other sort of low quality resampling.</p><p>1. Device enumeration is exact - The ALSA library correctly enumerates available devices through the control interface and name hints control.</p><p>2. Driver descriptions can be buggy - Generic card configurations like HDA-Intel.conf make assumptions about device mappings that may not match actual hardware pin configurations. </p><p>3. &quot;Virtual&quot; and resampling quality - Virtual devices (using the plug plugin) perform conversions, but the quality depends on the configured rate converter. The default is often linear interpolation, but high-quality converters like fftrate can be used.</p><p>Virtual devices are software plugins that wrap hardware access. They always perform some conversion (format, rate, or channels), but the quality varies:</p><p>Default: often linear interpolation (lower quality)<br />Configurable: can use high-quality resamplers like fftrate</p><p>Hardware devices (hw:) provide direct kernel driver access without any conversions. </p><p>The &quot;digital&quot;/&quot;analog&quot; labels come from driver descriptions, which may be incorrect due to generic configuration assumptions not matching your specific motherboard&#039;s pin layout.</p><p>The word &quot;direct&quot; is also a sort of label that has a flexible meaning: &quot;direct exclusive kernel driver access&quot; is not possible with ALSA in any sense.</p><p>The ALSA hw plugin does communicate directly with the kernel driver through device files and ioctl calls, but this is still mediated by the ALSA library (libasound) in userspace. The <span class="bbc">snd_pcm_hw_open</span> function opens kernel device files like <span class="bbc">/dev/snd/pcmC%iD%ip</span> and uses ioctl calls to communicate with the kernel driver.</p><p>When ALSA documentation says the hw plugin provides &quot;direct communication without any conversions,&quot; it means:<br />No software format conversion<br />No software rate conversion<br />No software channel routing<br />Direct ioctl calls to kernel device files</p><p>But it does NOT mean:<br />Bypassing the ALSA library<br />Exclusive hardware access (other processes can still access the device)<br />Bypassing potential kernel driver bugs</p><p>The ALSA path with <span class="bbc">hw:0,0</span> is:</p><div class="codebox"><pre><code>Application → ALSA Library (libasound) → hw plugin → ioctl → Kernel Driver → Hardware </code></pre></div><p>The hw plugin is the closest you can get to the kernel driver while still using the ALSA API, but it&#039;s still going through the library layer.</p><p>There is no way to access the ALSA kernel driver directly from userspace without going through libasound. The &quot;direct&quot; terminology in ALSA documentation refers to the absence of software processing plugins, not to bypassing the library itself. <br />See also: <br /><strong>The exclusive mode of ALSA</strong><br />_https://dev1galaxy.org/viewtopic.php?id=8053</p><p>In practical terms, the choice is indeed between low-quality hardware resampling and software resampling.</p><p>The fundamental tradeoff in ALSA audio processing:<br />Hardware resampling - Built into consumer sound cards/codecs, often poor quality due to cost-cutting and implementation limitations.<br />Software resampling - Performed by ALSA&#039;s rate plugin, quality depends on the converter used.</p><p>ALSA&#039;s plug plugin automatically inserts rate conversion when the application&#039;s requested rate differs from the hardware&#039;s native rate. The rate plugin supports multiple converters specified via the converter parameter.</p><p>The default linear converter provides basic linear interpolation (low quality), while high-quality external converters like fftrate can be used through the External Rate-Converter-Plugin SDK.</p><p>The optimal strategy — using high-quality software resampling (fftrate) to bypass hardware resamplers by sending a fixed high-rate stream to the hardware — effectively avoids the quality limitations of consumer hardware SRC implementations.</p><div class="quotebox"><blockquote><div><p><strong>NOTE:</strong> This guide is a work in progress. Please do not post in this topic. If you have any questions, please consult the Devuan Wiki, or other knowledge repositories of the sort.</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (igorzwx)]]></author>
			<pubDate>Fri, 10 Jul 2026 00:40:42 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8012&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] HP, Inc ScanJet G3010 could not open USB device Access denied]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=7963&amp;action=new</link>
			<description><![CDATA[<div class="quotebox"><blockquote><div><p>Under Linux i have stage wide blue tint lines at scanned images but at Windows VueScan all looks good.</p></div></blockquote></div><p>its not bug:) its was dust at inside mirrors, after gentle cleaning no more any color issues:)</p>]]></description>
			<author><![CDATA[dummy@example.com (deepforest)]]></author>
			<pubDate>Thu, 09 Jul 2026 21:12:43 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=7963&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] UMAX AstraSlim SE - Invalid argument]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8083&amp;action=new</link>
			<description><![CDATA[<p>@<strong>kapqa</strong> Thanks for helping!:)<br />solved!<br />firmware must be placed at this both folders<br /><span class="bbc">/usr/local/share/sane/artec_eplus48u/Artec48.usb</span><br /><span class="bbc">/usr/share/sane/artec_eplus48u/Artec48.usb</span></p>]]></description>
			<author><![CDATA[dummy@example.com (deepforest)]]></author>
			<pubDate>Thu, 09 Jul 2026 20:49:39 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8083&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[xlibre-deb or xlibre-debian PART TWO]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8089&amp;action=new</link>
			<description><![CDATA[<p>I switched to xlibre-debian a few months ago. At that time, there had not been any updates on xlibre-deb since the end of last year.</p><p>Here are the xlibre versions I have as of today (2026-07-09)</p><div class="codebox"><pre><code>ii  x11proto-dev                         2025.1-1+xlibre1                             all          X11 extension protocols and auxiliary headers
ii  xlibre                               1:7.8+5                                      amd64        XLibre X Window System
ii  xlibre-archive-keyring               1.0.0-1                                      all          OpenPGP archive certificates of XLibre
ii  xlibre-x11-common                    1:7.8+5                                      all          X Window System (X.Org) infrastructure
ii  xlibre-xutils                        1:7.8+5                                      all          X Window System utility programs metapackage
ii  xserver-xlibre                       1:7.8+5                                      amd64        XLibre X server
ii  xserver-xlibre-common                2:25.2.0-3                                   all          common files used by various X servers
ii  xserver-xlibre-core                  2:25.2.0-3                                   amd64        XLibre X server - core server
ii  xserver-xlibre-input-all             1:7.8+5                                      amd64        XLibre X server -- input driver metapackage
ii  xserver-xlibre-input-libinput        1:25.0.1-1                                   amd64        XLibre X server -- libinput input driver
ii  xserver-xlibre-video-all             1:7.8+5                                      amd64        XLibre X server -- output driver metapackage
ii  xserver-xlibre-video-amdgpu          25.1.1-3                                     amd64        XLibre X server -- AMDGPU display driver
ii  xserver-xlibre-video-ati             1:25.0.1-1                                   amd64        XLibre X server -- AMD/ATI display driver wrapper
ii  xserver-xlibre-video-fbdev           2:25.0.0-1                                   amd64        XLibre X server -- fbdev display driver
ii  xserver-xlibre-video-nouveau         2:25.0.0-1                                   amd64        XLibre X server -- Nouveau display driver
ii  xserver-xlibre-video-qxl             1:25.0.0-1                                   amd64        XLibre X server -- QXL display driver
ii  xserver-xlibre-video-radeon          1:25.0.1-1                                   amd64        XLibre X server -- AMD/ATI Radeon display driver
ii  xserver-xlibre-video-vesa            2:25.0.0-1                                   amd64        XLibre X server -- VESA display driver
ii  xserver-xlibre-video-vmware          2:25.0.0-1                                   amd64        XLibre X server -- VMware display driver
ii  xserver-xlibre-xephyr                2:25.2.0-3                                   amd64        nested X server</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Thu, 09 Jul 2026 18:10:49 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8089&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Tips for people who don't like hidden scrollbars and other GTK3 things]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8087&amp;action=new</link>
			<description><![CDATA[<div class="quotebox"><cite>Uityyy wrote:</cite><blockquote><div><p><strong>Scrollbars that jump many pages when you click the wrong place</strong></p><p>GTK themes can contain general GTK settings. Devuan Excalibur&#039;s theme contains a settings.ini containing the line</p><div class="codebox"><pre><code>gtk-primary-button-warps-slider = false</code></pre></div><p>This makes the scrollbar only scroll by one page if you left-click it somewhere other than the handle.<br />If you want this behavior all the time and not just when you&#039;re using Excalibur&#039;s default theme, simply create ~/.config/gtk-3.0/settings.ini and add the same line to it.</p></div></blockquote></div><p>Thanks for posting this!&#160; The same setting works on Daedalus also.&#160; Note that if you&#039;re creating a settings.ini file, that code should be in a &quot;[Settings]&quot; group, like so: </p><div class="codebox"><pre><code>[Settings]
gtk-primary-button-warps-slider = false</code></pre></div><p> Otherwise you&#039;ll get a gtk warning, failed to parse settings.ini: Key file does not start with a group.</p>]]></description>
			<author><![CDATA[dummy@example.com (rbit)]]></author>
			<pubDate>Thu, 09 Jul 2026 16:48:16 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8087&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[xlibre-deb or xlibre-debian?]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8088&amp;action=new</link>
			<description><![CDATA[<p>This discussion is continued here:<br /><a href="https://dev1galaxy.org/viewtopic.php?id=8089" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=8089</a></p>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Thu, 09 Jul 2026 14:34:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8088&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[How to set system time?]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8072&amp;action=new</link>
			<description><![CDATA[<div class="quotebox"><blockquote><div><p>Current default time zone: &#039;Europe/Rome&#039;<br />Local time is now:&#160; &#160; &#160; Thu Jul&#160; 9 13:45:59 CEST 2026.<br />Universal Time is now:&#160; Thu Jul&#160; 9 11:45:59 UTC 2026.<br />Run &#039;dpkg-reconfigure tzdata&#039; if you wish to change it.</p></div></blockquote></div><p>think the .reg file trick shared by Mr. RedGreen925 is very helpful;<br />it functioned on 1 computer that i use here quite reliably; however, it takes the windows machine about a half or minute or so to adjust; but otherwise it seem to function; but probably, it needs an internet connection to function.</p><p>where i live the UTC &quot;universal&quot; time seem not so much off, so i am not at odds with it;<br />very mjuch more so with the &quot;current local time&quot; <del>which is affront, </del>so calld &quot;DST&quot; &quot;ora legale&quot; &quot;Sommerzeit&quot; etc ~</p><p>basically in small room can get 3 different times depending on where i watch ~</p><p>TV gives me like&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;07.39 (UTC)<br />my smartwatch on wrist&#160; &#160; &#160; &#160; 08.39 (local-time) &gt; since have the wrist-watch not synced for along time.<br />radio-clock in kitchen-space 09-39 (local-&quot;summer&quot;-time) &gt; the stupid does &quot;align&quot; itself via radio probably</p><p>the local-time is most true to the sun since it probaly 15min ahead of loca-tun-time~<br />and UTC is probably 45min behind suntime ~<br />whereas the &quot;summer-time&quot; &quot;day-light-saving-time&quot; if full 75minutes &quot;ahead&quot; of sun <del>and a real bummer so doing my best to ignore it ~ but since it is ~ &quot;legal&quot; time, well, not fully to ignore, but thats for another topi</del>c.</p><p>it would be nice to set the time in BIOS, and that could be it.</p>]]></description>
			<author><![CDATA[dummy@example.com (kapqa)]]></author>
			<pubDate>Thu, 09 Jul 2026 11:59:22 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8072&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[Invalid PCI Header Signature error]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8086&amp;action=new</link>
			<description><![CDATA[<p>its not much of an advice, but you could always try a fresh install,<br />see no reason why it should not function;</p><p>have an older laptop with &quot;carrizo&quot; or &quot;kabini&quot; based graphics and it still function with devuan 7.</p><div class="codebox"><pre class="vscroll"><code>sudo dmesg | grep amdgpu
[sudo] password for : 
[   15.624597] amdgpu: Virtual CRAT table created for CPU
[   15.624676] amdgpu: Topology: Add CPU node
[   15.625191] amdgpu 0000:00:01.0: initializing kernel modesetting (CARRIZO 0x1002:0x9874 0x17AA:0x5120 0xC9).
[   15.661524] amdgpu 0000:00:01.0: register mmio base: 0xF0F00000
[   15.661532] amdgpu 0000:00:01.0: register mmio size: 262144
[   15.662084] amdgpu 0000:00:01.0: detected ip block number 0 &lt;common_v1_0_0&gt; (vi_common)
[   15.662095] amdgpu 0000:00:01.0: detected ip block number 1 &lt;gmc_v8_0_0&gt; (gmc_v8_0)
[   15.662110] amdgpu 0000:00:01.0: detected ip block number 2 &lt;ih_v3_0_0&gt; (cz_ih)
[   15.662114] amdgpu 0000:00:01.0: detected ip block number 3 &lt;gfx_v8_0_0&gt; (gfx_v8_0)
[   15.662117] amdgpu 0000:00:01.0: detected ip block number 4 &lt;sdma_v3_0_0&gt; (sdma_v3_0)
[   15.662120] amdgpu 0000:00:01.0: detected ip block number 5 &lt;smu_v1_0_0&gt; (powerplay)
[   15.662123] amdgpu 0000:00:01.0: detected ip block number 6 &lt;dce_v1_0_0&gt; (dm)
[   15.662126] amdgpu 0000:00:01.0: detected ip block number 7 &lt;uvd_v6_0_0&gt; (uvd_v6_0)
[   15.662129] amdgpu 0000:00:01.0: detected ip block number 8 &lt;vce_v3_1_0&gt; (vce_v3_0)
[   15.662132] amdgpu 0000:00:01.0: detected ip block number 9 &lt;acp_v2_2_0&gt; (acp_ip)
[   15.674451] amdgpu 0000:00:01.0: Fetched VBIOS from ROM BAR
[   15.674456] amdgpu 0000:00:01.0: [drm] ATOM BIOS: 113-C75100-031
[   15.678025] amdgpu 0000:00:01.0: [drm] UVD is enabled in physical mode
[   15.680078] amdgpu 0000:00:01.0: Found VCE firmware Version: 52.4 Binary ID: 3
[   15.680087] amdgpu 0000:00:01.0: [drm] VCE enabled in physical mode
[   15.680705] amdgpu 0000:00:01.0: vgaarb: deactivate vga console
[   15.680710] amdgpu 0000:00:01.0: Trusted Memory Zone (TMZ) feature not supported
[   15.680714] amdgpu 0000:00:01.0: PCIE atomic ops is not supported
[   15.680764] amdgpu 0000:00:01.0: vm size is 64 GB, 2 levels, block size is 10-bit, fragment size is 9-bit
[   15.680774] amdgpu 0000:00:01.0: VRAM: 1024M 0x000000F400000000 - 0x000000F43FFFFFFF (1024M used)
[   15.680778] amdgpu 0000:00:01.0: GART: 1024M 0x000000FF00000000 - 0x000000FF3FFFFFFF
[   15.680793] amdgpu 0000:00:01.0: [drm] Detected VRAM RAM=1024M, BAR=1024M
[   15.680796] amdgpu 0000:00:01.0: [drm] RAM width 128bits UNKNOWN
[   15.681051] amdgpu 0000:00:01.0:  1024M of VRAM memory ready
[   15.681056] amdgpu 0000:00:01.0:  7449M of GTT memory ready.
[   15.681101] amdgpu 0000:00:01.0: [drm] GART: num cpu pages 262144, num gpu pages 262144
[   15.681666] amdgpu 0000:00:01.0: [drm] PCIE GART of 1024M enabled (table at 0x000000F400E00000).
[   15.688241] amdgpu: hwmgr_sw_init smu backed is smu8_smu
[   15.690399] amdgpu 0000:00:01.0: [drm] Found UVD firmware Version: 1.91 Family ID: 11
[   15.690469] amdgpu 0000:00:01.0: [drm] UVD ENC is disabled
[   15.693026] amdgpu: smu version 27.18.00
[   15.699361] amdgpu 0000:00:01.0: [drm] Display Core v3.2.369 initialized on DCE 11.0
[   15.713298] snd_hda_intel 0000:00:01.1: bound 0000:00:01.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
[   15.754619] amdgpu 0000:00:01.0: [drm] Using ACPI provided EDID for eDP-1
[   15.785324] amdgpu 0000:00:01.0: [drm] UVD initialized successfully.
[   15.984828] amdgpu 0000:00:01.0: [drm] VCE initialized successfully.
[   15.985930] amdgpu 0000:00:01.0: SE 1, SH per SE 1, CU per SH 8, active_cu_number 6
[   15.987124] amdgpu: pp_dpm_get_sclk_od was not implemented.
[   15.987128] amdgpu: pp_dpm_get_mclk_od was not implemented.
[   15.987316] amdgpu 0000:00:01.0: Runtime PM not available
[   15.996967] amdgpu 0000:00:01.0: [drm] Using custom brightness curve
[   15.997483] amdgpu 0000:00:01.0: [drm] Registered 3 planes with drm panic
[   16.016758] [drm] Initialized amdgpu 3.64.0 for 0000:00:01.0 on minor 0
[   16.023676] fbcon: amdgpudrmfb (fb0) is primary device
[   16.699733] amdgpu 0000:00:01.0: [drm] fb0: amdgpudrmfb frame buffer device</code></pre></div><div class="codebox"><pre><code>00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Wani [Radeon R5/R6/R7 Graphics] (rev c9) (prog-if 00 [VGA controller])
        Subsystem: Lenovo Device 5120
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast &gt;TAbort- &lt;TAbort- &lt;MAbort- &gt;SERR- &lt;PERR- INTx-
        Latency: 0, Cache Line Size: 32 bytes
        Interrupts: pin B disabled, MSI(X) routed to IRQ 60
        IOMMU group: 0
        Region 0: Memory at e0000000 (64-bit, prefetchable) [size=256M]
        Region 2: Memory at f0000000 (64-bit, prefetchable) [size=8M]
        Region 4: I/O ports at 2000 [size=256]
        Region 5: Memory at f0f00000 (32-bit, non-prefetchable) [size=256K]
        Expansion ROM at 000c0000 [disabled] [size=128K]
        Capabilities: &lt;access denied&gt;
        Kernel driver in use: amdgpu
        Kernel modules: amdgpu
00: 02 10 74 98 07 04 10 00 c9 00 00 03 08 00 80 00
10: 0c 00 00 e0 00 00 00 00 0c 00 00 f0 00 00 00 00
20: 01 20 00 00 00 00 f0 f0 00 00 00 00 aa 17 20 51
30: 00 00 fe ff 48 00 00 00 00 00 00 00 0b 01 00 00</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (kapqa)]]></author>
			<pubDate>Thu, 09 Jul 2026 07:03:27 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8086&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Failed to check for processor microcode upgrades(x86_64)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8080&amp;action=new</link>
			<description><![CDATA[<p>There is an amd64 microcode package. I reckon that you should install it. Sorry if I made a mistake, I don&#039;t have the best knowledge of hardware and firmware.</p>]]></description>
			<author><![CDATA[dummy@example.com (WEBDEVDESTROYER2000)]]></author>
			<pubDate>Thu, 09 Jul 2026 07:01:02 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8080&amp;action=new</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Missing AMD GPU Firmware, *ip_discovery.bin]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?id=8085&amp;action=new</link>
			<description><![CDATA[<p>Since the driver pat of this issue is solved, and that&#039;s what the thread title is about, I&#039;m going to mark this as solved and make another thread about the pci signature error. Tl;dr, add backports to your apt sources list and you can get the drivers.</p>]]></description>
			<author><![CDATA[dummy@example.com (Invisible_Pineapple)]]></author>
			<pubDate>Wed, 08 Jul 2026 23:27:26 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?id=8085&amp;action=new</guid>
		</item>
	</channel>
</rss>
