[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend... |
Date: |
Tue, 29 May 2007 17:15:15 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/29 17:15:14
Modified files:
. : ChangeLog
backend : sound_handler.h sound_handler_gst.cpp
sound_handler_sdl.cpp
testsuite : FuzzyPixel.h Makefile.am MovieTester.cpp
MovieTester.h
Removed files:
testsuite : sound_handler_test.cpp sound_handler_test.h
Log message:
* backend/sound_handler.h: add numSoundsStarted() and
numSoundsStopped() methods to be used in testing, and
associated protected counts.
* backend/: sound_handler_gst.cpp, sound_handler_sdl.cpp:
Increment started/stopped sound counters.
* testsuite/FuzzyPixel.h: remove unused header.
* testsuite/: Makefile.am, sound_handler_test.{cpp,h}:
drop sound_handler_test, testing will now be done against
the built sound_handler.
* testsuite/MovieTester.{cpp,h}: initialize the currently
configured sound handler and use that for testing.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3394&r2=1.3395
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.cpp?cvsroot=gnash&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/FuzzyPixel.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/Makefile.am?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.cpp?cvsroot=gnash&r1=1.9&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.h?cvsroot=gnash&r1=1.6&r2=0
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3394
retrieving revision 1.3395
diff -u -b -r1.3394 -r1.3395
--- ChangeLog 29 May 2007 14:49:08 -0000 1.3394
+++ ChangeLog 29 May 2007 17:15:13 -0000 1.3395
@@ -1,5 +1,19 @@
2007-05-29 Sandro Santilli <address@hidden>
+ * backend/sound_handler.h: add numSoundsStarted() and
+ numSoundsStopped() methods to be used in testing, and
+ associated protected counts.
+ * backend/: sound_handler_gst.cpp, sound_handler_sdl.cpp:
+ Increment started/stopped sound counters.
+ * testsuite/FuzzyPixel.h: remove unused header.
+ * testsuite/: Makefile.am, sound_handler_test.{cpp,h}:
+ drop sound_handler_test, testing will now be done against
+ the built sound_handler.
+ * testsuite/MovieTester.{cpp,h}: initialize the currently
+ configured sound handler and use that for testing.
+
+2007-05-29 Sandro Santilli <address@hidden>
+
* server/asobj/NetStreamFfmpeg.{cpp,h}: drop
the decode_wait_mutex, use decoding_mutex instead.
Document which function lock it and which not, adding
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- backend/sound_handler.h 29 May 2007 11:14:55 -0000 1.14
+++ backend/sound_handler.h 29 May 2007 17:15:13 -0000 1.15
@@ -18,7 +18,7 @@
//
//
-/* $Id: sound_handler.h,v 1.14 2007/05/29 11:14:55 strk Exp $ */
+/* $Id: sound_handler.h,v 1.15 2007/05/29 17:15:13 strk Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -274,7 +274,27 @@
int sample_size, int sample_rate, bool stereo,
int m_sample_rate, bool m_stereo);
+ sound_handler()
+ :
+ _soundsStarted(0),
+ _soundsStopped(0)
+ {}
+
virtual ~sound_handler() {};
+
+ /// Special test-fuction. Reports how many times a sound has been
started
+ size_t numSoundsStarted() const { return _soundsStarted; }
+
+ /// Special test-fuction. Reports how many times a sound has been
stopped
+ size_t numSoundsStopped() const { return _soundsStopped; }
+
+protected:
+
+ /// Special test-member. Stores count of started sounds.
+ size_t _soundsStarted;
+
+ /// Special test-member. Stores count of stopped sounds.
+ size_t _soundsStopped;
};
// TODO: move to appropriate specific sound handlers
Index: backend/sound_handler_gst.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- backend/sound_handler_gst.cpp 24 May 2007 13:48:43 -0000 1.46
+++ backend/sound_handler_gst.cpp 29 May 2007 17:15:14 -0000 1.47
@@ -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_gst.cpp,v 1.46 2007/05/24 13:48:43 strk Exp $ */
+/* $Id: sound_handler_gst.cpp,v 1.47 2007/05/29 17:15:14 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -439,6 +439,8 @@
// If not already playing, start doing it
gst_element_set_state (GST_ELEMENT (gst_element->pipeline),
GST_STATE_PLAYING);
+ ++_soundsStarted;
+
}
@@ -476,6 +478,7 @@
sounddata->m_gst_elements.erase(sounddata->m_gst_elements.begin() + i);
}
+ ++_soundsStopped;
}
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- backend/sound_handler_sdl.cpp 28 May 2007 15:40:57 -0000 1.66
+++ backend/sound_handler_sdl.cpp 29 May 2007 17:15:14 -0000 1.67
@@ -18,7 +18,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.66 2007/05/28 15:40:57 ann Exp $
+// $Id: sound_handler_sdl.cpp,v 1.67 2007/05/29 17:15:14 strk Exp $
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -326,6 +326,7 @@
}
++soundsPlaying;
+ ++_soundsStarted;
sounddata->m_active_sounds.push_back(sound);
if (soundsPlaying == 1) {
@@ -363,13 +364,13 @@
#endif
sound->delete_raw_data();
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
// Stop sound, remove it from the active list
(adpcm/native16)
} else {
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
}
+ --soundsPlaying;
+ ++_soundsStopped;
}
}
Index: testsuite/FuzzyPixel.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/FuzzyPixel.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/FuzzyPixel.h 28 May 2007 15:41:10 -0000 1.4
+++ testsuite/FuzzyPixel.h 29 May 2007 17:15:14 -0000 1.5
@@ -23,7 +23,6 @@
#include "Range2d.h"
#include "gnash.h" // for namespace key
-#include "sound_handler_test.h" // for creating the "test" sound handler
#include "types.h" // for rgba class
#include <iostream>
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/Makefile.am,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- testsuite/Makefile.am 18 May 2007 10:14:11 -0000 1.38
+++ testsuite/Makefile.am 29 May 2007 17:15:14 -0000 1.39
@@ -28,8 +28,6 @@
MovieTester.cpp \
FuzzyPixel.cpp \
FuzzyPixel.h \
- sound_handler_test.h \
- sound_handler_test.cpp \
$(NULL)
libtestsuite_la_LIBADD = \
$(top_builddir)/backend/libgnashbackend.la \
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- testsuite/MovieTester.cpp 28 May 2007 15:41:10 -0000 1.36
+++ testsuite/MovieTester.cpp 29 May 2007 17:15:14 -0000 1.37
@@ -29,7 +29,7 @@
#include "as_environment.h"
#include "gnash.h" // for create_movie and create_library_movie and for
gnash::key namespace
#include "VM.h" // for initialization
-#include "sound_handler_test.h" // for creating the "test" sound handler
+#include "sound_handler.h" // for creating the "test" sound handlers
#include "render.h" // for get_render_handler
#include "types.h" // for rgba class
#include "FuzzyPixel.h"
@@ -75,9 +75,8 @@
throw GnashException("Could not load movie from "+url);
}
- // Create a soundhandler
- _sound_handler.reset(
static_cast<TEST_sound_handler*>(gnash::create_sound_handler_test()));
- gnash::set_sound_handler(_sound_handler.get());
+ // Initialize the sound handler(s)
+ initTestingSoundHandlers();
_movie_root = &(VM::init(*_movie_def).getRoot());
@@ -343,13 +342,13 @@
int
MovieTester::soundsStarted()
{
- return _sound_handler.get()->test_times_started_all();
+ return _sound_handler->numSoundsStarted();
}
int
MovieTester::soundsStopped()
{
- return _sound_handler.get()->test_times_stopped_all();
+ return _sound_handler->numSoundsStopped();
}
void
@@ -421,4 +420,21 @@
_testingRenderers.push_back(TestingRendererPtr(new TestingRenderer(h,
name)));
}
+void
+MovieTester::initTestingSoundHandlers()
+{
+#ifdef SOUND_SDL
+ cout << "Creating SDL sound handler" << endl;
+ _sound_handler.reset( gnash::create_sound_handler_sdl() );
+#elif defined(SOUND_GST)
+ cout << "Creating GST sound handler" << endl;
+ _sound_handler.reset( gnash::create_sound_handler_gst() );
+#else
+ cerr << "Neigher SOUND_SDL nor SOUND_GST defined" << endl;
+ exit(1);
+#endif
+
+ gnash::set_sound_handler(_sound_handler.get());
+}
+
} // namespace gnash
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- testsuite/MovieTester.h 28 May 2007 15:41:10 -0000 1.21
+++ testsuite/MovieTester.h 29 May 2007 17:15:14 -0000 1.22
@@ -23,7 +23,7 @@
#include "Range2d.h"
#include "gnash.h" // for namespace key
-#include "sound_handler_test.h" // for creating the "test" sound handler
+#include "sound_handler.h" // for creating the "test" sound handlers
#include "types.h" // for rgba class
#include "render_handler.h" // for dtor visibility by auto_ptr
@@ -216,6 +216,14 @@
/// Initialize testing renderers
void initTestingRenderers();
+ /// Initialize sound handlers
+ //
+ /// For now this function initializes a single sound handler,
+ /// the one enabled at configure time.
+ /// In the future it might initialize multiple ones (maybe)
+ ///
+ void initTestingSoundHandlers();
+
/// Render the current movie to all testing renderers
//
/// This function calls movie_root::display internally
@@ -242,7 +250,7 @@
gnash::sprite_instance* _movie;
- std::auto_ptr<TEST_sound_handler> _sound_handler;
+ std::auto_ptr<sound_handler> _sound_handler;
/// Current pointer position - X ordinate
int _x;
Index: testsuite/sound_handler_test.cpp
===================================================================
RCS file: testsuite/sound_handler_test.cpp
diff -N testsuite/sound_handler_test.cpp
--- testsuite/sound_handler_test.cpp 28 May 2007 15:41:10 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,388 +0,0 @@
-// Copyright (C) 2007 Free Software Foundation, Inc.
-//
-// 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 St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-// $Id: sound_handler_test.cpp,v 1.9 2007/05/28 15:41:10 ann Exp $
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "sound_handler_test.h"
-
-#include "log.h"
-#include <cmath>
-#include <vector>
-
-using namespace boost;
-
-TEST_sound_handler::TEST_sound_handler()
- : soundsPlaying(0),
- muted(false),
- started_all(0),
- stopped_all(0)
-{
-
-}
-
-TEST_sound_handler::~TEST_sound_handler()
-{
- for (size_t i=0, e=m_sound_data.size(); i < e; ++i)
- {
- stop_sound(i);
- delete_sound(i);
- }
-}
-
-
-int TEST_sound_handler::create_sound(
- void* data,
- int data_bytes,
- int sample_count,
- format_type format,
- int sample_rate,
- bool stereo)
-// Called to create a sample. We'll return a sample ID that
-// can be use for playing it.
-{
-
- sound_data *sounddata = new sound_data;
- if (!sounddata) {
- gnash::log_error("could not allocate memory for sounddata !\n");
- return -1;
- }
-
- sounddata->format = format;
- sounddata->data_size = data_bytes;
- sounddata->stereo = stereo;
- sounddata->sample_count = sample_count;
- sounddata->sample_rate = sample_rate;
- sounddata->volume = 100;
- sounddata->started = 0;
- sounddata->stopped = 0;
-
- mutex::scoped_lock lock(_mutex);
-
- sounddata->data = new uint8_t[data_bytes];
- if (!sounddata->data) {
- gnash::log_error("could not allocate space for data in
soundhandler\n");
- return -1;
- }
- memcpy(sounddata->data, data, data_bytes);
-
- m_sound_data.push_back(sounddata);
- int sound_id = m_sound_data.size()-1;
-
- return sound_id;
-
-}
-
-// this gets called when a stream gets more data
-long TEST_sound_handler::fill_stream_data(void* data, int data_bytes, int
/*sample_count*/, int handle_id)
-{
-
- mutex::scoped_lock lock(_mutex);
- // @@ does a negative handle_id have any meaning ?
- // should we change it to unsigned instead ?
- if (handle_id < 0 || (unsigned int) handle_id+1 > m_sound_data.size()) {
- return 1;
- }
- int start_size = 0;
- sound_data* sounddata = m_sound_data[handle_id];
-
- // Reallocate the required memory.
- uint8_t* tmp_data = new uint8_t[data_bytes + sounddata->data_size];
- memcpy(tmp_data, sounddata->data, sounddata->data_size);
- memcpy(tmp_data + sounddata->data_size, data, data_bytes);
- if (sounddata->data_size > 0) delete [] sounddata->data;
- sounddata->data = tmp_data;
-
- start_size = sounddata->data_size;
- sounddata->data_size += data_bytes;
- std::vector<active_sound*> asounds = sounddata->m_active_sounds;
-
- // If playback has already started, we also update the active sounds
- for(uint32_t i=0; i < asounds.size(); i++) {
- active_sound* sound = asounds[i];
- sound->set_data(sounddata->data);
- sound->data_size = sounddata->data_size;
- }
-
- return start_size;
-}
-
-
-void TEST_sound_handler::play_sound(int sound_handle, int loop_count, int
offset, long start_position, const std::vector<sound_envelope>* envelopes)
-// Play the index'd sample.
-{
- mutex::scoped_lock lock(_mutex);
-
- // Check if the sound exists, or if audio is muted
- if (sound_handle < 0 || static_cast<unsigned int>(sound_handle) >=
m_sound_data.size() || muted)
- {
- // Invalid handle or muted
- return;
- }
-
- sound_data* sounddata = m_sound_data[sound_handle];
-
- // If this is called from a streamsoundblocktag, we only start if this
- // sound isn't already playing. If a active_sound-struct is existing we
- // assume it is also playing.
- if (start_position > 0 && sounddata->m_active_sounds.size() > 0) {
- return;
- }
-
- // Make a "active_sound" for this sound which is later placed on the
vector of instances of this sound being played
- active_sound* sound = new active_sound;
-
- // Copy data-info to the active_sound
- sound->data_size = sounddata->data_size;
- sound->set_data(sounddata->data);
-
- // Set the given options of the sound
- if (start_position < 0) sound->position = 0;
- else sound->position = start_position;
-
- if (offset < 0) sound->offset = 0;
- else sound->offset = (sounddata->stereo ? offset : offset*2); // offset
is stored as stereo
-
- sound->envelopes = envelopes;
- sound->current_env = 0;
- sound->samples_played = 0;
-
- // Set number of loop we should do. -1 is infinte loop, 0 plays it
once, 1 twice etc.
- sound->loop_count = loop_count;
-
- ++soundsPlaying;
- sounddata->started++;
- started_all++;
- sounddata->m_active_sounds.push_back(sound);
-
-}
-
-
-void TEST_sound_handler::stop_sound(int sound_handle)
-{
- mutex::scoped_lock lock(_mutex);
-
- // Check if the sound exists.
- if (sound_handle < 0 || (unsigned int) sound_handle >=
m_sound_data.size())
- {
- // Invalid handle.
- } else {
-
- sound_data* sounddata = m_sound_data[sound_handle];
-
- for (int32_t i = (int32_t) sounddata->m_active_sounds.size()-1;
i >-1; i--) {
-
- // Stop sound, remove it from the active list (mp3)
- if (sounddata->format == 2) {
-
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
-
- // Stop sound, remove it from the active list
(adpcm/native16)
- } else {
-
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
- }
- }
- sounddata->stopped++;
- stopped_all++;
-
- }
-
-}
-
-
-void TEST_sound_handler::delete_sound(int sound_handle)
-// this gets called when it's done with a sample.
-{
- mutex::scoped_lock lock(_mutex);
-
- if (sound_handle >= 0 && static_cast<unsigned int>(sound_handle) <
m_sound_data.size())
- {
- delete[] m_sound_data[sound_handle]->data;
- }
-
-}
-
-// This will stop all sounds playing. Will cause problems if the soundhandler
is made static
-// and supplys sound_handling for many SWF's, since it will stop all sounds
with no regard
-// for what sounds is associated with what SWF.
-void TEST_sound_handler::stop_all_sounds()
-{
- mutex::scoped_lock lock(_mutex);
-
- int32_t num_sounds = (int32_t) m_sound_data.size()-1;
- for (int32_t j = num_sounds; j > -1; j--) {//Optimized
- sound_data* sounddata = m_sound_data[j];
- int32_t num_active_sounds = (int32_t)
sounddata->m_active_sounds.size()-1;
- for (int32_t i = num_active_sounds; i > -1; i--) {
-
- // Stop sound, remove it from the active list (mp3)
- if (sounddata->format == 2) {
-
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
-
- // Stop sound, remove it from the active list
(adpcm/native16)
- } else {
-
sounddata->m_active_sounds.erase(sounddata->m_active_sounds.begin() + i);
- soundsPlaying--;
- }
- }
- }
-}
-
-
-// returns the sound volume level as an integer from 0 to 100,
-// where 0 is off and 100 is full volume. The default setting is 100.
-int TEST_sound_handler::get_volume(int sound_handle) {
-
- mutex::scoped_lock lock(_mutex);
-
- int ret;
- // Check if the sound exists.
- if (sound_handle >= 0 && static_cast<unsigned int>(sound_handle) <
m_sound_data.size())
- {
- ret = m_sound_data[sound_handle]->volume;
- } else {
- ret = 0; // Invalid handle
- }
- return ret;
-}
-
-
-// A number from 0 to 100 representing a volume level.
-// 100 is full volume and 0 is no volume. The default setting is 100.
-void TEST_sound_handler::set_volume(int sound_handle, int volume) {
-
- mutex::scoped_lock lock(_mutex);
-
- // Check if the sound exists.
- if (sound_handle < 0 || static_cast<unsigned int>(sound_handle) >=
m_sound_data.size())
- {
- // Invalid handle.
- } else {
-
- // Set volume for this sound. Should this only apply to the
active sounds?
- m_sound_data[sound_handle]->volume = volume;
- }
-
-
-}
-
-void TEST_sound_handler::get_info(int sound_handle, int* format, bool* stereo)
{
-
- mutex::scoped_lock lock(_mutex);
-
- // Check if the sound exists.
- if (sound_handle >= 0 && static_cast<unsigned int>(sound_handle) <
m_sound_data.size())
- {
- *format = m_sound_data[sound_handle]->format;
- *stereo = m_sound_data[sound_handle]->stereo;
- }
-
-}
-
-// gnash calls this to mute audio
-void TEST_sound_handler::mute() {
- stop_all_sounds();
- muted = true;
-}
-
-// gnash calls this to unmute audio
-void TEST_sound_handler::unmute() {
- muted = false;
-}
-
-bool TEST_sound_handler::is_muted()
-{
- return muted;
-}
-
-void TEST_sound_handler::attach_aux_streamer(aux_streamer_ptr ptr, void*
owner)
-{
- assert(owner);
- assert(ptr);
-
- aux_streamer_ptr p;
- if (m_aux_streamer.get(owner, &p))
- {
- // Already in the hash.
- return;
- }
- m_aux_streamer[owner] = ptr;
-
- soundsPlaying++;
-}
-
-void TEST_sound_handler::detach_aux_streamer(void* owner)
-{
- soundsPlaying--;
- m_aux_streamer.erase(owner);
-}
-
-int TEST_sound_handler::test_times_stopped_all() {
- return stopped_all;
-}
-
-int TEST_sound_handler::test_times_started_all() {
- return started_all;
-}
-
-int TEST_sound_handler::test_times_stopped(int sound_handle) {
- // Check if the sound exists.
- if (sound_handle < 0 || static_cast<unsigned int>(sound_handle) >=
m_sound_data.size())
- {
- // Invalid handle.
- return -1;
- } else {
-
- // Set volume for this sound. Should this only apply to the
active sounds?
- return m_sound_data[sound_handle]->stopped;
- }
-
-}
-
-int TEST_sound_handler::test_times_started(int sound_handle) {
- // Check if the sound exists.
- if (sound_handle < 0 || static_cast<unsigned int>(sound_handle) >=
m_sound_data.size())
- {
- // Invalid handle.
- return -1;
- } else {
-
- // Set volume for this sound. Should this only apply to the
active sounds?
- return m_sound_data[sound_handle]->started;
- }
-
-}
-
-gnash::sound_handler* gnash::create_sound_handler_test()
-// Factory.
-{
- return new TEST_sound_handler;
-}
-
-void active_sound::set_data(uint8_t* idata) {
- data = idata;
-}
-
-// Local Variables:
-// mode: C++
-// End:
-
Index: testsuite/sound_handler_test.h
===================================================================
RCS file: testsuite/sound_handler_test.h
diff -N testsuite/sound_handler_test.h
--- testsuite/sound_handler_test.h 28 May 2007 15:41:10 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-// Copyright (C) 2007 Free Software Foundation, Inc.
-//
-// 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 St, Fifth Floor, Boston, MA 02110-1301 USA
-
-// $Id: sound_handler_test.h,v 1.6 2007/05/28 15:41:10 ann Exp $
-
-#ifndef SOUND_HANDLER_TEST_H
-#define SOUND_HANDLER_TEST_H
-
-#include "gnash.h" // still needed ?
-#include "sound_handler.h" // for inheritance
-#include "hash_wrapper.h"
-
-#include <vector>
-
-#include <boost/thread/thread.hpp>
-#include <boost/bind.hpp>
-#include <boost/thread/mutex.hpp>
-
-/// Used to hold the info about active sounds
-class active_sound
-{
-public:
-
- /// The size of the undecoded data
- unsigned long data_size;
-
- /// Current decoding position in the stream
- unsigned long position;
-
- /// Numbers of loops: -1 means loop forever, 0 means play once.
- /// For every loop completed, it is decremented.
- long loop_count;
-
- /// Offset to make playback start in-sync, only used with mp3 streams.
- unsigned int offset;
-
- /// Sound envelopes for the current sound, which determine the volume
level
- /// from a given position. Only used with sound events.
- const std::vector<gnash::sound_handler::sound_envelope>* envelopes;
-
- /// Index of current envelope.
- uint32_t current_env;
-
- /// Number of samples played so far.
- unsigned long samples_played;
-
- /// Set the undecoded data pointer
- void set_data(uint8_t*);
-
-private:
- /// The undecoded data
- uint8_t* data;
-
-};
-
-
-/// Used to hold the sounddata when doing on-demand-decoding
-class sound_data
-{
-public:
- /// The undecoded data
- uint8_t* data;
-
- /// Format of the sound (MP3, raw, etc).
- int format;
-
- /// The size of the undecoded data
- long data_size;
-
- /// Stereo or not
- bool stereo;
-
- /// Number of samples
- int sample_count;
-
- /// Sample rate
- int sample_rate;
-
- /// Volume for AS-sounds, range: 0-100.
- /// It's the SWF range that is represented here.
- int volume;
-
- /// Vector containing the active instances of this sounds being played
- std::vector<active_sound*> m_active_sounds;
-
- /// Test information
- int started;
- int stopped;
-
-};
-
-
-// Handle sounds for test purposes
-class TEST_sound_handler : public gnash::sound_handler
-{
-public:
- /// NetStream audio callbacks
- hash_wrapper< void* /* owner */, aux_streamer_ptr /* callback */>
m_aux_streamer; //vv
-
- /// Vector containing all sounds.
- std::vector<sound_data*> m_sound_data;
-
- /// Keeps track of numbers of playing sounds
- int soundsPlaying;
-
- /// Is the audio muted?
- bool muted;
-
- /// Mutex for making sure threads doesn't mess things up
- boost::mutex _mutex;
-
- /// Test information
- int started_all;
- int stopped_all;
-
- TEST_sound_handler();
- virtual ~TEST_sound_handler();
-
- /// Called to create a sound.
- virtual int create_sound(void* data, int data_bytes,
- int sample_count, format_type format,
- int sample_rate, bool stereo);
-
- /// this gets called when a stream gets more data
- virtual long fill_stream_data(void* data, int data_bytes,
- int sample_count, int handle_id);
-
- /// Play the index'd sample.
- virtual void play_sound(int sound_handle, int loop_count, int offset,
- long start_position, const
std::vector<sound_envelope>* envelopes);
-
- /// Stop the index'd sample.
- virtual void stop_sound(int sound_handle);
-
- /// This gets called when it's done with a sample.
- virtual void delete_sound(int sound_handle);
-
- /// This will stop all sounds playing.
- virtual void stop_all_sounds();
-
- /// Returns the sound volume level as an integer from 0 to 100.
AS-script only.
- virtual int get_volume(int sound_handle);
-
- /// Sets the sound volume level as an integer from 0 to 100. AS-script
only.
- virtual void set_volume(int sound_handle, int volume);
-
- /// Gnash uses this to get info about a sound. Used when a stream needs
more data.
- virtual void get_info(int sound_handle, int* format, bool* stereo);
-
- /// Gnash calls this to mute audio.
- virtual void mute();
-
- /// Gnash calls this to unmute audio.
- virtual void unmute();
-
- /// Gnash calls this to get the mute state.
- virtual bool is_muted();
-
- virtual void attach_aux_streamer(aux_streamer_ptr ptr, void* owner);
//vv
- virtual void detach_aux_streamer(void* owner); //vv
-
- /// Special test-fuction. Reports how many times this sound has been
started
- int test_times_started(int sound_handle);
-
- /// Special test-fuction. Reports how many times this sound has been
stopped
- int test_times_stopped(int sound_handle);
-
- /// Special test-fuction. Reports how many times a sound has been
started
- int test_times_started_all();
-
- /// Special test-fuction. Reports how many times a sound has been
stopped
- int test_times_stopped_all();
-
-};
-
-
-#endif // SOUND_HANDLER_TEST_H