From kde-core-devel Sun Aug 05 20:15:09 2001 From: Stefan Westerfeld Date: Sun, 05 Aug 2001 20:15:09 +0000 To: kde-core-devel Subject: [PATCH] graceful artsd behaviour without soundcard X-MARC-Message: https://marc.info/?l=kde-core-devel&m=99704267702517 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--mP3DRpeJDSE+ciuQ" --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Hi! The most end user visible issue with artsd in KDE2.2 until now probably was that if you had no soundcard, it would now violently complain about this, and an average user might not know what to do about it at all. As artsd would not start without soundcard, for instance noatun would have problems even playing videos without sound, as it absolutely requires artsd to run. The following patch tries to introduce more graceful behaviour. * artsd will tell the user that it will not do sound, but will stay around anyway * there will be this "don't show this message again" thing, which should give most users an idea what to do if they don't like to see the message each time they log in * knotify will be smart and not play sound over artsd if artsd is running silently without soundcard - this will remove the argument that one should not start artsd without soundcard since it will consume CPU all the time If you have objections, you have probably a little less than three hours before the packages are finished. ;) Cu... Stefan -- -* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany KDE Developer, project infos at http://space.twc.de/~stefan/kde *- --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="20010805-kdelibs-artsd-nosoundcard.diff" ? doc/TODO.X ? soundserver/TEXT Index: knotify/knotify.cpp =================================================================== RCS file: /home/kde/kdelibs/arts/knotify/knotify.cpp,v retrieving revision 1.51 diff -u -r1.51 knotify.cpp --- knotify/knotify.cpp 2001/04/28 00:50:29 1.51 +++ knotify/knotify.cpp 2001/08/05 19:59:08 @@ -63,7 +63,7 @@ QString externalPlayer; KProcess *externalPlayerProc; - Arts::SimpleSoundServer soundServer; + Arts::SoundServerV2 soundServer; Arts::PlayObjectFactory playObjectFactory; QValueList playObjects; @@ -110,7 +110,7 @@ : QObject(), DCOPObject("Notify") { d = new KNotifyPrivate; - d->soundServer = Arts::SimpleSoundServer::null(); + d->soundServer = Arts::SoundServerV2::null(); d->globalEvents = new KConfig("knotify/eventsrc", true, false, "data"); d->globalConfig = new KConfig("knotify.eventsrc", true, false); d->externalPlayerProc = 0; @@ -267,6 +267,9 @@ while( d->playObjects.count()>5 ) d->playObjects.remove( d->playObjects.begin() ); + if (d->soundServer.audioDevice() == "null") + return false; + Arts::PlayObject player = d->playObjectFactory.createPlayObject( QFile::encodeName(soundFile).data() ); if (player.isNull()) @@ -397,13 +400,13 @@ * startup sequence, even if artsd is started some time after the first * process requests knotify to do some notifications */ - Arts::SimpleSoundServer result; - d->soundServer = Arts::Reference("global:Arts_SimpleSoundServer"); + Arts::SoundServerV2 result; + d->soundServer = Arts::Reference("global:Arts_SoundServerV2"); if ( firstTime && d->soundServer.isNull() ) for( int tries=0; tries<7; tries++ ) { sleep( 1 ); - d->soundServer = Arts::Reference("global:Arts_SimpleSoundServer"); + d->soundServer = Arts::Reference("global:Arts_SoundServerV2"); if( !d->soundServer.isNull() ) break; } Index: soundserver/artsd.cc =================================================================== RCS file: /home/kde/kdelibs/arts/soundserver/artsd.cc,v retrieving revision 1.36 diff -u -r1.36 artsd.cc --- soundserver/artsd.cc 2001/03/26 16:01:30 1.36 +++ soundserver/artsd.cc 2001/08/05 19:59:10 @@ -71,6 +71,7 @@ fprintf(stderr,"-F number of fragments\n"); fprintf(stderr,"-S fragment size in bytes\n"); fprintf(stderr,"-s auto-suspend time in seconds\n"); + fprintf(stderr,"-f force starting artsd (if no soundcard is there, uses the null output device)\n"); fprintf(stderr,"\n"); fprintf(stderr,"misc options:\n"); fprintf(stderr,"-h display this help and exit\n"); @@ -106,6 +107,7 @@ static int cfgDebugLevel = 2; static const char *cfgDebugApp = 0; static bool cfgFullDuplex = 0; +static bool cfgForceStart = 0; static const char *cfgDeviceName = 0; static const char *cfgAudioIO = 0; static int cfgAutoSuspend = 0; @@ -116,7 +118,7 @@ static void handleArgs(int argc, char **argv) { int optch; - while((optch = getopt(argc,argv,"r:p:nuF:S:hD:dl:a:Ab:s:m:vNw:")) > 0) + while((optch = getopt(argc,argv,"r:p:nuF:S:hD:dl:a:Ab:s:m:vNw:f")) > 0) { switch(optch) { @@ -154,6 +156,8 @@ break; case 'w': cfgBuffers = atoi(optarg); break; + case 'f': cfgForceStart = true; + break; case 'h': default: exitUsage(argc?argv[0]:"artsd"); @@ -250,6 +254,19 @@ if(cfgFullDuplex) AudioSubSystem::the()->fullDuplex(cfgFullDuplex); if(cfgDeviceName) AudioSubSystem::the()->deviceName(cfgDeviceName); if(cfgBits) AudioSubSystem::the()->format(cfgBits); + + if(cfgForceStart && !AudioSubSystem::the()->check()) + { + /* hack to get this message to the user in any case */ + Debug::init("[artsd]", static_cast(1)); + arts_info( + "Error while initializing the sound driver:\n" + "%s\n\n" + "The sound server will continue, using the null output device.", + AudioSubSystem::the()->error()); + Debug::init("[artsd]", static_cast(cfgDebugLevel)); + AudioSubSystem::the()->audioIO("null"); + } if(!AudioSubSystem::the()->check()) { --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="20010805-kdebase-artsd-nosoundcard.diff" ? pics/hicolor/.xvpics ? pics/hicolor/hi32-app-arts.png ? pics/hicolor/hi48-app-arts.png Index: arts/arts.cpp =================================================================== RCS file: /home/kde/kdebase/kcontrol/arts/arts.cpp,v retrieving revision 1.44 diff -u -r1.44 arts.cpp --- arts/arts.cpp 2001/07/29 20:54:50 1.44 +++ arts/arts.cpp 2001/08/05 19:59:32 @@ -472,7 +472,7 @@ bool startServer = config->readBoolEntry("StartServer",true); bool startRealtime = config->readBoolEntry("StartRealtime",true); bool x11Comm = config->readBoolEntry("X11GlobalComm",false); - QString args = config->readEntry("Arguments","-F 10 -S 4096 -s 60 -m artsmessage -l 3"); + QString args = config->readEntry("Arguments","-F 10 -S 4096 -s 60 -m artsmessage -l 3 -f"); delete config; @@ -536,6 +536,7 @@ args += QChar(' ') + addOptions; args += QString::fromLatin1(" -l %1").arg(loggingLevel); + args += QString::fromLatin1(" -f"); return args; } --mP3DRpeJDSE+ciuQ--