Skip to contentSkip to conversation

AUDIO2000 and DShare plugin

DISCUSSION James Stafford 2 participants 6 messages Apr 18, 2006 – Apr 25, 2006

lore
Share & tools
lore
#0 lore raw

Hi,
Almost two years ago (May 2003), the company I work for successfully used the DShare plugin to have each channel of our Envy24HT based PC104+ card controlled by a different application. To do this, we had an entry for each channel in the .asoundrc file similar to this

pcm.dshare_frontl {
	type dshare
	ipc_key 9874545
	ipc_key_add_uid yes
	slave {
		pcm "hw:0,0"
	}
	bindings {
		0 0
	}
}

A customer of ours now wants to do something similar but using a later version of ALSA.
We have found that the old .asoundrc doesn't work with the latest ALSA. Using the pcm test program from ALSA-lib-1.0.10 gives the following

[james]$ ./pcm -Ddshare_frontl
Playback device is dshare_frontr
Stream parameters are 44100Hz, S16_LE, 1 channels
Sine wave rate is 440.0000Hz
Using transfer method: write
ALSA lib pcm_direct.c:812:(snd_pcm_direct_initialize_slave) requested or auto-format is not available ALSA lib pcm_dshare.c:682:(snd_pcm_dshare_open) unable to initialize slave
Playback open error: Invalid argument

I can overcome this error by changing the .asoundrc entries to read

pcm.dshare_frontl {
	type dshare
	ipc_key 9874545
	ipc_key_add_uid yes
	slave {
		pcm "hw:0,0"
		format S32_LE
		rate 48000
	}
	bindings {
		0 0
	}
}

and using -Dplug:dshare_frontl
However, running multiple instances of pcm is causing a segmentation fault. Running pcm from within gdb gives the following backtrace

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208712096 (LWP 2605)] 0xb7f99874 in snd_pcm_area_copy (dst_area=0xc, dst_offset=6008,

    src_area=0x804d0c8, src_offset=0, samples=11992,
    format=SND_PCM_FORMAT_S32_LE) at pcm.c:2487
2487            if (!dst_area->addr)
(gdb) bt
#0  0xb7f99874 in snd_pcm_area_copy (dst_area=0xc, dst_offset=6008,
    src_area=0x804d0c8, src_offset=0, samples=11992,
    format=SND_PCM_FORMAT_S32_LE) at pcm.c:2487
#1  0xb7fc9172 in share_areas (dshare=0x8055160, src_areas=0x804d0c8,
    dst_areas=0x0, src_ofs=0, dst_ofs=6008, size=11992) at pcm_dshare.c:94
#2  0xb7fc9320 in snd_pcm_dshare_sync_area (pcm=0x8055218) at pcm_dshare.c:146
#3  0xb7fc98ff in snd_pcm_dshare_start (pcm=0x8055218) at pcm_dshare.c:351
#4  0xb7f97601 in snd_pcm_start (pcm=0x8055ee8) at pcm.c:1005
#5  0xb7fa64a3 in snd_pcm_generic_start (pcm=0xc) at pcm_generic.c:155
#6  0xb7f97601 in snd_pcm_start (pcm=0x8055ee8) at pcm.c:1005
#7  0xb7f9dc7e in snd_pcm_write_areas (pcm=0x8055d68, areas=0xbffff500,
    offset=5512, size=0, func=0xb7fb3f20 <snd_pcm_mmap_write_areas>)
    at pcm.c:6457
#8  0xb7fb41ac in snd_pcm_mmap_writei (pcm=0x8055d68, buffer=0x80797d0,
    size=5512) at pcm_mmap.c:186
#9  0xb7f97957 in snd_pcm_writei (pcm=0x8055ee8, buffer=0x80797d0, size=0)
    at pcm_local.h:401
#10 0x0804996f in write_loop (handle=0x8055b90, samples=0x80797d0,
    areas=0x8055708) at pcm.c:233

#11 0x0804aa38 in main (argc=2, argv=0xbffff9e4) at pcm.c:873

