[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ... |
Date: |
Thu, 03 Aug 2006 19:16:38 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/08/03 19:16:38
Modified files:
. : ChangeLog
server : gnash.h impl.cpp movie_def_impl.cpp
movie_def_impl.h sound.cpp sound.h
server/swf : tag_loaders.cpp tag_loaders.h
Log message:
* server/gnash.h, server/impl.cpp, server/movie_def_impl.cpp,
server/movie_def_impl.h, server/sound.cpp, server/sound.h,
server/swf/tag_loaders.cpp, server/swf/tag_loaders.h:
Moved sound tag loaders to tag_loaders, moved s_sound_handler
instance to globals namespace, made adpcm_expand a static
method of sound_handler class.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.577&r2=1.578
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sound.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sound.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.h?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.577
retrieving revision 1.578
diff -u -b -r1.577 -r1.578
--- ChangeLog 3 Aug 2006 18:58:53 -0000 1.577
+++ ChangeLog 3 Aug 2006 19:16:37 -0000 1.578
@@ -1,5 +1,14 @@
2006-08-03 Sandro Santilli <address@hidden>
+ * server/gnash.h, server/impl.cpp, server/movie_def_impl.cpp,
+ server/movie_def_impl.h, server/sound.cpp, server/sound.h,
+ server/swf/tag_loaders.cpp, server/swf/tag_loaders.h:
+ Moved sound tag loaders to tag_loaders, moved s_sound_handler
+ instance to globals namespace, made adpcm_expand a static
+ method of sound_handler class.
+
+2006-08-03 Sandro Santilli <address@hidden>
+
* libbase/rc.cpp: initialize RcInitFile::_delay to 0 (undefined).
* server/as_environment.cpp, server/swf/ASHandlers.cpp:
removed superflous newlines at end of debug messages.
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/gnash.h 26 Jul 2006 21:49:06 -0000 1.35
+++ server/gnash.h 3 Aug 2006 19:16:37 -0000 1.36
@@ -438,6 +438,15 @@
virtual void delete_sound(int sound_handle) = 0;
virtual ~sound_handler() {};
+
+ // Utility function to uncompress ADPCM.
+ static void adpcm_expand(
+ void* data_out,
+ stream* in,
+ int sample_count, // in stereo, this is number of *pairs*
of samples
+ bool stereo);
+
+
};
Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/impl.cpp 24 Jul 2006 13:30:51 -0000 1.47
+++ server/impl.cpp 3 Aug 2006 19:16:37 -0000 1.48
@@ -84,9 +84,12 @@
{
+/// Namespace for global data (will likely turn into a class)
namespace globals { // gnash::globals
+
/// global StreamProvider
static StreamProvider streamProvider;
+
} // namespace gnash::global
bool s_verbose_action = false;
Index: server/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/movie_def_impl.cpp 26 Jul 2006 11:54:27 -0000 1.13
+++ server/movie_def_impl.cpp 3 Aug 2006 19:16:37 -0000 1.14
@@ -289,6 +289,7 @@
void movie_def_impl::add_bitmap_character(int character_id,
bitmap_character_def* ch)
{
assert(ch);
+ //log_msg("Add bitmap character %d", character_id);
m_bitmap_characters.add(character_id, ch);
add_bitmap_info(ch->get_bitmap_info());
@@ -305,6 +306,7 @@
void movie_def_impl::add_sound_sample(int character_id, sound_sample* sam)
{
assert(sam);
+ log_msg("Add sound sample %d", character_id);
m_sound_samples.add(character_id, sam);
}
@@ -609,18 +611,36 @@
// CharacterDictionary
//
+void
+CharacterDictionary::dump_chars() const
+{
+ for ( const_iterator it=begin(), endIt=end();
+ it != endIt; ++it )
+ {
+ log_msg("Character %d @ %p", it->first, it->second.get_ptr());
+ //character_def* cdef = it->second;
+ }
+}
+
smart_ptr<character_def>
CharacterDictionary::get_character(int id)
{
container::iterator it = _map.find(id);
- if ( it == _map.end() ) return smart_ptr<character_def>();
+ if ( it == _map.end() )
+ {
+ log_msg("Could not find char %d, dump is:", id);
+ dump_chars();
+ return smart_ptr<character_def>();
+ }
else return it->second;
}
void
CharacterDictionary::add_character(int id, smart_ptr<character_def> c)
{
+ //log_msg("CharacterDictionary: add char %d", id);
_map[id] = c;
+ //dump_chars();
}
} // namespace gnash
Index: server/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/movie_def_impl.h 24 Jul 2006 18:59:40 -0000 1.11
+++ server/movie_def_impl.h 3 Aug 2006 19:16:37 -0000 1.12
@@ -134,6 +134,8 @@
/// Return a const_iterator to one-past last dictionary element
const_iterator end() const { return _map.end(); }
+ /// Dump content of the dictionary (debugging only)
+ void dump_chars(void) const;
private:
container _map;
Index: server/sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sound.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/sound.cpp 26 Jul 2006 21:49:06 -0000 1.14
+++ server/sound.cpp 3 Aug 2006 19:16:37 -0000 1.15
@@ -14,63 +14,48 @@
#include "movie_definition.h"
namespace gnash {
+
+namespace globals {
+
// Callback interface to host, for handling sounds. If it's NULL,
// sound is ignored.
- static sound_handler* s_sound_handler = 0;
+ sound_handler* s_sound_handler = 0;
+
+} // namespace gnash::global
void set_sound_handler(sound_handler* s)
// Called by host, to set a handler for all sounds.
// Can pass in 0 to disable sound.
{
- s_sound_handler = s;
+ globals::s_sound_handler = s;
}
sound_handler* get_sound_handler()
{
- return s_sound_handler;
+ return globals::s_sound_handler;
}
sound_sample_impl::~sound_sample_impl()
{
- if (s_sound_handler)
+ if (globals::s_sound_handler)
{
- s_sound_handler->delete_sound(m_sound_handler_id);
+
globals::s_sound_handler->delete_sound(m_sound_handler_id);
}
}
- // Utility function to uncompress ADPCM.
- static void adpcm_expand(
- void* data_out,
- stream* in,
- int sample_count, // in stereo, this is number of *pairs*
of samples
- bool stereo);
-
-
-
- /// SWF Tag StartSound (15)
- struct start_sound_tag : public execute_tag
- {
- uint16_t m_handler_id;
- int m_loop_count;
- bool m_stop_playback;
-
- start_sound_tag()
- :
- m_handler_id(0),
- m_loop_count(0),
- m_stop_playback(false)
- {
- }
+//
+// SWF Tag StartSound (15)
+//
- void read(stream* in, int tag_type, movie_definition* m,
const sound_sample_impl* sam)
- // Initialize this StartSound tag from the stream & given
sample.
- // Insert ourself into the movie.
- {
+void
+start_sound_tag::read(stream* in, int tag_type, movie_definition* m,
+ const sound_sample_impl* sam)
+{
assert(sam);
in->read_uint(2); // skip reserved bits.
@@ -93,11 +78,14 @@
m_handler_id = sam->m_sound_handler_id;
m->add_execute_tag(this);
- }
+}
- void execute(movie* m)
- {
+void
+start_sound_tag::execute(movie* m)
+{
+ using globals::s_sound_handler;
+
if (s_sound_handler)
{
if (m_stop_playback)
@@ -109,45 +97,32 @@
s_sound_handler->play_sound(m_handler_id, m_loop_count, 0,0);
}
}
- }
- };
-
-#ifdef SOUND_GST
- /// SWF Tag SoundStreamBlock (19)
- struct start_stream_sound_tag : public execute_tag
- {
- uint16_t m_handler_id;
- long m_start;
- int latency;
-
- start_stream_sound_tag()
- :
- m_handler_id(0),
- m_start(0),
- latency(0)
- {
- }
+}
+//
+// SWF Tag SoundStreamBlock (19)
+//
- void read(movie_definition* m, int handler_id, long start)
- // Initialize this StartSound tag from the stream & given
sample.
- // Insert ourself into the movie.
- {
+// Initialize this StartSound tag from the stream & given sample.
+// Insert ourself into the movie.
+void
+start_stream_sound_tag::read(movie_definition* m, int handler_id, long start)
+{
m_handler_id = handler_id;
m_start = start;
m->add_execute_tag(this);
- }
+}
- void execute(movie* m)
- {
+void
+start_stream_sound_tag::execute(movie* m)
+{
+ using globals::s_sound_handler;
if (s_sound_handler)
{
s_sound_handler->play_sound(m_handler_id, 0, 0,
m_start);
}
- }
- };
-#endif
+}
// void define_button_sound(...) ???
@@ -300,14 +275,14 @@
}
- void adpcm_expand(
+ // Utility function: uncompress ADPCM data from in stream to
+ // out_data[]. The output buffer must have (sample_count*2)
+ // bytes for mono, or (sample_count*4) bytes for stereo.
+ void sound_handler::adpcm_expand(
void* out_data_void,
stream* in,
int sample_count, // in stereo, this is number of *pairs*
of samples
bool stereo)
- // Utility function: uncompress ADPCM data from in stream to
- // out_data[]. The output buffer must have (sample_count*2)
- // bytes for mono, or (sample_count*4) bytes for stereo.
{
int16_t* out_data = (int16_t*) out_data_void;
@@ -367,224 +342,6 @@
}
}
-namespace SWF {
-namespace tag_loaders {
-
-// Load a DefineSound tag.
-void
-define_sound_loader(stream* in, tag_type tag, movie_definition* m)
-{
- assert(tag == 14);
-
- uint16_t character_id = in->read_u16();
-
- sound_handler::format_type format = (sound_handler::format_type)
in->read_uint(4);
- int sample_rate = in->read_uint(2); // multiples of 5512.5
- bool sample_16bit = in->read_uint(1) ? true : false;
- bool stereo = in->read_uint(1) ? true : false;
- int sample_count = in->read_u32();
-
- static int s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
-
- log_parse("define sound: ch=%d, format=%d, rate=%d, 16=%d, stereo=%d,
ct=%d\n",
- character_id, int(format), sample_rate, int(sample_16bit),
int(stereo), sample_count);
-
- // If we have a sound_handler, ask it to init this sound.
- if (s_sound_handler)
- {
- int data_bytes = 0;
- unsigned char* data = NULL;
-
- if (! (sample_rate >= 0 && sample_rate <= 3))
- {
- gnash::log_error("Bad sample rate read from SWF
header.\n");
- return;
- }
-
- if (format == sound_handler::FORMAT_ADPCM)
- {
- // Uncompress the ADPCM before handing data to host.
- data_bytes = sample_count * (stereo ? 4 : 2);
- data = new unsigned char[data_bytes];
- adpcm_expand(data, in, sample_count, stereo);
- format = sound_handler::FORMAT_NATIVE16;
- }
- else
- {
- // @@ This is pretty awful -- lots of copying, slow
reading.
- data_bytes = in->get_tag_end_position() -
in->get_position();
- data = new unsigned char[data_bytes];
- for (int i = 0; i < data_bytes; i++)
- {
- data[i] = in->read_u8();
- }
-
- // Swap bytes on behalf of the host, to make it easier
for the handler.
- // @@ I'm assuming this is a good idea? Most sound
handlers will prefer native endianness?
- if (format == sound_handler::FORMAT_UNCOMPRESSED
- && sample_16bit)
- {
- #ifndef _TU_LITTLE_ENDIAN_
- // Swap sample bytes to get big-endian format.
- for (int i = 0; i < data_bytes - 1; i += 2)
- {
- swap(&data[i], &data[i+1]);
- }
- #endif // not _TU_LITTLE_ENDIAN_
-
- format = sound_handler::FORMAT_NATIVE16;
- }
- }
-
- int handler_id = s_sound_handler->create_sound(
- data,
- data_bytes,
- sample_count,
- format,
- s_sample_rate_table[sample_rate],
- stereo);
- sound_sample* sam = new sound_sample_impl(handler_id);
- m->add_sound_sample(character_id, sam);
-
- delete [] data;
- }
-}
-
-
-void
-start_sound_loader(stream* in, tag_type tag, movie_definition* m)
-// Load a StartSound tag.
-{
- assert(tag == 15);
-
- uint16_t sound_id = in->read_u16();
-
- sound_sample_impl* sam = (sound_sample_impl*)
m->get_sound_sample(sound_id);
- if (sam)
- {
- start_sound_tag* sst = new start_sound_tag();
- sst->read(in, tag, m, sam);
-
- log_parse("start_sound tag: id=%d, stop = %d, loop ct = %d\n",
- sound_id, int(sst->m_stop_playback),
sst->m_loop_count);
- }
- else
- {
- if (s_sound_handler)
- {
- log_error("start_sound_loader: sound_id %d is not
defined\n", sound_id);
- }
- }
-
-}
-
-
-
-// Load a SoundStreamHead(2) tag.
-void
-sound_stream_head_loader(stream* in, tag_type tag, movie_definition* m)
-{
-#ifdef SOUND_GST
- assert(tag == 18 || tag == 45);
-
- // FIXME:
- // no character id for soundstreams... so we make one up...
- // This only works if there is only one stream in the movie...
- // The right way to do it is to make seperate structures for streams
- // in movie_def_impl.
-
- // extract garbage data
- int garbage = in->read_uint(8);
-
- sound_handler::format_type format =
static_cast<sound_handler::format_type>(in->read_uint(4));
- int sample_rate = in->read_uint(2); // multiples of 5512.5
- bool sample_16bit = in->read_uint(1) ? true : false;
- bool stereo = in->read_uint(1) ? true : false;
-
- // checks if this is a new streams header or just one in the row
- if (format == 0 && sample_rate == 0 && !sample_16bit && !stereo) return;
-
- int sample_count = in->read_u32();
- if (format == 2) garbage = in->read_uint(16);
-
- static int s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
-
- log_parse("sound stream head: format=%d, rate=%d, 16=%d, stereo=%d,
ct=%d\n",
- int(format), sample_rate, int(sample_16bit), int(stereo),
sample_count);
-
- // If we have a sound_handler, ask it to init this sound.
- if (s_sound_handler)
- {
- int data_bytes = 0;
-
- if (! (sample_rate >= 0 && sample_rate <= 3))
- {
- gnash::log_error("Bad sample rate read from SWF
header.\n");
- return;
- }
-
- int handler_id = s_sound_handler->create_sound(
- NULL,
- data_bytes,
- sample_count,
- format,
- s_sample_rate_table[sample_rate],
- stereo);
- m->set_loading_sound_stream_id(handler_id);
-
- }
-#endif
-}
-
-
-// Load a SoundStreamBlock tag.
-void
-sound_stream_block_loader(stream* in, tag_type tag, movie_definition* m)
-{
-#ifdef SOUND_GST
- assert(tag == 19);
-
-
- // extract garbage data
- int garbage = in->read_uint(32);
-
-
- // If we have a sound_handler, store the data with the appropiate sound.
- if (!s_sound_handler) return;
-
- int data_bytes = 0;
- unsigned char* data = NULL;
-
- // @@ This is pretty awful -- lots of copying, slow reading.
- data_bytes = in->get_tag_end_position() - in->get_position();
-
- if (data_bytes <= 0) return;
-
- data = new unsigned char[data_bytes];
- for (int i = 0; i < data_bytes; i++)
- {
- data[i] = in->read_u8();
- }
-
- int handle_id = m->get_loading_sound_stream_id();
-
- // Fill the data on the apropiate sound, and receives the starting point
- // for later "start playing from this frame" events.
- long start = s_sound_handler->fill_stream_data(data, data_bytes,
handle_id);
-
- delete [] data;
-
- start_stream_sound_tag* ssst = new start_stream_sound_tag();
- ssst->read(m, handle_id, start);
-
-
-#endif
-}
-
-
-} // namespace gnash::SWF::tag_loaders
-} // namespace gnash::SWF
-
} // namespace gnash
Index: server/sound.h
===================================================================
RCS file: /sources/gnash/gnash/server/sound.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/sound.h 20 Dec 2005 21:01:18 -0000 1.1
+++ server/sound.h 3 Aug 2006 19:16:37 -0000 1.2
@@ -7,10 +7,16 @@
#define GNASH_SOUND_H
+namespace gnash {
+ struct movie_definition;
+}
+
#include "impl.h"
+#include "execute_tag.h" // for sound tags
namespace gnash {
+
struct sound_sample_impl : public sound_sample
{
int m_sound_handler_id;
@@ -23,6 +29,61 @@
virtual ~sound_sample_impl();
};
+
+ /// SWF Tag StartSound (15)
+ struct start_sound_tag : public execute_tag
+ {
+ uint16_t m_handler_id;
+ int m_loop_count;
+ bool m_stop_playback;
+
+ start_sound_tag()
+ :
+ m_handler_id(0),
+ m_loop_count(0),
+ m_stop_playback(false)
+ {
+ }
+
+
+ /// \brief
+ /// Initialize this StartSound tag from
+ /// the stream & given sample.
+ //
+ /// Insert ourself into the movie.
+ void read(stream* in, int tag_type,
+ movie_definition* m, const sound_sample_impl* sam);
+
+ void execute(movie* m);
+ };
+
+ /// SWF Tag SoundStreamBlock (19)
+ struct start_stream_sound_tag : public execute_tag
+ {
+ uint16_t m_handler_id;
+ long m_start;
+ int latency;
+
+ start_stream_sound_tag()
+ :
+ m_handler_id(0),
+ m_start(0),
+ latency(0)
+ {
+ }
+
+
+ /// \brief
+ /// Initialize this StartSound tag
+ /// from the stream & given sample.
+ //
+ /// Insert ourself into the movie.
+ void read(movie_definition* m, int handler_id, long start);
+
+
+ void execute(movie* m);
+ };
+
}
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/swf/tag_loaders.cpp 31 Jul 2006 23:10:14 -0000 1.19
+++ server/swf/tag_loaders.cpp 3 Aug 2006 19:16:38 -0000 1.20
@@ -75,8 +75,13 @@
#include "GnashException.h"
namespace gnash {
-// @@ TODO get rid of this; make it the normal mode.
-extern bool s_no_recurse_while_loading;
+
+ // @@ TODO get rid of this; make it the normal mode.
+ extern bool s_no_recurse_while_loading;
+
+ namespace globals {
+ extern sound_handler* s_sound_handler;
+ }
}
namespace gnash {
@@ -1379,8 +1384,8 @@
void
do_action_loader(stream* in, tag_type tag, movie_definition* m)
{
- log_parse("tag %d: do_action_loader\n", tag);
- log_action("-- actions in frame %d\n",
+ log_parse("tag %d: do_action_loader", tag);
+ log_action("-- actions in frame %d",
m->get_loading_frame());
assert(in);
@@ -1400,8 +1405,8 @@
int sprite_character_id = in->read_u16();
- log_parse(" tag %d: do_init_action_loader\n", tag);
- log_action(" -- init actions for sprite %d\n",
+ log_parse(" tag %d: do_init_action_loader", tag);
+ log_action(" -- init actions for sprite %d",
sprite_character_id);
do_action* da = new do_action;
@@ -1410,6 +1415,238 @@
m->add_init_action(da);
}
+//
+// Sound
+//
+
+// Load a DefineSound tag.
+void
+define_sound_loader(stream* in, tag_type tag, movie_definition* m)
+{
+ assert(tag == SWF::DEFINESOUND); // 14
+
+ using globals::s_sound_handler;
+
+ uint16_t character_id = in->read_u16();
+
+ sound_handler::format_type format = (sound_handler::format_type)
in->read_uint(4);
+ int sample_rate = in->read_uint(2); // multiples of 5512.5
+ bool sample_16bit = in->read_uint(1) ? true : false;
+ bool stereo = in->read_uint(1) ? true : false;
+ int sample_count = in->read_u32();
+
+ static int s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
+
+ log_parse("define sound: ch=%d, format=%d, rate=%d, 16=%d, stereo=%d,
ct=%d\n",
+ character_id, int(format), sample_rate, int(sample_16bit),
int(stereo), sample_count);
+
+ // If we have a sound_handler, ask it to init this sound.
+
+ if (s_sound_handler)
+ {
+ int data_bytes = 0;
+ unsigned char* data = NULL;
+
+ if (! (sample_rate >= 0 && sample_rate <= 3))
+ {
+ gnash::log_error("Bad sample rate read from SWF
header.\n");
+ return;
+ }
+
+ if (format == sound_handler::FORMAT_ADPCM)
+ {
+ // Uncompress the ADPCM before handing data to host.
+ data_bytes = sample_count * (stereo ? 4 : 2);
+ data = new unsigned char[data_bytes];
+ sound_handler::adpcm_expand(data, in, sample_count,
+ stereo);
+ format = sound_handler::FORMAT_NATIVE16;
+ }
+ else
+ {
+ // @@ This is pretty awful -- lots of copying, slow
reading.
+ data_bytes = in->get_tag_end_position() -
in->get_position();
+ data = new unsigned char[data_bytes];
+ for (int i = 0; i < data_bytes; i++)
+ {
+ data[i] = in->read_u8();
+ }
+
+ // Swap bytes on behalf of the host, to make it easier
for the handler.
+ // @@ I'm assuming this is a good idea? Most sound
handlers will prefer native endianness?
+ if (format == sound_handler::FORMAT_UNCOMPRESSED
+ && sample_16bit)
+ {
+ #ifndef _TU_LITTLE_ENDIAN_
+ // Swap sample bytes to get big-endian format.
+ for (int i = 0; i < data_bytes - 1; i += 2)
+ {
+ swap(&data[i], &data[i+1]);
+ }
+ #endif // not _TU_LITTLE_ENDIAN_
+
+ format = sound_handler::FORMAT_NATIVE16;
+ }
+ }
+
+ int handler_id = s_sound_handler->create_sound(
+ data,
+ data_bytes,
+ sample_count,
+ format,
+ s_sample_rate_table[sample_rate],
+ stereo);
+ sound_sample* sam = new sound_sample_impl(handler_id);
+ m->add_sound_sample(character_id, sam);
+
+ delete [] data;
+ }
+}
+
+
+// Load a StartSound tag.
+void
+start_sound_loader(stream* in, tag_type tag, movie_definition* m)
+{
+ using globals::s_sound_handler;
+
+ assert(tag == SWF::STARTSOUND); // 15
+
+ uint16_t sound_id = in->read_u16();
+
+ sound_sample_impl* sam = (sound_sample_impl*)
m->get_sound_sample(sound_id);
+ if (sam)
+ {
+ start_sound_tag* sst = new start_sound_tag();
+ sst->read(in, tag, m, sam);
+
+ log_parse("start_sound tag: id=%d, stop = %d, loop ct = %d\n",
+ sound_id, int(sst->m_stop_playback),
sst->m_loop_count);
+ }
+ else
+ {
+ if (s_sound_handler)
+ {
+ log_error("start_sound_loader: sound_id %d is not
defined\n", sound_id);
+ }
+ }
+
+}
+
+// Load a SoundStreamHead(2) tag.
+void
+sound_stream_head_loader(stream* in, tag_type tag, movie_definition* m)
+{
+ using globals::s_sound_handler;
+
+ // 18 || 45
+ assert(tag == SWF::SOUNDSTREAMHEAD || tag == SWF::SOUNDSTREAMHEAD2);
+
+ // FIXME:
+ // no character id for soundstreams... so we make one up...
+ // This only works if there is only one stream in the movie...
+ // The right way to do it is to make seperate structures for streams
+ // in movie_def_impl.
+
+ // extract garbage data
+ int garbage = in->read_uint(8);
+
+ sound_handler::format_type format =
static_cast<sound_handler::format_type>(in->read_uint(4));
+ int sample_rate = in->read_uint(2); // multiples of 5512.5
+ bool sample_16bit = in->read_uint(1) ? true : false;
+ bool stereo = in->read_uint(1) ? true : false;
+
+ // checks if this is a new streams header or just one in the row
+ if (format == 0 && sample_rate == 0 && !sample_16bit && !stereo) return;
+
+ int sample_count = in->read_u32();
+ if (format == 2) garbage = in->read_uint(16);
+
+ static int s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
+
+ log_parse("sound stream head: format=%d, rate=%d, 16=%d, stereo=%d,
ct=%d\n",
+ int(format), sample_rate, int(sample_16bit), int(stereo),
sample_count);
+
+ // If we don't have a sound_handler registered stop here
+ if (!s_sound_handler) return;
+
+#ifdef SOUND_GST
+ // Ask sound_handler it to init this sound.
+ int data_bytes = 0;
+
+ if (! (sample_rate >= 0 && sample_rate <= 3))
+ {
+ gnash::log_error("Bad sample rate read from SWF header.\n");
+ return;
+ }
+
+ int handler_id = s_sound_handler->create_sound(
+ NULL,
+ data_bytes,
+ sample_count,
+ format,
+ s_sample_rate_table[sample_rate],
+ stereo);
+ m->set_loading_sound_stream_id(handler_id);
+
+#else
+ log_error("Only Gstreamer sound backend supports SoundStreamHead tag");
+#endif
+}
+
+
+// Load a SoundStreamBlock tag.
+void
+sound_stream_block_loader(stream* in, tag_type tag, movie_definition* m)
+{
+ using globals::s_sound_handler;
+
+ assert(tag == SWF::SOUNDSTREAMBLOCK); // 19
+
+
+ // extract garbage data
+ int garbage = in->read_uint(32);
+
+
+ // If we don't have a sound_handler registered stop here
+ if (!s_sound_handler) return;
+
+ // store the data with the appropiate sound.
+#ifdef SOUND_GST
+
+ int data_bytes = 0;
+ unsigned char* data = NULL;
+
+ // @@ This is pretty awful -- lots of copying, slow reading.
+ data_bytes = in->get_tag_end_position() - in->get_position();
+
+ if (data_bytes <= 0) return;
+
+ data = new unsigned char[data_bytes];
+ for (int i = 0; i < data_bytes; i++)
+ {
+ data[i] = in->read_u8();
+ }
+
+ int handle_id = m->get_loading_sound_stream_id();
+
+ // Fill the data on the apropiate sound, and receives the starting point
+ // for later "start playing from this frame" events.
+ long start = s_sound_handler->fill_stream_data(data, data_bytes,
handle_id);
+
+ delete [] data;
+
+ start_stream_sound_tag* ssst = new start_stream_sound_tag();
+ ssst->read(m, handle_id, start);
+
+#else
+ log_error("Only Gstreamer sound backend supports SoundStreamBlock tag");
+
+#endif
+}
+
+
+
} // namespace gnash::SWF::tag_loaders
} // namespace gnash::SWF
Index: server/swf/tag_loaders.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/swf/tag_loaders.h 24 Jul 2006 13:30:51 -0000 1.5
+++ server/swf/tag_loaders.h 3 Aug 2006 19:16:38 -0000 1.6
@@ -125,9 +125,10 @@
void export_loader(stream*, tag_type, movie_definition*);
-/// Load an import tag (for pulling in external resources)
+/// Load an SWF::IMPORTASSETS tag (for pulling in external resources)
void import_loader(stream*, tag_type, movie_definition*);
+/// Load a SWF::DEFINESOUND tag.
void define_sound_loader(stream*, tag_type, movie_definition*);
/// Load a SWF::STARTSOUND tag.
@@ -137,8 +138,10 @@
void do_init_action_loader(stream*, tag_type, movie_definition*);
+/// Load SWF::SOUNDSTREAMHEAD or SWF::SOUNDSTREAMHEAD2 tag.
void sound_stream_head_loader(stream*, tag_type, movie_definition*);
+/// Load a SWF::SOUNDSTREAMBLOCK tag.
void sound_stream_block_loader(stream*, tag_type, movie_definition*);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ...,
Sandro Santilli <=