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

List:       kde-core-devel
Subject:    PATCH: aRts & flash
From:       Stefan Westerfeld <stefan () space ! twc ! de>
Date:       2001-01-30 14:37:36
[Download RAW message or body]

Hi!

Finally, I found a way to make aRts and flash work together. The problem was
that the flash plugin did call GETBLKSIZE before having really set all
parameters which are needed to create the stream. At that time, artsdsp made
a blind guess (16384) what the block size will be, as that can only be really
found out after the stream has been opened (then the buffering parameters will
be determined).

However, the flash plugin sets the fragment size even before calling
GETBLKSIZE. So what this patch does is adapting the block size to the
fragment size that was requested before. It also applies the parameters to
the stream. The aRts server itself can work with any packet size (smaller
packets = more cpu usage) and will only adapt the number of packets
accordingly so that we can guarantee that the block size confirmed at the
beginning can be used in any case.

If there are no objections, I'd like to apply it tomorrow.

It would be good if everybody could test whether the apps that used to work
with artsdsp still work with the patch. You never know ;-).

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

["20010130-artsdsp-flash.diff" (text/plain)]

? flash-works
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 14:23:28
@@ -67,6 +67,7 @@
 static int settings;
 static int arts_init_done = 0;
 static arts_stream_t stream = 0;
+static int frags;
 
 #if defined(HAVE_IOCTL_INT_INT_DOTS)
 typedef int ioctl_request_t;
@@ -191,6 +192,7 @@
     return orig_open (pathname, flags, mode);
 
   settings = 0;
+  frags = 0;
   stream = 0;
 
   artsdspdebug ("aRts: hijacking /dev/dsp open...\n");
@@ -276,10 +278,18 @@
 
 #ifdef SNDCTL_DSP_GETBLKSIZE
         case SNDCTL_DSP_GETBLKSIZE:			/* _SIOWR('P', 4, int) */
-		  if(mmapemu)
-			*arg = 4096;
-		  else
-			*arg = stream?arts_stream_get(stream,ARTS_P_PACKET_SIZE):16384;
+          if(mmapemu)
+            *arg = 4096;
+          else if(stream)
+            *arg = arts_stream_get(stream,ARTS_P_PACKET_SIZE);
+          else
+          {
+            int fragSize = frags & 0x7fff;
+            if(fragSize > 1 && fragSize < 16)
+              *arg = (1 << fragSize);
+            else
+              *arg = 16384; /* no idea ;-) */
+          }
           break;
 #endif
 
@@ -317,8 +327,10 @@
 
 #ifdef SNDCTL_DSP_SETFRAGMENT
         case SNDCTL_DSP_SETFRAGMENT:        /* _SIOWR('P',10, int) */
-		  artsdspdebug("aRts: SNDCTL_DSP_SETFRAGMENT(%x) unsupported\n",*arg);
-		  break;
+          artsdspdebug("aRts: SNDCTL_DSP_SETFRAGMENT(%x) partially supported\n",
+                          *arg);
+          frags = *arg;
+          break;
 #endif
 
 #ifdef SNDCTL_DSP_GETFMTS
@@ -442,10 +454,27 @@
       if (settings == 7 && !stream)
         {
           const char *name = getenv("ARTSDSP_NAME");
+          int fragSize = (frags & 0x7fff);
+          int fragCount = (frags & 0x7fff0000) >> 16;
 
           artsdspdebug ("aRts: creating stream...\n");
           stream = arts_play_stream(speed,bits,channels,name?name:"artsdsp");
 
+          if(fragSize > 1 && fragSize < 16)
+          {
+            /*
+             * if fragment settings are way too large (unrealistic), we
+             * will assume that the user didn't mean it, and let the C API
+             * choose a convenient number >= 3
+             */
+            if(fragCount < 2 || fragCount > 8192
+            || (fragCount * (1 << fragSize)) > 128*1024)
+            {
+              frags = 0x00030000+fragSize;
+            }
+
+            arts_stream_set(stream,ARTS_P_PACKET_SETTINGS,frags);
+          }
 		  if(mmapemu)
 		  {
 		    arts_stream_set(stream,ARTS_P_PACKET_SETTINGS,0x0002000c);


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

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