[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: PATCH to load artsdsp in nsplugins
From:       Stefan Westerfeld <stefan () space ! twc ! de>
Date:       2001-01-30 12:20:45
[Download RAW message or body]

Hi!

On Mon, Jan 29, 2001 at 10:07:04PM +0100, Stefan Schimanski wrote:
> On Monday 29 January 2001 21:04, Stefan Schimanski wrote:
> > please checkout this patch if you have a sound driver that doesn't support
> > non-blocking access to /dev/dsp. The flash plugin for example is known to
> > freeze konqi on such systems. I can't test this code here, so I depend on
> > your feedback!
> 
> Forget this patch. It doesn't solve the problem either, but blocks in the 
> fopen call :(

You could try this:

  int fd = open("/dev/dsp", O_WRONLY | O_NDELAY);


About the general problem of flash & artsdsp: I have tried getting artsdsp to
work "properly" with flash. It's weird. I implemented the things that the
flash thingy does, and that artsdsp didn't support before, like:
 
 * changing the fragment size
 * non-blocking read/write

And still... it doesn't work. It seems that there is no performance problem
transferring the data to artsd, because I didn't see underruns occur in
artsd, so the flash plugin probably outputs zero samples when running with
arts (which I really can't understand, either).

Anyway, I am attaching the patch... perhaps anybody else has a good idea what
else to try. It might also make a few more apps work better, but then again,
it also might make a few more apps break (which use strange fragment settings,
which might make artsdsp do the wrong thing).

   Cu... Stefan
-- 
  -* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
     KDE Developer, project infos at http://space.twc.de/~stefan/kde *-         

["artsdsp-nblock-fragsize.diff" (text/plain)]

cvs server: Diffing .
Index: artscbackend.cc
===================================================================
RCS file: /home/kde/kdelibs/arts/artsc/artscbackend.cc,v
retrieving revision 1.15
diff -u -r1.15 artscbackend.cc
--- artscbackend.cc	2001/01/17 15:21:26	1.15
+++ artscbackend.cc	2001/01/30 12:14:45
@@ -164,13 +164,22 @@
 		if(isAttached)
 			return ARTS_E_NOIMPL;
 
-		packetCount = settings >> 16;
-		
-		packetCapacity = 1;
-		int c = settings & 0xffff;
-		while(c > 0) {
-			packetCapacity *= 2;
-			c--;
+		if((settings & 0x7fff0000) != 0x7fff0000)
+			packetCount = settings >> 16;
+
+		if((settings & 0x00007fff) != 0x00007fff)
+		{
+			packetCapacity = 1;
+			int c = settings & 0xffff;
+			while(c > 0) {
+				packetCapacity *= 2;
+				c--;
+			}
+		}
+		else
+		{
+			/* choose something convenient */
+			packetCapacity = 4096;
 		}
 
 		/*
Index: artsdsp.c
===================================================================
RCS file: /home/kde/kdelibs/arts/artsc/artsdsp.c,v
retrieving revision 1.26
diff -u -r1.26 artsdsp.c
--- artsdsp.c	2001/01/02 18:05:37	1.26
+++ artsdsp.c	2001/01/30 12:14:46
@@ -67,6 +67,8 @@
 static int settings;
 static int arts_init_done = 0;
 static arts_stream_t stream = 0;
+static int blocking;
+static int frags;
 
 #if defined(HAVE_IOCTL_INT_INT_DOTS)
 typedef int ioctl_request_t;
@@ -192,6 +194,8 @@
 
   settings = 0;
   stream = 0;
+  frags = 0;
+  blocking = 1;
 
   artsdspdebug ("aRts: hijacking /dev/dsp open...\n");
 
@@ -221,6 +225,7 @@
   static int channels;
   static int bits;
   static int speed;
+  static int blocking;
   int space, size, latency, odelay;
 
   /*
@@ -317,7 +322,8 @@
 
 #ifdef SNDCTL_DSP_SETFRAGMENT
         case SNDCTL_DSP_SETFRAGMENT:        /* _SIOWR('P',10, int) */
-		  artsdspdebug("aRts: SNDCTL_DSP_SETFRAGMENT(%x) unsupported\n",*arg);
+		  artsdspdebug("aRts: SNDCTL_DSP_SETFRAGMENT(%x) only partially supported\n",*arg);
+		  frags = *arg;
 		  break;
 #endif
 
@@ -348,12 +354,16 @@
               stream?arts_stream_get(stream, ARTS_P_BUFFER_SPACE):16384;
             audiop->fragments = audiop->bytes / audiop->fragsize;
 		  }
+		  artsdspdebug("returning (io)space = (ftotal: %d, fsize: %d, bytes: %d, frags: %d)\n",
+            audiop->fragstotal, audiop->fragsize, audiop->bytes,
+			audiop->fragments);
           break;
 #endif
 
 #ifdef SNDCTL_DSP_NONBLOCK
 		case SNDCTL_DSP_NONBLOCK:           /* _SIO  ('P',14) */
-		  artsdspdebug("aRts: SNDCTL_DSP_NONBLOCK unsupported\n");
+		  blocking = 0;
+		  /*artsdspdebug("aRts: SNDCTL_DSP_NONBLOCK unsupported\n");*/
 		  break;
 #endif
 
@@ -445,6 +455,16 @@
 
           artsdspdebug ("aRts: creating stream...\n");
           stream = arts_play_stream(speed,bits,channels,name?name:"artsdsp");
+
+		  if(!blocking)
+		    arts_stream_set(stream,ARTS_P_BLOCKING,0);
+
+		  if(frags)
+		    arts_stream_set(stream,ARTS_P_PACKET_SETTINGS,frags);
+		  arts_stream_set(stream,ARTS_P_PACKET_SETTINGS,0x00660008);
+		  artsdspdebug("aRts: %d packets with %d bytes\n",
+			  arts_stream_get(stream,ARTS_P_PACKET_COUNT),
+              arts_stream_get(stream, ARTS_P_PACKET_SIZE));
 
 		  if(mmapemu)
 		  {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic