[alsa-devel] Strange behaviour on audio chipset VIA VT2021 codec
Marco De Maio - BETTINI Srl
demaio at bettinivideo.com
Thu Feb 16 16:52:15 CET 2012
i need to develop for my work an audio recorder application. I have to
develop the software on Linux OS (Ubuntu 8.04 with kernel 184.108.40.206),
and the motherboard is Gigabyte GA-G41MT-S2P (rev. 1.3) where is
installed the integrated audio chipset VIA VT2021 codec.
I upgraded the alsa driver to 1.0.25 version for support of audio
chipset VIA VT2021. I downloaded the driver and compiled it with the
./configure --with-cards=hda-intel --with-sequencer=yes
and i done some experiments with the following simple application
example with alsa lib:
unsigned int val;
/* Open PCM device for playback. */
rc = snd_pcm_open(&handle, "default",
if (rc < 0)
"unable to open pcm device: %s\n",
/* Allocate a hardware parameters object. */
/* Fill it in with default values. */
/* Set the desired hardware parameters. */
/* Interleaved mode */
/* Signed 16-bit little-endian format */
/* Two channels (stereo) */
snd_pcm_hw_params_set_channels(handle, params, 2);
/* 44100 bits/second sampling rate (CD quality) */
val = 44100;
/* Set period size to 32 frames. */
frames = 32;
params, &frames, &dir);
/* Write the parameters to the driver */
rc = snd_pcm_hw_params(handle, params);
if (rc < 0)
"unable to set hw parameters: %s\n",
/* Use a buffer large enough to hold one period */
size = frames * 4; /* 2 bytes/sample, 2 channels */
buffer = (char *) malloc(size);
printf ("Capture data\n");
rc = snd_pcm_readi(handle, buffer, size);
if (rc == -EAGAIN)
fprintf(stderr, "EAGAIN occurred\n");
else if (rc == -EPIPE)
fprintf(stderr, "EPIPE occurred\n");
else if (rc == -ESTRPIPE)
fprintf(stderr, "ESTRPIPE occurred\n");
else if (rc > 0)
fprintf(stderr, "read %d ok\n", rc);
fprintf(stderr, "error occurred %s\n", snd_strerror(rc));
Running the example above, I found the following behaviors:
1) Until there is no mic plugged, the application stop on snd_pcm_readi.
When mic is plugged, the application starts again.
So when i unplug mic the application stops on snd_pcm_readi, when i plug
mic the application starts again, and so on.
I want to point out that i achieve the same result with a simple stand
2) If i reboot my machine with mic plugged, after restart, I run the
application but it stop immediately on snd_pcm_readi
and I need to unplug/plug the mic to stats again the application.
This behavior seems to me quite strange. Please someone could help me to
figure out why this behavior ? Maybe something wrong with my
example ? Maybe something wrong with compiling options of the driver or
maybe into the drivers itself ?
I tried the same application on a different mainboard with Realtek
ALC889 codec, and the applications never stops on snd_pcm_readi
(I suppose this is the correct behavior), and run correctly.
Let me know if you need more information about.
Thank to all in advance.
More information about the Alsa-devel