It has been almost 2 years since I used ALSA (or the Envy24HT) and so I am a little out of touch with the code. Can anyone give me a clue for how to solve this problem?

--
James Stafford

Advanced Micro Peripherals Ltd
Unit 1
Harrier House
Sedgeway Business Park
Witchford
Cambridge
CB6 2HY

Fax:+44 1353 659 600

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#1 lore raw

At Tue, 18 Apr 2006 16:12:09 +0100,

Quoted 20 lines · James Stafford

Hi,
Almost two years ago (May 2003), the company I work for successfully used the DShare plugin to have each channel of our Envy24HT based PC104+ card controlled by a different application.
To do this, we had an entry for each channel in the .asoundrc file similar to this

pcm.dshare_frontl {
	type dshare
	ipc_key 9874545
	ipc_key_add_uid yes
	slave {
		pcm "hw:0,0"
	}
	bindings {
		0 0
	}
}
Quoted 4 lines

A customer of ours now wants to do something similar but using a later version of ALSA.
We have found that the old .asoundrc doesn't work with the latest ALSA. Using the pcm test program from ALSA-lib-1.0.10 gives the following

Could you try with ALSA 1.0.11?

Takashi

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#2 lore raw
Quoted 3 lines

Could you try with ALSA 1.0.11?

I tried with 1.0.11rc5 and still had the problem (I don't currently have the hardware setup to try 1.0.11). In the end I solved the seg fault by changing from using dshare to dmix.
The entries in .asoundrc ended up as follows

pcm.dshare2{
        type dmix
        ipc_key 2048
        slave {
                pcm "hw:0"
                format S32_LE
                channels 6
        }
        bindings {
                0 0
                1 1
                2 4
                3 5
                4 2
                5 3
        }
}
pcm.frontl {
        type plug
        slave {
                pcm "dshare2"
                channels 6
        }
        ttable.0.0 1
}

etc

This probably isn't the most elegant solution but worked.

--
James Stafford

mailto:[email protected]

Advanced Micro Peripherals Ltd
Unit 1
Harrier House
Sedgeway Business Park
Witchford
Cambridge
CB6 2HY

Fax:+44 1353 659 600

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#3 lore raw

At Thu, 20 Apr 2006 16:27:01 +0100,

Quoted 5 lines · James Stafford
Quoted 2 lines

Could you try with ALSA 1.0.11?

I tried with 1.0.11rc5 and still had the problem (I don't currently have the hardware setup to try 1.0.11).

OK, then please show the backtrace if possible.

Quoted 2 lines

In the end I solved the seg fault by changing from using dshare to dmix. The entries in .asoundrc ended up as follows

Then the problem is apparently in dshare only.

thanks,

Takashi

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#4 lore raw
Quoted 5 lines
Quoted 3 lines

I tried with 1.0.11rc5 and still had the problem (I don't currently have the hardware setup to try 1.0.11).

OK, then please show the backtrace if possible.

I tried 1.0.11 and also got the same seg fault.

With pcm -Dplug:dshare_frontl running in one terminal, I used gdb to run pcm -Dplug:dshare_frontr in another. This is the output I got (using ALSA libs 1.0.11):

Starting program: /home/james/audio2000/alsa-lib-1.0.11/test/pcm -Dplug:dshare_frontr [Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 1148)]
Playback device is plug:dshare_frontr
Stream parameters are 44100Hz, S16_LE, 1 channels
Sine wave rate is 440.0000Hz
Using transfer method: write

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 1148)]
0x4003bc6c in snd_pcm_area_copy (dst_area=0xc, dst_offset=12000,

    src_area=0x804d150, src_offset=0, samples=6000,
    format=SND_PCM_FORMAT_S32_LE) at pcm.c:2537
2537            if (!dst_area->addr)
(gdb) bt
#0  0x4003bc6c in snd_pcm_area_copy (dst_area=0xc, dst_offset=12000,
    src_area=0x804d150, src_offset=0, samples=6000,
    format=SND_PCM_FORMAT_S32_LE) at pcm.c:2537
#1  0x40069d0a in share_areas (dshare=0x80555b0, src_areas=0x804d150,
    dst_areas=0x0, src_ofs=0, dst_ofs=12000, size=6000) at pcm_dshare.c:94
