From: Erik Hofman Date: Fri, 27 May 2016 09:37:47 +0000 (+0200) Subject: Remove unused sample queue code X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0f51d28732d3adc58319cd4b5f9bb5ec2516c40a;p=simgear.git Remove unused sample queue code --- diff --git a/simgear/sound/CMakeLists.txt b/simgear/sound/CMakeLists.txt index a15c9110..c2538938 100644 --- a/simgear/sound/CMakeLists.txt +++ b/simgear/sound/CMakeLists.txt @@ -3,7 +3,6 @@ include (SimGearComponent) set(HEADERS sample_group.hxx sample_openal.hxx - sample_queue.hxx soundmgr_openal.hxx xmlsound.hxx readwav.hxx @@ -12,7 +11,6 @@ set(HEADERS set(SOURCES sample_group.cxx sample_openal.cxx - sample_queue.cxx soundmgr_openal.cxx xmlsound.cxx readwav.cxx @@ -42,5 +40,4 @@ endfunction() create_test(openal_test1) create_test(openal_test2) create_test(openal_test3) -create_test(openal_test4) endif() diff --git a/simgear/sound/openal_test4.cxx b/simgear/sound/openal_test4.cxx deleted file mode 100644 index eaf2bcab..00000000 --- a/simgear/sound/openal_test4.cxx +++ /dev/null @@ -1,75 +0,0 @@ -#include -#ifdef _WIN32 -#include -#define sleep(x) Sleep(x*1000) -#else -#include -#endif - -#include -#include - -#include "soundmgr_openal.hxx" -#include "sample_group.hxx" -#include "sample_openal.hxx" - -int main( int argc, char *argv[] ) { - SGSampleQueue *squeue; - SGSampleGroup *sgr; - SGSoundMgr *smgr; - SGGeod pos; - - smgr = new SGSoundMgr; - - smgr->bind(); - smgr->select_device("OSS Default"); - smgr->init(); - sgr = smgr->find("default", true); - smgr->set_volume(0.9); - smgr->activate(); - smgr->set_position( SGVec3d::fromGeod(SGGeod()), SGGeod() ); - - void *data; - size_t len; - int freq, fmt; - std::string file = SRC_DIR"/jet.wav"; - smgr->load(file, &data, &fmt, &len, &freq); - - squeue = new SGSampleQueue( freq, fmt ); - squeue->set_volume(1.0); - - sgr->add(squeue, "queue"); - - squeue->add( data, len ); - squeue->add( data, len ); - squeue->play(); - printf("playing queue\n"); - - smgr->update(1.0); - sleep(10); - smgr->update(10.0); - - printf("source at lat,lon = (10,-10), listener at (9.99,-9.99)\n"); - pos = SGGeod::fromDeg(9.99,-9.99); - sgr->set_position_geod( SGGeod::fromDeg(10,-10) ); - smgr->set_position( SGVec3d::fromGeod(pos), pos ); - - squeue->add( data, len ); - squeue->add( data, len ); - squeue->play( true ); // play looped - printf("playing queue\n"); - - smgr->update(1.0); - sleep(10); - smgr->update(10.0); - - squeue->stop(); - smgr->update(1.0); - sleep(1); - - sgr->remove("queue"); - smgr->unbind(); - sleep(2); - - delete smgr; -} diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index f87cb1dc..4d307dd9 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -37,7 +37,6 @@ #include #include "sample_openal.hxx" -#include "sample_queue.hxx" typedef std::map < std::string, SGSharedPtr > sample_map; diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index 34a54064..286379fa 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -30,6 +30,7 @@ #ifndef _SG_SAMPLE_HXX #define _SG_SAMPLE_HXX 1 +#include #include enum { diff --git a/simgear/sound/sample_queue.cxx b/simgear/sound/sample_queue.cxx deleted file mode 100644 index 30e1c550..00000000 --- a/simgear/sound/sample_queue.cxx +++ /dev/null @@ -1,126 +0,0 @@ - -// queue.cxx -- Audio sample encapsulation class -// -// Written by Curtis Olson, started April 2004. -// Modified to match the new SoundSystem by Erik Hofman, October 2009 -// -// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt -// Copyright (C) 2009 Erik Hofman -// -// 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. -// -// $Id$ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include // rand() -#include - -#include -#include -#include - -#include "soundmgr_openal.hxx" -#include "sample_queue.hxx" -#include "soundmgr_openal_private.hxx" - -using std::string; - -// -// SGSampleQueue -// - -// empty constructor -SGSampleQueue::SGSampleQueue( int freq, int format ) : - _refname(random_string()), - _playing(false) -{ - set_frequency( freq ); - set_format_AL( format ); - _buffers.clear(); -} - -SGSampleQueue::~SGSampleQueue() { - stop(); -} - -void SGSampleQueue::stop() -{ -#ifdef ENABLE_SOUND - ALint num; - alGetSourcei(_source, AL_BUFFERS_PROCESSED, &num); - for (int i=0; i 1) { - alSourceUnqueueBuffers(_source, 1, &buffer); - } else { - alGenBuffers(1, &buffer); - } - alBufferData(buffer, get_format_AL(), data, len, get_frequency()); - } - else - { - alGenBuffers(1, &buffer); - alBufferData(buffer, get_format_AL(), data, len, get_frequency()); - _buffers.push_back(buffer); - } -#endif -} - -void SGSampleQueue::set_source( unsigned int sid ) -{ - SGSoundSample::set_source(sid); -#ifdef ENABLE_SOUND - ALuint num = _buffers.size(); - for (unsigned int i=0; i < num; i++) - { - ALuint buffer = _buffers[i]; - alSourceQueueBuffers(_source, 1, &buffer); - } - _buffers.clear(); -#endif -} - -string SGSampleQueue::random_string() { - static const char *r = "0123456789abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - string rstr = "Queued sample: "; - for (int i=0; i<10; i++) { - rstr.push_back( r[rand() % strlen(r)] ); - } - - return rstr; -} diff --git a/simgear/sound/sample_queue.hxx b/simgear/sound/sample_queue.hxx deleted file mode 100644 index 20de3a87..00000000 --- a/simgear/sound/sample_queue.hxx +++ /dev/null @@ -1,96 +0,0 @@ -///@file -/// Provides a sample queue encapsulation -// -// based on sample.hxx -// -// Copyright (C) 2010 Erik Hofman -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - -#ifndef _SG_QUEUE_HXX -#define _SG_QUEUE_HXX 1 - -#include -#include - -#include -#include -#include - -#include "sample_openal.hxx" - -/** - * manages everything we need to know for an individual audio sample - */ - -class SGSampleQueue : public SGSoundSample { -public: - - - /** - * Empty constructor, can be used to read data to the systems - * memory and not to the driver. - * @param freq sample frequentie of the samples - * @param format OpenAL format id of the data - */ - SGSampleQueue(int freq, int format = SG_SAMPLE_MONO8); - - /** - * Destructor - */ - ~SGSampleQueue (); - - /** - * Schedule this audio sample to stop playing. - */ - virtual void stop(); - - /** - * Queue new data for this audio sample. - * - * @param data Pointer to a memory block containg this audio sample data. - * @param len Length of the sample buffer in bytes. - */ - void add( const void* data, size_t len ); - - /** - * Set the source id of this source. - * - * @param sid OpenAL source-id - */ - virtual void set_source(unsigned int sid); - - /** - * Test if the buffer-id of this audio sample may be passed to OpenAL. - * - * @return false for sample queue - */ - inline bool is_valid_buffer() const { return false; } - - inline virtual bool is_queue() const { return true; } - -private: - std::string _refname; // sample name - std::vector _buffers; - - bool _playing; - - std::string random_string(); -}; - - -#endif // _SG_QUEUE_HXX - -