gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...


From: Tomas Groth
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...
Date: Wed, 14 Feb 2007 09:41:39 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Tomas Groth <tgc>       07/02/14 09:41:38

Modified files:
        .              : ChangeLog 
        server/asobj   : Global.cpp Makefile.am 
        win32/VC8      : gnash.vcproj npgnash.vcproj 
Added files:
        server/asobj   : Sound.cpp Sound.h 
Removed files:
        server/asobj   : ASSound.cpp ASSound.h 

Log message:
        * server/asobj/ASSound.{cpp,h}: Renamed to Sound.{h,cpp}.
        * server/asobj/Global.cpp, server/asobj/Makefile.am, 
win32/VC8/gnash.vcproj, 
          win32/VC8/npgnash.vcproj: Updated to use Sound.{h,cpp} instead of
          ASSound.{h,cpp}.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2355&r2=1.2356
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Makefile.am?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ASSound.cpp?cvsroot=gnash&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ASSound.h?cvsroot=gnash&r1=1.5&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/win32/VC8/gnash.vcproj?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/win32/VC8/npgnash.vcproj?cvsroot=gnash&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2355
retrieving revision 1.2356
diff -u -b -r1.2355 -r1.2356
--- ChangeLog   14 Feb 2007 09:39:08 -0000      1.2355
+++ ChangeLog   14 Feb 2007 09:41:38 -0000      1.2356
@@ -1,3 +1,10 @@
+2007-02-14 Tomas Groth Christensen <address@hidden>
+
+       * server/asobj/ASSound.{cpp,h}: Renamed to Sound.{h,cpp}.
+       * server/asobj/Global.cpp, server/asobj/Makefile.am, 
win32/VC8/gnash.vcproj, 
+         win32/VC8/npgnash.vcproj: Updated to use Sound.{h,cpp} instead of
+         ASSound.{h,cpp}.
+
 2007-02-14 Sandro Santilli <address@hidden>
 
        * testsuite/misc-ming.all/Makefile.am: run the multi_doactions

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/asobj/Global.cpp     12 Feb 2007 17:35:51 -0000      1.43
+++ server/asobj/Global.cpp     14 Feb 2007 09:41:38 -0000      1.44
@@ -18,7 +18,7 @@
 
 // Implementation of the Global ActionScript Object
 
