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

List:       kde-core-devel
Subject:    missing important features in aRts' server interface
From:       Hans Meine <hans_meine () gmx ! net>
Date:       2000-12-07 13:08:38
[Download RAW message or body]

Hi all!

How is such a proposal affected by today's feature freeze?
(Have a way to remote-suspend aRts from other programs)
I already planned and nearly-implemented a "Suspend now"-button in artscontrol
which also implies changes in the soundserver interface. AFAIK, the 
patches of Elvis affect binary compatibility :-(, but I already talked with
Stefan about a new interface in a BC way (derived IDL class). I would try
to merge my changes with Elvis' artsc-interface-changes (which I had not
think about before) and put a working solution into CVS, soon (today evening?).
(Stefan: Sure we have a long phone-talk before... ;-) )

This would also make aRts a little more transparent to the KDE-user, too,
as I plan to give feedback about:
- "xx" seconds until auto-suspend
- aRts realtime status (is it running realtime / why not)
in aRtscontrol.
I think both are important features (have in mind the many user-questions
about this and how hard the status of aRts is to grep right now) and easy
to implement.

So: anyone complaining/still calling this "new features" concerning the 
  freeze?


[Attachment #3 (message/rfc822)]


I am the packager of KDE2 for Conectiva Linux and found a problem with sound
recorders. Since aRts SimpleSoundServer does not implement sound recording
yet, the recorder application (e.g. KRecord) should have some method to make
aRts suspend the use of /dev/dsp, so the user does not have to wait 'n'
seconds to use the sound device.

It could even be used as an option for artsdsp for those applications that
can't cope with the LD_PRELOAD hack (e.g. RealPlayer can play  with artsdsp,
but can't seek or pause, it just SIGABRTs.)

What do you think about that ?

Follows the patches for aRts and krecord (as an example of use). BTW I would
like to congratulate you for the great work in aRts and the IDL framework
(you create a new method and automagically it gets available both in client
and server ends, no need of extending the protocol etc. etc.)

["krecord-arts.patch" (text/x-c)]

--- krecord-1.7/oss.cpp	Sat Nov  4 16:33:52 2000
+++ krecord-1.7.new/oss.cpp	Wed Dec  6 11:21:42 2000
@@ -9,6 +9,7 @@
 
 #include <sys/ioctl.h>
 #include <sys/soundcard.h>
+#include <artsc/artsc.h>
 
 #include "sound.h"
 #include "oss.moc"
@@ -21,6 +22,7 @@
 
 Soundcard::Soundcard(char *dev)
 {
+    arts_init();
     if (dev)
 	strcpy(devname,dev);
     else
@@ -38,6 +40,7 @@
 Soundcard::~Soundcard()
 {
     /* nothing */
+	arts_free();
 }
 
 int
@@ -101,8 +104,9 @@
     int i,dsp;
     int try_afmt;
     int try_channels;
-    
+
     afmt = 0;
+    arts_suspend();
     if (-1 != (dsp = open(devname, O_RDONLY))) {
 	
         ioctl(dsp, SNDCTL_DSP_SETFMT,  &afmt);     /* current */
@@ -180,6 +184,7 @@
     struct SOUNDPARAMS p;
     int frag,rrate;
 
+    arts_suspend();
     if (-1 == (fd = open(devname,record ? O_RDONLY : O_WRONLY)))
         goto err;
     fcntl(fd,F_SETFD,FD_CLOEXEC);

["kdelibs-2.01-artssuspendmethod.patch" (text/x-c)]

diff -urN arts/artsc/artsc.c arts.new/artsc/artsc.c
--- arts/artsc/artsc.c	Sat Jun  3 15:04:07 2000
+++ arts.new/artsc/artsc.c	Wed Dec  6 11:28:24 2000
@@ -25,6 +25,7 @@
 #include <assert.h>
 
 typedef int (*backend_init_ptr)();
+typedef void (*backend_suspend_ptr)();
 typedef void (*backend_free_ptr)();
 typedef arts_stream_t (*backend_play_stream_ptr)(int,int,int,const char*);
 typedef arts_stream_t (*backend_record_stream_ptr)(int,int,int,const char*);
@@ -40,6 +41,7 @@
 	lt_dlhandle handle;
 
 	backend_init_ptr init;
+	backend_suspend_ptr suspend;
 	backend_free_ptr free;
 	backend_play_stream_ptr play_stream;
 	backend_record_stream_ptr record_stream;
@@ -61,6 +63,8 @@
 		{
 			backend.init = (backend_init_ptr)
 				lt_dlsym(backend.handle, "arts_backend_init");
+			backend.suspend = (backend_suspend_ptr)
+				lt_dlsym(backend.handle, "arts_backend_suspend");
 			backend.free = (backend_free_ptr)
 				lt_dlsym(backend.handle, "arts_backend_free");
 			backend.play_stream = (backend_play_stream_ptr)
@@ -81,7 +85,8 @@
 
 		if(backend.handle && backend.init && backend.free && backend.play_stream
 			&& backend.record_stream && backend.close_stream && backend.write
-			&& backend.read && backend.stream_set && backend.stream_get)
+			&& backend.read && backend.stream_set && backend.stream_get
+			&& backend.suspend)
 			backend.available = 1;
 		else
 			backend.available = 0;
@@ -116,6 +121,11 @@
 	if(rc < 0) arts_backend_release();
 
 	return rc;
+}
+
+void arts_suspend()
+{
+	if (backend.available) backend.suspend();
 }
 
 void arts_free()
diff -urN arts/artsc/artsc.h arts.new/artsc/artsc.h
--- arts/artsc/artsc.h	Sun Jun 25 20:40:00 2000
+++ arts.new/artsc/artsc.h	Wed Dec  6 11:28:24 2000
@@ -135,6 +135,11 @@
 void arts_free(void);
 
 /**
+ * asks aRtsd to free the DSP device
+ */
+void arts_suspend(void);
+
+/**
  * converts an error code to a human readable error message
  *
  * @param errorcode the errorcode (from another arts function that failed)
diff -urN arts/artsc/artscbackend.cc arts.new/artsc/artscbackend.cc
--- arts/artsc/artscbackend.cc	Wed Aug 23 20:44:48 2000
+++ arts.new/artsc/artscbackend.cc	Wed Dec  6 11:28:24 2000
@@ -280,6 +280,14 @@
 		bsWrapper = ByteSoundProducer::null();
 	}
 
+	void suspend()
+	{
+		if(isAttached)
+		{
+			server.suspend();
+		}
+	}
+
 	int write(const mcopbyte *data, int size)
 	{
 		attach();
@@ -351,6 +359,10 @@
 		return 0;
 	}
 
+	void suspend() {
+		if(!server.isNull()) server.suspend();
+	}
+
 	void free() {
 		// nothing to do
 	}
@@ -448,6 +460,13 @@
 	int rc = ArtsCApi::the()->init();
 	if(rc < 0) ArtsCApi::release();
 	return rc;
+}
+
+extern "C" void arts_backend_suspend()
+{
+	if(!ArtsCApi::the()) return;
+	arts_backend_debug("arts_backend_suspend");
+	ArtsCApi::the()->suspend();	
 }
 
 extern "C" void arts_backend_free()
diff -urN arts/soundserver/simplesoundserver_impl.cc arts.new/soundserver/simplesoundserver_impl.cc
--- arts/soundserver/simplesoundserver_impl.cc	Wed Dec  6 11:29:50 2000
+++ arts.new/soundserver/simplesoundserver_impl.cc	Wed Dec  6 11:28:26 2000
@@ -223,6 +223,16 @@
 	return Object(SubClass(name));
 }
 
+void SimpleSoundServer_impl::suspend()
+{
+	if(Dispatcher::the()->flowSystem()->suspendable() &&
+	  !Dispatcher::the()->flowSystem()->suspended())
+	{
+		Dispatcher::the()->flowSystem()->suspend();
+		arts_info("suspended by program");
+	}
+}
+
 void SimpleSoundServer_impl::notifyTime()
 {
 	static long lock = 0;
diff -urN arts/soundserver/simplesoundserver_impl.h arts.new/soundserver/simplesoundserver_impl.h
--- arts/soundserver/simplesoundserver_impl.h	Wed Jul 12 08:59:46 2000
+++ arts.new/soundserver/simplesoundserver_impl.h	Wed Dec  6 11:28:26 2000
@@ -89,6 +89,7 @@
 	SimpleSoundServer_impl();
 	~SimpleSoundServer_impl();
 
+	void suspend();
 	void notifyTime();
 
 	// streaming audio
diff -urN arts/soundserver/soundserver.idl arts.new/soundserver/soundserver.idl
--- arts/soundserver/soundserver.idl	Wed May 17 19:48:20 2000
+++ arts.new/soundserver/soundserver.idl	Wed Dec  6 11:28:26 2000
@@ -69,6 +69,8 @@
 	 */
 	void attach(ByteSoundProducer producer);
 
+	void suspend();
+
 	/**
 	 * detaches a previous attached byte sound producer
 	 */

-- 
   /  /
  /--/
 /  / ANS
 _______________________________
/ Hans Meine | Hamburg, Germany \


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

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