All of lore.kernel.org
 help / color / mirror / Atom feed
From: Halim Sahin <halim.sahin@freenet.de>
To: alsa-devel@alsa-project.org
Subject: Re: a11y: howto reduce latency with alsa's dmix plugin?
Date: Wed, 02 Sep 2009 10:56:17 +0200	[thread overview]
Message-ID: <87ab1dg1xq.fsf@freenet.de> (raw)
In-Reply-To: s5hy6ozt0cd.wl%tiwai@suse.de

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

On Di, Sep 01 2009, Takashi Iwai wrote:

> At best, we need a small C code that reproduces the behavior.
Ok here is a small example.
It's a modified version of pcm_min.c.
Simply press ctrl+c to reproduce the problematic behaviour.
on my machine it takes about an half sek to stop with an usb head which
uses dmix.
Using an sblive card (without dmix) stopps immediately.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pcm_min.c --]
[-- Type: text/x-csrc, Size: 1703 bytes --]

/*
 *  This extra small demo sends a random samples to your speakers.
 */

#include <alsa/asoundlib.h>
#include <signal.h>
#include <unistd.h>
static char *device = "default";

snd_output_t *output = NULL;

unsigned char buffer[16 * 1024];        /* some random data */

snd_pcm_t *handle;

void suspend (int signum)
{
  int err;

  printf ("trying to stop\n");
  if ((err = snd_pcm_drop (handle)) < 0)
    printf ("cannot pause\n");

  sleep (1);
  snd_pcm_close (handle);

  exit (1);
}

int main (void)
{
  int err;

  unsigned int i;

  snd_pcm_sframes_t frames;

  signal (SIGINT, suspend);
  for (i = 0; i < sizeof (buffer); i++)
    buffer[i] = random () & 0xff;

  if ((err = snd_pcm_open (&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
   {
     printf ("Playback open error: %s\n", snd_strerror (err));
     exit (EXIT_FAILURE);
   }
  if ((err = snd_pcm_set_params (handle,
                                 SND_PCM_FORMAT_U8,
                                 SND_PCM_ACCESS_RW_INTERLEAVED,
                                 1, 48000, 1, 500000)) < 0)
   {                            /* 0.5sec */
     printf ("Playback open error: %s\n", snd_strerror (err));
     exit (EXIT_FAILURE);
   }

  for (i = 0; i < 16; i++)
   {
     frames = snd_pcm_writei (handle, buffer, sizeof (buffer));
     if (frames < 0)
       frames = snd_pcm_recover (handle, frames, 0);
     if (frames < 0)
      {
        printf ("snd_pcm_writei failed: %s\n", snd_strerror (err));
        break;
      }
     if (frames > 0 && frames < (long) sizeof (buffer))
       printf ("Short write (expected %li, wrote %li)\n",
               (long) sizeof (buffer), frames);
   }

  snd_pcm_close (handle);
  return 0;
}

[-- Attachment #3: Type: text/plain, Size: 38 bytes --]

Hope you can help.
Kind regards
Halim

[-- Attachment #4: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2009-09-02  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-23  9:55 a11y: howto reduce latency with alsa's dmix plugin? Halim Sahin
2009-08-30 16:13 ` really no idea? " Halim Sahin
2009-08-31 15:12 ` Takashi Iwai
2009-09-01 10:32   ` Halim Sahin
2009-09-01 10:40     ` Takashi Iwai
2009-09-02  8:56       ` Halim Sahin [this message]
2009-09-03 22:07         ` Takashi Iwai
2009-09-04  9:09           ` Halim Sahin
2009-09-04  9:32             ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ab1dg1xq.fsf@freenet.de \
    --to=halim.sahin@freenet.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.