From ed339d93850bd931cceb65b1a0f3179adb880f57 Mon Sep 17 00:00:00 2001 From: Stelios Bounanos Date: Mon, 28 Apr 2008 20:46:23 +0100 Subject: [PATCH] Use unnamed semaphores Also check for zoh/linear converters by enum name --- src/include/sound.h | 5 ----- src/soundcard/sound.cxx | 30 ++++++++++-------------------- src/soundcard/soundconf.cxx | 4 ++-- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/include/sound.h b/src/include/sound.h index fa0b197d..48658025 100644 --- a/src/include/sound.h +++ b/src/include/sound.h @@ -267,11 +267,6 @@ private: sem_t* csem; int state; ringbuffer* rb; - - Cmovavg* avg; - double est_sample_rate; - unsigned long nframes; - PaTime stime; } sd[2]; }; diff --git a/src/soundcard/sound.cxx b/src/soundcard/sound.cxx index 342471eb..3db95e75 100644 --- a/src/soundcard/sound.cxx +++ b/src/soundcard/sound.cxx @@ -55,7 +55,6 @@ #include "timeops.h" #include "ringbuffer.h" -#include "filters.h" // We always read and write 2 channels from/to the audio device. // * input: we ignore the right channel of captured samples @@ -709,21 +708,13 @@ SoundPort::SoundPort(const char *in_dev, const char *out_dev) sd[0].dev_sample_rate = sd[1].dev_sample_rate = 0; sd[0].state = sd[1].state = spa_continue; sd[0].rb = sd[1].rb = 0; - sd[0].est_sample_rate = sd[1].est_sample_rate = 0.0; - sd[0].avg = new Cmovavg(128); - sd[1].avg = new Cmovavg(128); - sem_t** sems[] = { &sd[0].rwsem, &sd[0].csem, &sd[1].rwsem, &sd[1].csem }; - char sname[32]; + sem_t** sems[] = { &sd[0].rwsem, &sd[0].csem, &sd[1].rwsem, &sd[1].csem }; for (size_t i = 0; i < sizeof(sems)/sizeof(*sems); i++) { - snprintf(sname, sizeof(sname), "%u-%u-%s", i, getpid(), PACKAGE); - if ((*sems[i] = sem_open(sname, O_CREAT | O_EXCL, 0600, 0)) == SEM_FAILED) - throw SndException(errno); -#ifndef __CYGWIN__ // FIXME: write an autoconf macro for sem_unlink - if (sem_unlink(sname) == -1) - throw SndException(errno); -#endif - } + *sems[i] = new sem_t; + if (sem_init(*sems[i], 0, 0) == -1) + throw SndException(errno); + } try { rx_src_data = new SRC_DATA; @@ -753,13 +744,12 @@ SoundPort::~SoundPort() { Close(); - sem_t** sems[] = { &sd[0].rwsem, &sd[0].csem, &sd[1].rwsem, &sd[1].csem }; - for (size_t i = 0; i < sizeof(sems)/sizeof(*sems); i++) - if (sem_close(*sems[i]) == -1) + sem_t* sems[] = { sd[0].rwsem, sd[0].csem, sd[1].rwsem, sd[1].csem }; + for (size_t i = 0; i < sizeof(sems)/sizeof(*sems); i++) { + if (sem_destroy(sems[i]) == -1) perror("sem_close"); - - delete sd[0].avg; - delete sd[1].avg; + delete sems[i]; + } delete [] fbuf; } diff --git a/src/soundcard/soundconf.cxx b/src/soundcard/soundconf.cxx index 14e672d0..7d4d5a2f 100644 --- a/src/soundcard/soundconf.cxx +++ b/src/soundcard/soundconf.cxx @@ -194,8 +194,8 @@ static void sound_init_options(void) const char* cname; for (int i = 0; (cname = src_get_name(i)); i++) { - if (strstr( cname, "ZOH") != 0) continue; - if (strstr( cname, "Linear") != 0) continue; + if (i == SRC_ZERO_ORDER_HOLD || i == SRC_LINEAR) + continue; menuSampleConverter->add(cname); } menuSampleConverter->value(progdefaults.sample_converter);