5.2-CURRENT a prehravani wav souboru

Divacky Roman xdivac02 at stud.fit.vutbr.cz
Thu Aug 19 11:38:07 CEST 2004


On Wed, Aug 18, 2004 at 01:31:35PM +0200, Tomas Pluskal wrote:
> 
> >no... operace prehravani wavu je v podstate "cat neco > /dev/nekam" to by 
> >nemel
> >upgrade jadra moc ovlivnovat
> 
> pokud dam 'cat <soubor.wav> > /dev/dsp' tak se mi ozvou jen skreky 
> (rozsypany caj v audio podobe), ackoli treba ten wavplay je prehrava 
> normalne
 
mam tendenci veci dost zjednodusovat ;) jasne ze je potreba nastavit jeste
ruzne parametry prehravani ale princip je jasny ne?
 
 
> >jedine co ti poradim je vypnuti/zapnuti vchanu. popr. si to tracnout pres
> >ktrace play -d /dev/dsp0 cosi.wav
> >a pak
> >kdump
> >mohlo by ti to pomoct k zjisteni kde je chyba
> 
> kdump:
> ...
>  57779 play     RET   read 44/0x2c
>  57779 play     CALL  open(0xbfbfe9ac,0x1,0x280b8df8)
>  57779 play     NAMI  "/dev/dsp1"
>  57779 play     RET   open 4
>  57779 play     CALL  ioctl(0x4,SNDCTL_DSP_GETBLKSIZE,0xbfbfe7e8)
>  57779 play     RET   ioctl 0
>  57779 play     CALL  ioctl(0x4,SNDCTL_DSP_SETFMT,0x804bf20)
>  57779 play     RET   ioctl -1 errno 19 Operation not supported by device
>  57779 play     CALL  write(0x2,0xbfbfe000,0x6)
>  57779 play     GIO   fd 2 wrote 6 bytes
>        "play: "
> ...
> 
> vypis z wavplay vypada podobne:
> ...
>  78934 wavplay  CALL  ioctl(0x4,SNDCTL_DSP_GETBLKSIZE,0x8054034)
>  78934 wavplay  RET   ioctl 0
>  78934 wavplay  CALL  break(0x8056000)
>  78934 wavplay  RET   break 0
>  78934 wavplay  CALL  ioctl(0x4,SNDCTL_DSP_SETFMT,0xbfbfe778)
>  78934 wavplay  RET   ioctl 0
>  78934 wavplay  CALL  ioctl(0x4,SNDCTL_DSP_STEREO,0xbfbfe778)
>  78934 wavplay  RET   ioctl 0
>  78934 wavplay  CALL  ioctl(0x4,SNDCTL_DSP_SPEED,0xbfbfe774)
>  78934 wavplay  RET   ioctl 0
>  78934 wavplay  CALL  ioctl(0x4,AUDIO_COMPAT_DRAIN,0)
>  78934 wavplay  RET   ioctl 0
> ...
> 
> problem je tedy zrejme v tom volani SNDCTL_DSP_SETFMT, musel bych ale 
> zjistit s jakymi parametry se to presne vola.

tak jsem se na to dival (mimochodem, proc vsichni Cckari pisou jako prasata?
tihle navic jako tezce lame prasata ;)) a tendle patch by mohl pomoct
(ale bacha - je to uz po aplikace nejakeho jineho patche takze si s tim budete
muset pohrat) - pokdu to pofunguje tak nekdo poslete PR... (ja jsem desne linej
v tomdle vedru) thnx

--- play-1.0/encode_riff.c	Tue Mar 25 16:25:07 1997
+++ /root/play-1.0/encode_riff.c	Thu Aug 19 11:32:30 2004
@@ -11,7 +11,7 @@
 #include <signal.h>
 #include <err.h>
 
-#include <machine/soundcard.h>
+#include <sys/soundcard.h>
 
 #include "play.h"
 #include "encode_riff.h"
@@ -74,7 +74,7 @@
     char *bufp;
     char *device;
     int devfd, filefd;
-    int stat, len, buf_size, format, data_length;
+    int stat, len, buf_size, format = 0, data_length;
 
     if (!f_hasdsp) {
 	fprintf(stderr, "%s: %s: needs DSP for play\n", myname, audio_file);
@@ -109,7 +109,12 @@
 	warn("%s", device);
 	stat = FAIL; goto failplay0;
     }
+#if YOU_ARE_FUCKING_IDIOT
+    /* this (at least under fbsd) means that you want to set play format
+     * to headerp->sample_size which is a nonsense */
     if (ioctl(devfd, SNDCTL_DSP_SAMPLESIZE, &headerp->sample_size) < 0) {
+#endif
+    if (ioctl(devfd, SNDCTL_DSP_SAMPLESIZE, &format) < 0) {
 	warn("%s", device);
 	stat = FAIL; goto failplay0;
     }
@@ -121,11 +126,6 @@
 	warn("%s", device);
 	stat = FAIL; goto failplay0;
     }
-    /* XXX */
-    if (ioctl(devfd, SNDCTL_DSP_SETFMT, &format) < 0) {
-	warn("%s", device);
-	stat = FAIL; goto failplay0;
-    }
     if (headerp->channels > 1) {
 	int ch = headerp->channels;
 	if (ioctl(devfd, SNDCTL_DSP_STEREO, &ch) < 0) {
@@ -163,6 +163,8 @@
 	    warn("read");
 	    stat = FAIL; goto failplay2;
 	}
+/*	printf("len = %10d, len = %10d\n", stat, len); */
+	stat = (len < stat)? len : stat;
 	if (write(devfd, bufp, stat) < 0) {
 	    warn("write");
 	    stat = FAIL; goto failplay2;

> >
> >a mimochodem, ja na sve (ted uz) 6-current zadne /dev/dsp0 nemam (akorat 
> >dsp0.0
> >atp)
> 
> Ja je tam taky nemam (v tom smyslu ze nejsou videt pri 'ls /dev', nicmene 
> tam tyhle zarizeni jsou (prehravam pres ne zvuk z mplayeru, xmms, 
> wavplay..). Nevim proc nejsou videt, zrejme je to zalezitost devfs.

spis vchans... ale je fakt ze mi to prehravani na /dev/dsp0 funguje taky ;)

roman



More information about the Users-l mailing list