-/* $Id: Global.cpp,v 1.43 2007/02/12 17:35:51 tgc Exp $ */
+/* $Id: Global.cpp,v 1.44 2007/02/14 09:41:38 tgc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -52,7 +52,7 @@
 #include "NetStream.h"
 #include "Selection.h"
 #include "SharedObject.h"
-#include "ASSound.h"
+#include "Sound.h"
 #include "Stage.h"
 #include "System.h"
 #include "textformat.h"

Index: server/asobj/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Makefile.am,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/asobj/Makefile.am    13 Feb 2007 19:36:34 -0000      1.30
+++ server/asobj/Makefile.am    14 Feb 2007 09:41:38 -0000      1.31
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# $Id: Makefile.am,v 1.30 2007/02/13 19:36:34 rsavoye Exp $
+# $Id: Makefile.am,v 1.31 2007/02/14 09:41:38 tgc Exp $
 
 AUTOMAKE_OPTIONS = 
 
@@ -42,7 +42,7 @@
 
 
 libgnashasobjs_la_SOURCES = \
-       ASSound.cpp     \
+       Sound.cpp       \
        Boolean.cpp     \
        Camera.cpp      \
        Color.cpp       \
@@ -76,7 +76,7 @@
        $(NULL)
 
 noinst_HEADERS = \
-       ASSound.h       \
+       Sound.h         \
        Boolean.h       \
        Camera.h        \
        Color.h         \

Index: win32/VC8/gnash.vcproj
===================================================================
RCS file: /sources/gnash/gnash/win32/VC8/gnash.vcproj,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- win32/VC8/gnash.vcproj      24 Nov 2006 14:59:13 -0000      1.4
+++ win32/VC8/gnash.vcproj      14 Feb 2007 09:41:38 -0000      1.5
@@ -223,7 +223,7 @@
                                >
                        </File>
                        <File
-                               RelativePath="..\..\server\asobj\ASSound.cpp"
+                               RelativePath="..\..\server\asobj\Sound.cpp"
                                >
                        </File>
                        <File
@@ -857,7 +857,7 @@
                                >
                        </File>
                        <File
-                               RelativePath="..\..\server\asobj\ASSound.h"
+                               RelativePath="..\..\server\asobj\Sound.h"
                                >
                        </File>
                        <File

Index: win32/VC8/npgnash.vcproj
===================================================================
RCS file: /sources/gnash/gnash/win32/VC8/npgnash.vcproj,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- win32/VC8/npgnash.vcproj    20 Nov 2006 16:39:52 -0000      1.2
+++ win32/VC8/npgnash.vcproj    14 Feb 2007 09:41:38 -0000      1.3
@@ -233,7 +233,7 @@
                                >
                        </File>
                        <File
-                               RelativePath="..\..\server\asobj\ASSound.cpp"
+                               RelativePath="..\..\server\asobj\Sound.cpp"
                                >
                        </File>
                        <File
@@ -715,7 +715,7 @@
                                >
                        </File>
                        <File
-                               RelativePath="..\..\server\asobj\ASSound.h"
+                               RelativePath="..\..\server\asobj\Sound.h"
                                >
                        </File>
                        <File

Index: server/asobj/Sound.cpp
===================================================================
RCS file: server/asobj/Sound.cpp
diff -N server/asobj/Sound.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ server/asobj/Sound.cpp      14 Feb 2007 09:41:38 -0000      1.1
@@ -0,0 +1,446 @@
+// 
+//   Copyright (C) 2005, 2006 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
+//
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "log.h"
+#include "Sound.h"
+#include "sound.h" // for sound_sample_impl
+#include "movie_definition.h"
+#include "sprite_instance.h"
+#include "fn_call.h"
+#include "GnashException.h"
+#include "builtin_function.h"
+
+#include <string>
+
+namespace gnash {
+
+static void sound_new(const fn_call& fn);
+static void sound_attachsound(const fn_call& fn);
+static void sound_getbytesloaded(const fn_call& fn);
+static void sound_getbytestotal(const fn_call& fn);
+static void sound_getpan(const fn_call& fn);
+static void sound_gettransform(const fn_call& fn);
+static void sound_getvolume(const fn_call& fn);
+static void sound_loadsound(const fn_call& fn);
+static void sound_setpan(const fn_call& fn);
+static void sound_settransform(const fn_call& fn);
+static void sound_setvolume(const fn_call& fn);
+static void sound_start(const fn_call& fn);
+static void sound_stop(const fn_call& fn);
+static as_object* getSoundInterface();
+
+Sound::Sound()         :
+       as_object(getSoundInterface()),
+       soundName(""),
+       soundId(-1)
+{
+}
+
+Sound::~Sound() {
+}
+
+
+void
+Sound::attachSound(int si, const char* name)
+{
+       soundId = si;
+       soundName = name;
+}
+
+void
+Sound::getBytesLoaded()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+Sound::getBytesTotal()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+Sound::getPan()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+Sound::getTransform()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+int
+Sound::getVolume()
+{
+       int volume = 0;
+       sound_handler* s = get_sound_handler();
+       if (s != NULL)
+       {
+               volume = s->get_volume(soundId);
+       }
+       return volume;
+}
+
+void
+Sound::loadSound(std::string /*file*/, bool /*streaming*/)
+{
+    log_msg("%s is still testing!! \n", __FUNCTION__);
+
+
+}
+
+void
+Sound::setPan()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+Sound::setTransform()
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+Sound::setVolume(int volume)
+{
+       // sanity check
+       if (volume >= 0 && volume <=100)
+       {
+               sound_handler* s = get_sound_handler();
+               if (s != NULL)
+               {
+                       s->set_volume(soundId, volume);
+               }
+       }
+}
+
+void
+Sound::start(int offset, int loops)
+{
+           sound_handler* s = get_sound_handler();
+           if (s) s->play_sound(soundId, loops, offset, 0, NULL);
+    
+}
+
+void
+Sound::stop(int si)
+{
+
+       sound_handler* s = get_sound_handler();
+       if (s != NULL)
+       {
+           if (si > -1) {
+                       s->stop_sound(soundId);
+               } else {
+                       s->stop_sound(si);
+               }
+       }
+}
+
+void
+sound_new(const fn_call& fn)
+{
+       Sound *sound_obj = new Sound;
+
+       fn.result->set_as_object(sound_obj);
+}
+
+// Wrapper around dynamic_cast to implement user warning.
+// To be used by builtin properties and methods.
+static Sound*
+ensure_sound(as_object* obj)
+{
+       Sound* ret = dynamic_cast<Sound*>(obj);
+       if ( ! ret )
+       {
+               throw ActionException("builtin method or gettersetter for Sound 
objects called against non-Sound instance");
+       }
+       return ret;
+}
+
+void
+sound_start(const fn_call& fn)
+{
+       log_action("-- start sound \n");
+       Sound* so = ensure_sound(fn.this_ptr);
+       int loop = 0;
+       int secondOffset = 0;
+
+       if (fn.nargs > 0) {
+               secondOffset = (int) fn.arg(0).to_number();
+
+               if (fn.nargs > 1) {
+                       loop = (int) fn.arg(1).to_number() - 1;
+
+                       // -1 means infinite playing of sound
+                       // sanity check
+                       loop = loop < 0 ? -1 : loop;
+               }
+       }
+       so->start(secondOffset, loop);
+
+}
+
+void
+sound_stop(const fn_call& fn)
+{
+       log_action("-- stop sound \n");
+       Sound* so = ensure_sound(fn.this_ptr);
+
+       int si = -1;
+
+       if (fn.nargs > 0) {
+               const char* name = fn.arg(0).to_string();
+
+               // check the import.
+               movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
+               assert(def);
+               boost::intrusive_ptr<resource> res = 
def->get_exported_resource(name);
+               if (res == NULL)
+               {
+                   log_error("import error: resource '%s' is not exported\n", 
name);
+                   return;
+               }
+
+               sound_sample_impl* ss = (sound_sample_impl*) 
res->cast_to_sound_sample();
+
+               if (ss != NULL)
+               {
+                   si = ss->m_sound_handler_id;
+               }
+               else
+               {
+                   log_error("sound sample is NULL\n");
+                   return;
+               }
+
+       }
+       so->stop(si);
+
+}
+
+void
+sound_attachsound(const fn_call& fn)
+{
+    log_action("-- attach sound \n");
+    if (fn.nargs < 1)
+       {
+           log_error("attach sound needs one argument\n");
+           return;
+       }
+
+       Sound* so = ensure_sound(fn.this_ptr);
+
+    const char* name = fn.arg(0).to_string();
+    if (!name) {
+               log_error("attachSound need a non-null argument\n");
+               return;
+       }
+
+    // check the import.
+    movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
+    assert(def);
+    boost::intrusive_ptr<resource> res = 
def->get_exported_resource(so->soundName.c_str());
+    if (res == NULL)
+       {
+           log_error("import error: resource '%s' is not exported\n", 
so->soundName.c_str());
+           return;
+       }
+
+    int si = 0;
+    sound_sample_impl* ss = (sound_sample_impl*) res->cast_to_sound_sample();
+
+    if (ss != NULL)
+       {
+           si = ss->m_sound_handler_id;
+       }
+    else
+       {
+           log_error("sound sample is NULL\n");
+           return;
+       }
+
+    // sanity check
+    assert(si >= 0 && si < 1000);
+    so->attachSound(si, name);
+}
+
+void
+sound_getbytesloaded(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_getbytestotal(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_getpan(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_gettransform(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_getvolume(const fn_call& fn)
+{
+
+       Sound* so = ensure_sound(fn.this_ptr);
+
+       int volume = so->getVolume();
+
+       fn.result->set_int(volume);
+
+       return;
+}
+
+void
+sound_loadsound(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_setpan(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_settransform(const fn_call& /*fn*/)
+{
+    log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_setvolume(const fn_call& fn)
+{
+       if (fn.nargs < 1)
+       {
+               log_error("set volume of sound needs one argument\n");
+               return;
+       }
+
+       Sound* so = ensure_sound(fn.this_ptr);  
+       int volume = (int) fn.arg(0).to_number();
+
+       so->setVolume(volume);
+}
+
+void
+sound_duration(const fn_call& /*fn*/)
+{
+       log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_ID3(const fn_call& /*fn*/)
+{
+       log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+sound_position(const fn_call& /*fn*/)
+{
+       log_msg("%s:unimplemented \n", __FUNCTION__);
+}
+
+void
+attachSoundInterface(as_object& o)
+{
+
+       o.init_member("attachSound", &sound_attachsound);
+       o.init_member("getBytesLoaded", &sound_getbytesloaded);
+       o.init_member("getBytesTotal", &sound_getbytestotal);
+       o.init_member("getPan", &sound_getpan);
+       o.init_member("getTransform", &sound_gettransform);
+       o.init_member("getVolume", &sound_getvolume);
+       o.init_member("loadSound", &sound_loadsound);
+       o.init_member("setPan", &sound_setpan);
+       o.init_member("setTransform", &sound_settransform);
+       o.init_member("setVolume", &sound_setvolume);
+       o.init_member("start", &sound_start);
+       o.init_member("stop", &sound_stop);
+
+       // Properties
+
+       boost::intrusive_ptr<builtin_function> gettersetter;
+
+       gettersetter = new builtin_function(&sound_duration, NULL);
+       o.init_property("duration", *gettersetter, *gettersetter);
+
+       gettersetter = new builtin_function(&sound_ID3, NULL);
+       o.init_property("ID3", *gettersetter, *gettersetter);
+
+       gettersetter = new builtin_function(&sound_position, NULL);
+       o.init_property("position", *gettersetter, *gettersetter);
+
+}
+
+static as_object*
+getSoundInterface()
+{
+
+       static boost::intrusive_ptr<as_object> o;
+       if ( o == NULL )
+       {
+               o = new as_object();
+               attachSoundInterface(*o);
+       }
+
+       return o.get();
+}
+
+// extern (used by Global.cpp)
+void sound_class_init(as_object& global)
+{
+
+       // This is going to be the global Sound "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
+
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&sound_new, getSoundInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachSoundInterface(*cl);
+                    
+       }
+
+       // Register _global.String
+       global.init_member("Sound", cl.get());
+
+}
+
+} // end of gnash namespace
+

Index: server/asobj/Sound.h
===================================================================
RCS file: server/asobj/Sound.h
diff -N server/asobj/Sound.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ server/asobj/Sound.h        14 Feb 2007 09:41:38 -0000      1.1
@@ -0,0 +1,72 @@
+// 
+//   Copyright (C) 2005, 2006 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
+//
+
+#ifndef __ASSOUND_H__
+#define __ASSOUND_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "impl.h"
+#include "as_object.h" // for inheritance
+#include "NetConnection.h"
+
+namespace gnash {
+
+// Forward declarations
+class fn_call;
+  
+class Sound : public as_object {
+public:
+       Sound();
+       ~Sound();
+       void attachSound(int si, const char* name);
+       void getBytesLoaded();
+       void getBytesTotal();
+       void getPan();
+       void getTransform();
+       int getVolume();
+       void loadSound(std::string file, bool streaming);
+       void setPan();
+       void setTransform();
+       void setVolume(int volume);
+       void start(int offset, int loops);
+       void stop(int si);
+
+       std::string soundName;
+private:
+       bool _duration;
+       bool _id3;
+       bool _onID3;
+       bool _onLoad;
+       bool _onComplete;
+       bool _position;
+       NetConnection* connection;
+
+       int soundId;
+       bool externalSound;
+};
+
+void sound_class_init(as_object& global);
+
+} // end of gnash namespace
+
+// __ASSOUND_H__
+#endif
+

Index: server/asobj/ASSound.cpp
===================================================================
RCS file: server/asobj/ASSound.cpp
diff -N server/asobj/ASSound.cpp
--- server/asobj/ASSound.cpp    12 Feb 2007 17:35:51 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,446 +0,0 @@
-// 
-//   Copyright (C) 2005, 2006 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
-//
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "log.h"
-#include "ASSound.h"
-#include "sound.h" // for sound_sample_impl
-#include "movie_definition.h"
-#include "sprite_instance.h"
-#include "fn_call.h"
-#include "GnashException.h"
-#include "builtin_function.h"
-
-#include <string>
-
-namespace gnash {
-
-static void sound_new(const fn_call& fn);
-static void sound_attachsound(const fn_call& fn);
-static void sound_getbytesloaded(const fn_call& fn);
-static void sound_getbytestotal(const fn_call& fn);
-static void sound_getpan(const fn_call& fn);
-static void sound_gettransform(const fn_call& fn);
-static void sound_getvolume(const fn_call& fn);
-static void sound_loadsound(const fn_call& fn);
-static void sound_setpan(const fn_call& fn);
-static void sound_settransform(const fn_call& fn);
-static void sound_setvolume(const fn_call& fn);
-static void sound_start(const fn_call& fn);
-static void sound_stop(const fn_call& fn);
-static as_object* getSoundInterface();
-
-Sound::Sound()         :
-       as_object(getSoundInterface()),
-       soundName(""),
-       soundId(-1)
-{
-}
-
-Sound::~Sound() {
-}
-
-
-void
-Sound::attachSound(int si, const char* name)
-{
-       soundId = si;
-       soundName = name;
-}
-
-void
-Sound::getBytesLoaded()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-Sound::getBytesTotal()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-Sound::getPan()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-Sound::getTransform()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-int
-Sound::getVolume()
-{
-       int volume = 0;
-       sound_handler* s = get_sound_handler();
-       if (s != NULL)
-       {
-               volume = s->get_volume(soundId);
-       }
-       return volume;
-}
-
-void
-Sound::loadSound(std::string /*file*/, bool /*streaming*/)
-{
-    log_msg("%s is still testing!! \n", __FUNCTION__);
-
-
-}
-
-void
-Sound::setPan()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-Sound::setTransform()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-Sound::setVolume(int volume)
-{
-       // sanity check
-       if (volume >= 0 && volume <=100)
-       {
-               sound_handler* s = get_sound_handler();
-               if (s != NULL)
-               {
-                       s->set_volume(soundId, volume);
-               }
-       }
-}
-
-void
-Sound::start(int offset, int loops)
-{
-           sound_handler* s = get_sound_handler();
-           if (s) s->play_sound(soundId, loops, offset, 0, NULL);
-    
-}
-
-void
-Sound::stop(int si)
-{
-
-       sound_handler* s = get_sound_handler();
-       if (s != NULL)
-       {
-           if (si > -1) {
-                       s->stop_sound(soundId);
-               } else {
-                       s->stop_sound(si);
-               }
-       }
-}
-
-void
-sound_new(const fn_call& fn)
-{
-       Sound *sound_obj = new Sound;
-
-       fn.result->set_as_object(sound_obj);
-}
-
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static Sound*
-ensure_sound(as_object* obj)
-{
-       Sound* ret = dynamic_cast<Sound*>(obj);
-       if ( ! ret )
-       {
-               throw ActionException("builtin method or gettersetter for Sound 
objects called against non-Sound instance");
-       }
-       return ret;
-}
-
-void
-sound_start(const fn_call& fn)
-{
-       log_action("-- start sound \n");
-       Sound* so = ensure_sound(fn.this_ptr);
-       int loop = 0;
-       int secondOffset = 0;
-
-       if (fn.nargs > 0) {
-               secondOffset = (int) fn.arg(0).to_number();
-
-               if (fn.nargs > 1) {
-                       loop = (int) fn.arg(1).to_number() - 1;
-
-                       // -1 means infinite playing of sound
-                       // sanity check
-                       loop = loop < 0 ? -1 : loop;
-               }
-       }
-       so->start(secondOffset, loop);
-
-}
-
-void
-sound_stop(const fn_call& fn)
-{
-       log_action("-- stop sound \n");
-       Sound* so = ensure_sound(fn.this_ptr);
-
-       int si = -1;
-
-       if (fn.nargs > 0) {
-               const char* name = fn.arg(0).to_string();
-
-               // check the import.
-               movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
-               assert(def);
-               boost::intrusive_ptr<resource> res = 
def->get_exported_resource(name);
-               if (res == NULL)
-               {
-                   log_error("import error: resource '%s' is not exported\n", 
name);
-                   return;
-               }
-
-               sound_sample_impl* ss = (sound_sample_impl*) 
res->cast_to_sound_sample();
-
-               if (ss != NULL)
-               {
-                   si = ss->m_sound_handler_id;
-               }
-               else
-               {
-                   log_error("sound sample is NULL\n");
-                   return;
-               }
-
-       }
-       so->stop(si);
-
-}
-
-void
-sound_attachsound(const fn_call& fn)
-{
-    log_action("-- attach sound \n");
-    if (fn.nargs < 1)
-       {
-           log_error("attach sound needs one argument\n");
-           return;
-       }
-
-       Sound* so = ensure_sound(fn.this_ptr);
-
-    const char* name = fn.arg(0).to_string();
-    if (!name) {
-               log_error("attachSound need a non-null argument\n");
-               return;
-       }
-
-    // check the import.
-    movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
-    assert(def);
-    boost::intrusive_ptr<resource> res = 
def->get_exported_resource(so->soundName.c_str());
-    if (res == NULL)
-       {
-           log_error("import error: resource '%s' is not exported\n", 
so->soundName.c_str());
-           return;
-       }
-
-    int si = 0;
-    sound_sample_impl* ss = (sound_sample_impl*) res->cast_to_sound_sample();
-
-    if (ss != NULL)
-       {
-           si = ss->m_sound_handler_id;
-       }
-    else
-       {
-           log_error("sound sample is NULL\n");
-           return;
-       }
-
-    // sanity check
-    assert(si >= 0 && si < 1000);
-    so->attachSound(si, name);
-}
-
-void
-sound_getbytesloaded(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_getbytestotal(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_getpan(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_gettransform(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_getvolume(const fn_call& fn)
-{
-
-       Sound* so = ensure_sound(fn.this_ptr);
-
-       int volume = so->getVolume();
-
-       fn.result->set_int(volume);
-
-       return;
-}
-
-void
-sound_loadsound(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_setpan(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_settransform(const fn_call& /*fn*/)
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_setvolume(const fn_call& fn)
-{
-       if (fn.nargs < 1)
-       {
-               log_error("set volume of sound needs one argument\n");
-               return;
-       }
-
-       Sound* so = ensure_sound(fn.this_ptr);  
-       int volume = (int) fn.arg(0).to_number();
-
-       so->setVolume(volume);
-}
-
-void
-sound_duration(const fn_call& /*fn*/)
-{
-       log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_ID3(const fn_call& /*fn*/)
-{
-       log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-sound_position(const fn_call& /*fn*/)
-{
-       log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-
-void
-attachSoundInterface(as_object& o)
-{
-
-       o.init_member("attachSound", &sound_attachsound);
-       o.init_member("getBytesLoaded", &sound_getbytesloaded);
-       o.init_member("getBytesTotal", &sound_getbytestotal);
-       o.init_member("getPan", &sound_getpan);
-       o.init_member("getTransform", &sound_gettransform);
-       o.init_member("getVolume", &sound_getvolume);
-       o.init_member("loadSound", &sound_loadsound);
-       o.init_member("setPan", &sound_setpan);
-       o.init_member("setTransform", &sound_settransform);
-       o.init_member("setVolume", &sound_setvolume);
-       o.init_member("start", &sound_start);
-       o.init_member("stop", &sound_stop);
-
-       // Properties
-
-       boost::intrusive_ptr<builtin_function> gettersetter;
-
-       gettersetter = new builtin_function(&sound_duration, NULL);
-       o.init_property("duration", *gettersetter, *gettersetter);
-
-       gettersetter = new builtin_function(&sound_ID3, NULL);
-       o.init_property("ID3", *gettersetter, *gettersetter);
-
-       gettersetter = new builtin_function(&sound_position, NULL);
-       o.init_property("position", *gettersetter, *gettersetter);
-
-}
-
-static as_object*
-getSoundInterface()
-{
-
-       static boost::intrusive_ptr<as_object> o;
-       if ( o == NULL )
-       {
-               o = new as_object();
-               attachSoundInterface(*o);
-       }
-
-       return o.get();
-}
-
-// extern (used by Global.cpp)
-void sound_class_init(as_object& global)
-{
-
-       // This is going to be the global Sound "class"/"function"
-       static boost::intrusive_ptr<builtin_function> cl;
-
-       if ( cl == NULL )
-       {
-               cl=new builtin_function(&sound_new, getSoundInterface());
-               // replicate all interface to class, to be able to access
-               // all methods as static functions
-               attachSoundInterface(*cl);
-                    
-       }
-
-       // Register _global.String
-       global.init_member("Sound", cl.get());
-
-}
-
-} // end of gnash namespace
-

Index: server/asobj/ASSound.h
===================================================================
RCS file: server/asobj/ASSound.h
diff -N server/asobj/ASSound.h
--- server/asobj/ASSound.h      12 Feb 2007 17:35:51 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-// 
-//   Copyright (C) 2005, 2006 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
-//
-
-#ifndef __ASSOUND_H__
-#define __ASSOUND_H__
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "impl.h"
-#include "as_object.h" // for inheritance
-#include "NetConnection.h"
-
-namespace gnash {
-
-// Forward declarations
-class fn_call;
-  
-class Sound : public as_object {
-public:
-       Sound();
-       ~Sound();
-       void attachSound(int si, const char* name);
-       void getBytesLoaded();
-       void getBytesTotal();
-       void getPan();
-       void getTransform();
-       int getVolume();
-       void loadSound(std::string file, bool streaming);
-       void setPan();
-       void setTransform();
-       void setVolume(int volume);
-       void start(int offset, int loops);
-       void stop(int si);
-
-       std::string soundName;
-private:
-       bool _duration;
-       bool _id3;
-       bool _onID3;
-       bool _onLoad;
-       bool _onComplete;
-       bool _position;
-       NetConnection* connection;
-
-       int soundId;
-       bool externalSound;
-};
-
-void sound_class_init(as_object& global);
-
-} // end of gnash namespace
-
-// __ASSOUND_H__
-#endif
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]