CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/12/01 21:54:24
Modified files: . : ChangeLog libmedia/sdl : sound_handler_sdl.cpp sound_handler_sdl.h Log message: drop dependency on hash_wrapper.h. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5045&r2=1.5046 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/sound_handler_sdl.h?cvsroot=gnash&r1=1.5&r2=1.6 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5045 retrieving revision 1.5046 diff -u -b -r1.5045 -r1.5046 --- ChangeLog 1 Dec 2007 21:07:19 -0000 1.5045 +++ ChangeLog 1 Dec 2007 21:54:24 -0000 1.5046 @@ -1,5 +1,10 @@ 2007-12-01 Sandro Santilli <[EMAIL PROTECTED]> + * libmedia/sdl/sound_handler_sdl.{cpp,h}: drop dependency on + hash_wrapper.h. + +2007-12-01 Sandro Santilli <[EMAIL PROTECTED]> + * libmedia/gst/sound_handler_gst.{cpp,h}: drop dependency on hash_wrapper.h * utilities/processor.cpp: add support for reading from stdin. Index: libmedia/sdl/sound_handler_sdl.cpp =================================================================== RCS file: /sources/gnash/gnash/libmedia/sdl/sound_handler_sdl.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- libmedia/sdl/sound_handler_sdl.cpp 24 Nov 2007 17:21:43 -0000 1.6 +++ libmedia/sdl/sound_handler_sdl.cpp 1 Dec 2007 21:54:24 -0000 1.7 @@ -20,7 +20,7 @@ // Based on sound_handler_sdl.cpp by Thatcher Ulrich http://tulrich.com 2003 // which has been donated to the Public Domain. -// $Id: sound_handler_sdl.cpp,v 1.6 2007/11/24 17:21:43 strk Exp $ +// $Id: sound_handler_sdl.cpp,v 1.7 2007/12/01 21:54:24 strk Exp $ #ifdef HAVE_CONFIG_H #include "config.h" @@ -42,6 +42,7 @@ #include "log.h" #include <cmath> #include <vector> +#include <boost/scoped_array.hpp> #include <SDL.h> namespace gnash { @@ -406,13 +407,11 @@ assert(owner); assert(ptr); - aux_streamer_ptr p; - if (m_aux_streamer.get(owner, &p)) + if ( ! m_aux_streamer.insert(std::make_pair(owner, ptr)).second ) { // Already in the hash. return; } - m_aux_streamer[owner] = ptr; ++soundsPlaying; @@ -430,13 +429,14 @@ void SDL_sound_handler::detach_aux_streamer(void* owner) { boost::mutex::scoped_lock lock(_mutex); - aux_streamer_ptr p; - if (m_aux_streamer.get(owner, &p)) + + CallbacksMap::iterator it2=m_aux_streamer.find(owner); + if ( it2 != m_aux_streamer.end() ) { + // WARNING: erasing would break any iteration in the map --soundsPlaying; - m_aux_streamer.erase(owner); + m_aux_streamer.erase(it2); } - } unsigned int SDL_sound_handler::get_duration(int sound_handle) @@ -649,34 +649,36 @@ memset(buffer, 0, buffer_length); // call NetStream or Sound audio callbacks - if (handler->m_aux_streamer.size() > 0) + if ( !handler->m_aux_streamer.empty() ) { - uint8_t* buf = new uint8_t[buffer_length]; + boost::scoped_array<uint8_t> buf ( new uint8_t[buffer_length] ); // Loop through the attached sounds - hash_wrapper< void*, sound_handler::aux_streamer_ptr >::iterator it = handler->m_aux_streamer.begin(); - hash_wrapper< void*, sound_handler::aux_streamer_ptr >::iterator end = handler->m_aux_streamer.end(); + CallbacksMap::iterator it = handler->m_aux_streamer.begin(); + CallbacksMap::iterator end = handler->m_aux_streamer.end(); while (it != end) { - memset(buf, 0, buffer_length); + memset(buf.get(), 0, buffer_length); - SDL_sound_handler::aux_streamer_ptr aux_streamer = it->second; //handler->m_aux_streamer[i]->ptr; + SDL_sound_handler::aux_streamer_ptr aux_streamer = it->second; void* owner = it->first; // If false is returned the sound doesn't want to be attached anymore - bool ret = (aux_streamer)(owner, buf, buffer_length); + bool ret = (aux_streamer)(owner, buf.get(), buffer_length); if (!ret) { - handler->m_aux_streamer.erase(it++); + CallbacksMap::iterator it2=it; + ++it2; // before we erase it + handler->m_aux_streamer.erase(it); // FIXME: isn't this terribly wrong ? + it = it2; handler->soundsPlaying--; } else { ++it; } - SDL_MixAudio(stream, buf, buffer_length, SDL_MIX_MAXVOLUME); + SDL_MixAudio(stream, buf.get(), buffer_length, SDL_MIX_MAXVOLUME); } - delete [] buf; } - // Run through all the sounds. + // Run through all the sounds. TODO: don't call .size() at every iteration ! for(uint32_t i=0; i < handler->m_sound_data.size(); i++) { sound_data* sounddata = handler->m_sound_data[i]; for(uint32_t j = 0; j < sounddata->m_active_sounds.size(); j++) { Index: libmedia/sdl/sound_handler_sdl.h =================================================================== RCS file: /sources/gnash/gnash/libmedia/sdl/sound_handler_sdl.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- libmedia/sdl/sound_handler_sdl.h 30 Nov 2007 00:13:02 -0000 1.5 +++ libmedia/sdl/sound_handler_sdl.h 1 Dec 2007 21:54:24 -0000 1.6 @@ -16,14 +16,13 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// $Id: sound_handler_sdl.h,v 1.5 2007/11/30 00:13:02 tgc Exp $ +// $Id: sound_handler_sdl.h,v 1.6 2007/12/01 21:54:24 strk Exp $ #ifndef SOUND_HANDLER_SDL_H #define SOUND_HANDLER_SDL_H #include "sound_handler.h" // for inheritance -#include "hash_wrapper.h" #include "AudioDecoder.h" #include "log.h" @@ -37,6 +36,7 @@ #endif #include <vector> +#include <map> // for composition #include <SDL_audio.h> #include <boost/thread/thread.hpp> @@ -285,7 +285,8 @@ { private: /// AS classes (NetStream, Sound) audio callbacks - hash_wrapper< void* /* owner */, aux_streamer_ptr /* callback */> m_aux_streamer; + typedef std::map< void* /* owner */, aux_streamer_ptr /* callback */> CallbacksMap; + CallbacksMap m_aux_streamer; /// Vector containing all sounds. // _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit