[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/gnash.h testsuite/Makefi...
From: |
Tomas Groth |
Subject: |
[Gnash-commit] gnash ChangeLog server/gnash.h testsuite/Makefi... |
Date: |
Tue, 20 Feb 2007 16:37:19 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Tomas Groth <tgc> 07/02/20 16:37:19
Modified files:
. : ChangeLog
server : gnash.h
testsuite : Makefile.am MovieTester.cpp MovieTester.h
testsuite/misc-ming.all: Makefile.am
Added files:
testsuite : sound_handler_test.cpp sound_handler_test.h
testsuite/media: sound1.mp3
testsuite/misc-ming.all: eventSoundTest1-Runner.cpp
eventSoundTest1.c
Log message:
* server/gnash.h: Added support for the new test-soundhandler.
* testsuite/sound_handler_test.{h,cpp}: Added. A soundhandler for
testing gnash.
* testsuite/Makefile.am: Added the new test-soundhandler.
* testsuite/MovieTester.{cpp,h}: Added support for the new
test-soundhandler.
*
testsuite/misc-ming.all/{eventSoundTest1.c,eventSoundTest1-Runner.cpp}:
Added. Tests simple event sounds.
* testsuite/misc-ming.all/Makefile.am: Added the eventSoundTest1
testcase and its runner.
* testsuite/media/sound1.mp3: Added. Used in the eventSoundTest1
testcase.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2408&r2=1.2409
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/Makefile.am?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/media/sound1.mp3?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/eventSoundTest1-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/eventSoundTest1.c?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2408
retrieving revision 1.2409
diff -u -b -r1.2408 -r1.2409
--- ChangeLog 20 Feb 2007 14:58:34 -0000 1.2408
+++ ChangeLog 20 Feb 2007 16:37:18 -0000 1.2409
@@ -1,3 +1,18 @@
+2007-02-20 Tomas Groth Christensen <address@hidden>
+
+ * server/gnash.h: Added support for the new test-soundhandler.
+ * testsuite/sound_handler_test.{h,cpp}: Added. A soundhandler for
+ testing gnash.
+ * testsuite/Makefile.am: Added the new test-soundhandler.
+ * testsuite/MovieTester.{cpp,h}: Added support for the new
+ test-soundhandler.
+ *
testsuite/misc-ming.all/{eventSoundTest1.c,eventSoundTest1-Runner.cpp}:
+ Added. Tests simple event sounds.
+ * testsuite/misc-ming.all/Makefile.am: Added the eventSoundTest1
+ testcase and its runner.
+ * testsuite/media/sound1.mp3: Added. Used in the eventSoundTest1
+ testcase.
+
2007-02-20 Sandro Santilli <address@hidden>
* testsuite/misc-ming.all/: DrawingApi.as => DrawingApiTest.as,
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- server/gnash.h 14 Feb 2007 20:41:48 -0000 1.84
+++ server/gnash.h 20 Feb 2007 16:37:19 -0000 1.85
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 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
@@ -17,7 +17,7 @@
//
//
-/* $Id: gnash.h,v 1.84 2007/02/14 20:41:48 tgc Exp $ */
+/* $Id: gnash.h,v 1.85 2007/02/20 16:37:19 tgc Exp $ */
/// \mainpage
///
@@ -158,7 +158,7 @@
DSOEXPORT sound_handler* create_sound_handler_sdl();
DSOEXPORT sound_handler* create_sound_handler_gst();
-
+DSOEXPORT sound_handler* create_sound_handler_test();
class font;
/// For caching precomputed stuff. Generally of
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/Makefile.am,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- testsuite/Makefile.am 12 Feb 2007 23:49:10 -0000 1.27
+++ testsuite/Makefile.am 20 Feb 2007 16:37:19 -0000 1.28
@@ -23,6 +23,8 @@
libtestsuite_la_SOURCES = \
MovieTester.h \
MovieTester.cpp \
+ sound_handler_test.h \
+ sound_handler_test.cpp \
$(NULL)
libtestsuite_la_LIBADD = \
$(top_builddir)/server/libgnashserver.la \
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- testsuite/MovieTester.cpp 9 Feb 2007 14:27:33 -0000 1.20
+++ testsuite/MovieTester.cpp 20 Feb 2007 16:37:19 -0000 1.21
@@ -65,6 +65,10 @@
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());
+
_movie_root = &(VM::init(*_movie_def).getRoot());
// Now complete load of the movie
@@ -188,4 +192,16 @@
}
+int
+MovieTester::soundsStarted()
+{
+ return _sound_handler.get()->test_times_started_all();
+}
+
+int
+MovieTester::soundsStopped()
+{
+ return _sound_handler.get()->test_times_stopped_all();
+}
+
} // namespace gnash
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- testsuite/MovieTester.h 8 Feb 2007 00:38:51 -0000 1.9
+++ testsuite/MovieTester.h 20 Feb 2007 16:37:19 -0000 1.10
@@ -22,6 +22,7 @@
#include "Range2d.h"
#include "gnash.h" // for namespace key
+#include "sound_handler_test.h"
#include <memory> // for auto_ptr
#include <string> // for auto_ptr
@@ -110,6 +111,12 @@
/// handles mouse events
bool isMouseOverMouseEntity();
+ /// Return the number of times a sound has been stopped.
+ int soundsStopped();
+
+ /// Return the number of times a sound has been started.
+ int soundsStarted();
+
private:
gnash::movie_root* _movie_root;
@@ -118,6 +125,7 @@
gnash::sprite_instance* _movie;
+ std::auto_ptr<TEST_sound_handler> _sound_handler;
};
} // namespace gnash
Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- testsuite/misc-ming.all/Makefile.am 20 Feb 2007 15:13:26 -0000 1.71
+++ testsuite/misc-ming.all/Makefile.am 20 Feb 2007 16:37:19 -0000 1.72
@@ -1,6 +1,6 @@
## Process this fill with automake to generate Makefile.in
#
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006, 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
@@ -87,6 +87,8 @@
loadMovieTest \
loadMovieTestRunner \
intervalTestRunner \
+ eventSoundTest1 \
+ eventSoundTest1-Runner \
DrawingApiTestRunner \
$(NULL)
@@ -106,6 +108,9 @@
# TESTS = \
# DefineEditTextVariableNameTest-Runner
+eventSoundTest1_SOURCES = eventSoundTest1.c
+eventSoundTest1_LDADD = $(MING_LIBS)
+
definebitsjpeg2_SOURCES = definebitsjpeg2.c
definebitsjpeg2_LDADD = $(MING_LIBS)
@@ -147,6 +152,23 @@
RemoveObject2Test_SOURCES = RemoveObject2Test.c
RemoveObject2Test_LDADD = $(MING_LIBS)
+eventSoundTest1.swf: eventSoundTest1
+ ./eventSoundTest1 $(srcdir)/../media/sound1.mp3
+
+eventSoundTest1_Runner_SOURCES = \
+ eventSoundTest1-Runner.cpp \
+ $(NULL)
+eventSoundTest1_Runner_CXXFLAGS = \
+ -DTGTDIR='"$(abs_builddir)"' \
+ $(NULL)
+eventSoundTest1_Runner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(NULL)
+eventSoundTest1_Runner_DEPENDENCIES = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ eventSoundTest1.swf \
+ $(NULL)
+
definebitsjpeg2.swf: definebitsjpeg2
./definebitsjpeg2 $(srcdir)/../media/lynch.jpg
@@ -627,6 +649,7 @@
KeyTest-Runner \
loadMovieTestRunner \
intervalTestRunner \
+ eventSoundTest1-Runner \
DrawingApiTestRunner \
$(NULL)
Index: testsuite/sound_handler_test.cpp
===================================================================
RCS file: testsuite/sound_handler_test.cpp
diff -N testsuite/sound_handler_test.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/sound_handler_test.cpp 20 Feb 2007 16:37:19 -0000 1.1
@@ -0,0 +1,396 @@
+// 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.1 2007/02/20 16:37:19 tgc Exp $
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sound_handler_test.h"
+
+#include "log.h"
+#include <pthread.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, 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->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--;
+ }
+ }
+ }
+
+}
+
+
+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;
+ }
+
+}
+
+void TEST_sound_handler::convert_raw_data(
+ int16_t** /*adjusted_data*/,
+ int* /*adjusted_size*/,
+ void* /*data*/,
+ int /*sample_count*/,
+ int /*sample_size*/,
+ int /*sample_rate*/,
+ bool /*stereo*/)
+{
+ gnash::log_msg("%s: unimplemented \n", __PRETTY_FUNCTION__);
+}
+
+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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/sound_handler_test.h 20 Feb 2007 16:37:19 -0000 1.1
@@ -0,0 +1,194 @@
+// 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.1 2007/02/20 16:37:19 tgc Exp $
+
+#ifndef SOUND_HANDLER_TEST_H
+#define SOUND_HANDLER_TEST_H
+
+#include "gnash.h"
+#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.
+ 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,
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
+
+ /// Converts input data to the SDL output format.
+ virtual void convert_raw_data(int16_t** adjusted_data,
+ int* adjusted_size, void* data, int sample_count,
+ int sample_size, int sample_rate, bool stereo);
//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
Index: testsuite/media/sound1.mp3
===================================================================
RCS file: testsuite/media/sound1.mp3
diff -N testsuite/media/sound1.mp3
Binary files /dev/null and /tmp/cvs89TNNX differ
Index: testsuite/misc-ming.all/eventSoundTest1-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/eventSoundTest1-Runner.cpp
diff -N testsuite/misc-ming.all/eventSoundTest1-Runner.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/eventSoundTest1-Runner.cpp 20 Feb 2007 16:37:19
-0000 1.1
@@ -0,0 +1,88 @@
+/*
+ * 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
+ *
+ *
+ */
+
+#define INPUT_FILENAME "event_sound_test1.swf"
+
+#include "MovieTester.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "container.h"
+#include "log.h"
+#include "GnashException.h"
+
+#include "check.h"
+
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <memory>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+ string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
+ auto_ptr<MovieTester> t;
+
+ try
+ {
+ t.reset(new MovieTester(filename));
+ }
+ catch (const GnashException& e)
+ {
+ std::cerr << "Error initializing MovieTester: " << e.what() <<
std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ MovieTester& tester = *t;
+
+ tester.advance();
+
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity(1);
+ dbglogfile.setActionDump(1);
+
+ sprite_instance* root = tester.getRootMovie();
+ assert(root);
+
+ check_equals(root->get_frame_count(), 20);
+
+ // Advance and check...
+ int frame = root->get_current_frame(); // 1
+ int sounds = 1;
+ while (frame < 21) {
+// check_equals(root->get_current_frame(), frame);
+ check_equals(tester.soundsStarted(), sounds);
+ tester.advance();
+ frame++;
+
+// check_equals(root->get_current_frame(), frame);
+ check_equals(tester.soundsStopped(), sounds);
+ tester.advance();
+ frame++;
+ sounds++;
+ }
+
+ check_equals(tester.soundsStopped(), tester.soundsStarted());
+
+}
+
Index: testsuite/misc-ming.all/eventSoundTest1.c
===================================================================
RCS file: testsuite/misc-ming.all/eventSoundTest1.c
diff -N testsuite/misc-ming.all/eventSoundTest1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/eventSoundTest1.c 20 Feb 2007 16:37:19 -0000
1.1
@@ -0,0 +1,81 @@
+/*
+ * 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
+ *
+ */
+
+/*
+ * Test for sounds being started and stopped
+ *
+ * The _root movie has 20 frames.
+ *
+ * In uneven frames a sound is started, and in even frames it is stopped.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "eventSoundTest1.swf"
+
+
+int
+main(int argc, char** argv)
+{
+ SWFMovie mo;
+ SWFSound so;
+ FILE *sound_f;
+ int i;
+ const char* sound_filename;
+
+ if ( argc>1 ) {
+ sound_filename=argv[1];
+ } else {
+ sound_filename="sound1.mp3";
+ }
+
+ sound_f = fopen(sound_filename, "r");
+ if ( ! sound_f ) {
+ perror(sound_filename);
+ return 1;
+ }
+
+ Ming_init();
+ Ming_useSWFVersion (OUTPUT_VERSION);
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension(mo, 100, 100);
+
+ SWFMovie_setRate(mo, 1);
+ so = newSWFSound(sound_f, SWF_SOUND_MP3_COMPRESSED | SWF_SOUND_44KHZ |
SWF_SOUND_16BITS |SWF_SOUND_STEREO);
+ for(i=0; i<20; i++)
+ {
+ SWFSoundInstance so_in = SWFMovie_startSound(mo, so);
+ SWFMovie_nextFrame(mo);
+ ++i;
+ SWFMovie_stopSound(mo, so);
+ SWFMovie_nextFrame(mo);
+ }
+
+ //Output movie
+ puts("Saving " OUTPUT_FILENAME );
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/gnash.h testsuite/Makefi...,
Tomas Groth <=