#2  0x40069eb8 in snd_pcm_dshare_sync_area (pcm=0x8055670) at pcm_dshare.c:146
#3  0x4006a497 in snd_pcm_dshare_start (pcm=0x8055670) at pcm_dshare.c:351
#4  0x40039a11 in snd_pcm_start (pcm=0x8056390) at pcm.c:1053
#5  0x4004b5b3 in snd_pcm_generic_start (pcm=0xc) at pcm_generic.c:155
#6  0x40039a11 in snd_pcm_start (pcm=0x8056390) at pcm.c:1053
#7  0x4004006a in snd_pcm_write_areas (pcm=0x8056210, areas=0xbffff570,
    offset=0, size=5512, func=0x40049ffc <snd_pcm_mmap_write_areas>)
    at pcm.c:6506
#8  0x4004a288 in snd_pcm_mmap_writei (pcm=0x8056210, buffer=0x8079c78,
    size=5512) at pcm_mmap.c:186
#9  0x40039d67 in snd_pcm_writei (pcm=0x8056390, buffer=0x8079c78, size=0)
    at pcm_local.h:401
#10 0x08049977 in write_loop (handle=0x8055ff8, samples=0x8079c78,
    areas=0x8055b68) at pcm.c:236

#11 0x0804aa40 in main (argc=2, argv=0xbffffa24) at pcm.c:876 (gdb)

The relevant entries in my .asoundrc are

pcm.dshare_frontl {
        type dshare
        ipc_key 9874545
        ipc_key_add_uid yes
        slave {
                pcm "hw:0,0"
                format S32_LE
                rate 48000
        }
        bindings {
                0 0
        }
}
pcm.dshare_frontr {
        type dshare
        ipc_key 9874545
        ipc_key_add_uid yes
        slave {
                pcm "hw:0,0"
                format S32_LE
                rate 48000
        }
        bindings {
                0 1
        }
}

--
James Stafford

mailto:[email protected]

Advanced Micro Peripherals Ltd
Unit 1
Harrier House
Sedgeway Business Park
Witchford
Cambridge
CB6 2HY

Fax:+44 1353 659 600

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#5 lore raw

At Mon, 24 Apr 2006 09:30:11 +0100,

Quoted 22 lines · James Stafford
Quoted 6 lines
Quoted 4 lines

I tried with 1.0.11rc5 and still had the problem (I don't currently have the hardware setup to try 1.0.11).

OK, then please show the backtrace if possible.

I tried 1.0.11 and also got the same seg fault.

With pcm -Dplug:dshare_frontl running in one terminal, I used gdb to run pcm -Dplug:dshare_frontr in another.
This is the output I got (using ALSA libs 1.0.11):

Starting program: /home/james/audio2000/alsa-lib-1.0.11/test/pcm -Dplug:dshare_frontr
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 1148)]
Playback device is plug:dshare_frontr
Stream parameters are 44100Hz, S16_LE, 1 channels
Sine wave rate is 440.0000Hz
Using transfer method: write

Quoted 6 lines

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 1148)]
0x4003bc6c in snd_pcm_area_copy (dst_area=0xc, dst_offset=12000,

     src_area=0x804d150, src_offset=0, samples=6000,
     format=SND_PCM_FORMAT_S32_LE) at pcm.c:2537

2537 if (!dst_area->addr)

Thanks for the back trace.

It turned out to be a bug in dshare plugin. I fixed it on Hg repo. The fix patch is below, one-liner.

Takashi

src/pcm/pcm_dshare.c +0 -1
diff -r f8249fa48b9c src/pcm/pcm_dshare.c
@@ -706,7 +706,6 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp
 			
 		snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT);
 		ret = snd_pcm_direct_open_secondary_client(&spcm, dshare, "dshare_client");
-		ret = snd_pcm_hw_open_fd(&spcm, "dshare_client", dshare->hw_fd, 0, 0);
 		if (ret < 0)
 			goto _err;
 		dshare->spcm = spcm;

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642