summaryrefslogtreecommitdiffstats
path: root/soundserver/soundserverstartup_impl.cc
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-06 19:28:06 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-06 19:28:49 +0900
commit247750abcbf6760bbc52aa5d64fc375d6fbee8a3 (patch)
tree86e029a960ddd599edbeee8dddf70e87ee314e23 /soundserver/soundserverstartup_impl.cc
parent595ad58e25c5d0f0c512194f66708f99e5bc1527 (diff)
downloadarts-247750abcbf6760bbc52aa5d64fc375d6fbee8a3.tar.gz
arts-247750abcbf6760bbc52aa5d64fc375d6fbee8a3.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 00d4f92b717fbcbed6f9eee361975d6ee5380d59)
Diffstat (limited to 'soundserver/soundserverstartup_impl.cc')
-rw-r--r--soundserver/soundserverstartup_impl.cc99
1 files changed, 0 insertions, 99 deletions
diff --git a/soundserver/soundserverstartup_impl.cc b/soundserver/soundserverstartup_impl.cc
deleted file mode 100644
index a0183d6..0000000
--- a/soundserver/soundserverstartup_impl.cc
+++ /dev/null
@@ -1,99 +0,0 @@
- /*
-
- Copyright (C) 2003 Stefan Westerfeld
- stefan@space.twc.de
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- */
-
-#include "config.h"
-#include "debug.h"
-#include "soundserverstartup_impl.h"
-#include <sys/time.h>
-#include <time.h>
-#include <cstdlib>
-
-using namespace Arts;
-
-SoundServerStartup_impl::SoundServerStartup_impl()
-{
- locked = false;
- /*
- * create a sane random seed, pseudo random is not enough for
- * our purposes
- */
- timeval tv;
- gettimeofday(&tv, NULL);
-
- int pid = getpid();
- srand(tv.tv_sec);
- srand(rand() + tv.tv_usec);
- srand(rand() + pid);
-}
-
-SoundServerStartup_impl::~SoundServerStartup_impl()
-{
- if (locked)
- unlock();
-}
-
-void SoundServerStartup_impl::cleanReference()
-{
- SoundServerStartup test = Reference("global:Arts_SoundServerStartup");
- if(test.isNull())
- Dispatcher::the()->globalComm().erase("Arts_SoundServerStartup");
-}
-
-void SoundServerStartup_impl::lock()
-{
- arts_return_if_fail (!locked);
-
- while (!ObjectManager::the()->addGlobalReference(self(), "Arts_SoundServerStartup"))
- {
- arts_debug ("[artsd: %5d] parallel startup detected: sleeping",getpid());
-
- /*
- * if several instances of artsd are started at the same time,
- * we don't want all of them to retry getting a reference at
- * exactly the same moment ; thus we sleep for a random amount
- * of time, rather than for exactly one second, if possible
- */
-#ifdef HAVE_USLEEP
- usleep((rand() % 700000) + 200000);
-#else
- sleep(1);
-#endif
- cleanReference();
- }
- locked = true;
- arts_debug ("[artsd: %5d] SoundServerStartup --> got lock",getpid());
-}
-
-void SoundServerStartup_impl::unlock()
-{
- arts_return_if_fail (locked);
-
- arts_debug ("[artsd: %5d] SoundServerStartup <-- released lock",getpid());
- Dispatcher::the()->globalComm().erase("Arts_SoundServerStartup");
- locked = false;
-}
-
-namespace Arts {
-#ifndef __SUNPRO_CC
- /* See bottom of simplesoundserver_impl.cc for the reason this is here. */
-REGISTER_IMPLEMENTATION(SoundServerStartup_impl);
-#endif
-}