# AMD Azalia soundcard - random blocking

## Havin_it

Hi,

I've had this problem since I put Gentoo on my new notebook (HP Pavilion dm1-4400sa) early last year. It has the following audio hardware:

```
00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Wrestler HDMI Audio

        Subsystem: Hewlett-Packard Company Device 18d4

        Kernel driver in use: snd_hda_intel

        Kernel modules: snd_hda_intel

--SNIP--

00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia Controller (rev 01)

        Subsystem: Hewlett-Packard Company Device 18d4

        Kernel driver in use: snd_hda_intel

        Kernel modules: snd_hda_intel

```

I don't have any HDMI hardware so I just use the Azalia card to output to the builtin speakers. For ALSA to choose it as default I added this to /etc/asound.conf:

```
pcm.!default {

        type hw

        card Generic_1

}

ctl.!default {

        type hw

        card Generic_1

}
```

I think my alsa setup is otherwise totally vanilla - I'v taken no other special steps.

Some of the time this works fine, although KDE seems to still often get confused about which device it should use (think I've just about conquered that one now). However, very often the device blocks hard and deadlocks the process trying to use it, usually for about 5 minutes or more. This can happen when playing video or audio in mplayer or VLC, or just when adjusting the volume with kmix. I think starting/stopping of the alsasound initscript may have been caught by it sometimes too.

It's been a long time since I debugged soundcard problems (in fact I never really had one this severe before) and I know that a lot of the alsa documentation is a bit outdated, so I'm not even sure what other info would be useful, but I'm happy to dish it up on request.

Thanks in advance for any suggestions on how to start digging into this.

----------

## PaulBredbury

 *Havin_it wrote:*   

> pcm.!default {
> 
>         type hw

 

That redefines PCM "default" to use hardware, rather than go through dmix. You probably want to remove your custom ~/.asoundrc, and use another method of selecting the default card.

----------

## Havin_it

Hi Paul, thanks for the reply.

Things must have changed at some point, because the "Generic_1" soundcard is still picked as default (aplay -l output remains the same) having commented-out my alsa.conf file.

However, audio is now exhibiting a variety of problems:

 Using aplay or mplayer to play a short 44100Hz wav file (/usr/share/sounds/pop.wav), it loops a short chunk (sub-1sec) endlessly and doesn't exit without Ctrl+C.

 With aplay and a 48000Hz wav file (/usr/share/sounds/alsa/Front_Right.wav), the audio loop continues after aplay exits, but playing some other audio afterwards will clear it.

 Using mplayer to play a compressed audio (ogg) or video (mp4/wmv) file, it plays normally to the end but fails to exit; Ctrl+C x2 required.

 While playing video files with mplayer, if the volume is changed (using kmix shortcut keys) the video pauses accompanied by the same short looped chunk of audio for a few seconds before resuming.

Here's the output of aplay on the 44100Hz wav file:

```
robin@happy ~ $ aplay -vv /usr/share/sounds/pop.wav 

Playing WAVE '/usr/share/sounds/pop.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono

Plug PCM: Rate conversion PCM (48000, sformat=S16_LE)

Converter: linear-interpolation

Protocol version: 10002

Its setup is:

  stream       : PLAYBACK

  access       : RW_INTERLEAVED

  format       : S16_LE

  subformat    : STD

  channels     : 1

  rate         : 44100

  exact rate   : 44100 (44100/1)

  msbits       : 16

  buffer_size  : 15052

  period_size  : 940

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 940

  period_event : 0

  start_threshold  : 15052

  stop_threshold   : 15052

  silence_threshold: 0

  silence_size : 0

  boundary     : 4236761349448794112

Slave: Route conversion PCM (sformat=S32_LE)

  Transformation table:

    0 <- 0

    1 <- 0

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S16_LE

  subformat    : STD

  channels     : 1

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 16

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Slave: Soft volume PCM

Control: PCM Playback Volume

min_dB: -51

max_dB: 0

resolution: 256

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Slave: Direct Stream Mixing PCM

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Hardware PCM card 0 'HD-Audio Generic' device 0 subdevice 0

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : ENABLE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 1

  stop_threshold   : 0

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

  appl_ptr     : 0

  hw_ptr       : 5286466

###                                               +| 99%^C

Aborted by signal Interrupt...

```

...and for the 48000Hz file:

```
robin@happy ~ $ aplay -vv /usr/share/sounds/alsa/Front_Right.wav 

Playing WAVE '/usr/share/sounds/alsa/Front_Right.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

Plug PCM: Route conversion PCM (sformat=S32_LE)

  Transformation table:

    0 <- 0

    1 <- 0

Its setup is:

  stream       : PLAYBACK

  access       : RW_INTERLEAVED

  format       : S16_LE

  subformat    : STD

  channels     : 1

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 16

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Slave: Soft volume PCM

Control: PCM Playback Volume

min_dB: -51

max_dB: 0

resolution: 256

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Slave: Direct Stream Mixing PCM

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

Hardware PCM card 0 'HD-Audio Generic' device 0 subdevice 0

Its setup is:

  stream       : PLAYBACK

  access       : MMAP_INTERLEAVED

  format       : S32_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 32

  buffer_size  : 16384

  period_size  : 1024

  period_time  : 21333

  tstamp_mode  : ENABLE

  period_step  : 1

  avail_min    : 1024

  period_event : 0

  start_threshold  : 1

  stop_threshold   : 0

  silence_threshold: 0

  silence_size : 0

  boundary     : 4611686018427387904

  appl_ptr     : 0

  hw_ptr       : 5804343

#######                   +                        | 50%^C

Aborted by signal Interrupt...

aplay: pcm_write:1939: write error: Interrupted system call

```

----------

## Havin_it

I seem to have resolved this in an unexpected manner: I looked at the module options for snd_hda_intel and tried a few tweaks in /etc/modprobe.d/alsa.conf. What works is:

```

#SNIPPED all the gibberish about aliases etc

#The next 2 directives were already there

# Set this to the correct number of cards.

options snd cards_limit=2

options snd_hda_intel index=1

#This is what I added

options snd_hda_intel enable_msi=1

```

No idea why I expected MSI to help matters -- it usually seems to be causing problems in Linux-land -- but after enabling this, there seem to be no issues with playback on the analogue soundcard.

Not sure I trust it yet   :Rolling Eyes:   but will mark SOLVED after a bit more testing.

----------

