Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 118
View file
lightspark.spec
Changed
@@ -1,7 +1,7 @@ # # spec file for package lightspark # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20160913.0953 +Version: 0.7.2.99+git20161015.1649 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+ @@ -44,7 +44,6 @@ BuildRequires: pkgconfig(glibmm-2.4) BuildRequires: pkgconfig(gmodule-2.0) BuildRequires: pkgconfig(gthread-2.0) -BuildRequires: pkgconfig(gtk+-2.0) BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(liblzma) BuildRequires: pkgconfig(libpcre) @@ -66,6 +65,7 @@ %if %{with ffmpeg} BuildRequires: pkgconfig(libavcodec) BuildRequires: pkgconfig(libavformat) +BuildRequires: pkgconfig(libavresample) BuildRequires: pkgconfig(libavutil) %endif @@ -92,7 +92,6 @@ mkdir build cd build cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \ - -DAUDIO_BACKEND=sdl \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DLIB_SUFFIX=$(echo %{_lib} | cut -b4-) \ -DCMAKE_BUILD_TYPE=RelWithDebugInfo \
View file
lightspark.tar.xz/CMakeLists.txt
Changed
@@ -187,13 +187,6 @@ SET(PLUGINSDIR ".") ENDIF(UNIX) -# Setting variables -IF(WIN32) - SET(AUDIO_BACKEND "winmm" CACHE STRING "Which audio backends should be built?") -ELSE() - SET(AUDIO_BACKEND "pulseaudio" CACHE STRING "Which audio backends should be built?") -ENDIF() - SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix, default is /usr/local (UNIX) and C:\\Program Files (Windows)") SET(COMPILE_LIGHTSPARK TRUE CACHE BOOL "Compile Lightspark?") SET(COMPILE_TIGHTSPARK TRUE CACHE BOOL "Compile Tightspark?") @@ -293,10 +286,6 @@ SET(EXTRA_LIBS_LIBRARIES ${EXTRA_LIBS_LIBRARIES} ws2_32.lib imagehlp.lib) ENDIF(WIN32) -IF(AUDIO_BACKEND) - ADD_DEFINITIONS(-DAUDIO_BACKEND="${AUDIO_BACKEND}") -ENDIF(AUDIO_BACKEND) - IF(ENABLE_LIBAVCODEC) pkg_check_modules(FFMPEG libavcodec libavutil libavformat) pkg_check_modules(LIBAVRESAMPLE libavresample) @@ -384,7 +373,8 @@ pkg_check_modules(GMODULE REQUIRED gmodule-2.0) pkg_check_modules(GLIBMM REQUIRED glibmm-2.4) INCLUDE_DIRECTORIES(${GLIBMM_INCLUDE_DIRS}) -pkg_check_modules(GTK REQUIRED gtk+-2.0) +pkg_check_modules(SDL2 REQUIRED sdl2) +pkg_check_modules(SDL2MIXER REQUIRED SDL2_mixer) IF(GLIBMM_FOUND AND NOT(GLIBMM_VERSION VERSION_LESS 2.31.0)) ADD_DEFINITIONS(-DHAVE_NEW_GLIBMM_THREAD_API) @@ -409,7 +399,8 @@ INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CAIRO_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${SDL2MIXER_INCLUDE_DIRS}) IF(ENABLE_LIBAVCODEC) INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
View file
lightspark.tar.xz/ChangeLog
Changed
@@ -2,6 +2,11 @@ Version NEXT: + * switch to SDL2/SDL2_mixer for everything except Firefox plugin. + - the plugin uses gtk2 to interact with Firefox, so the gtk2 dependency is only needed when building the Firefox plugin + - removes audio plugins as audio is now handled via SDL2_mixer for all platforms. + - removes the pulseaudio dependency + - the configuration setting [audio] is no longer needed * implement rendering of embedded fonts in TextFields * fix handling of multiple streams in SDL audio plugin, adds dependency on sdl_mixer * switch to internal xml parsing (based on pugixml), removes dependency on libxml++
View file
lightspark.tar.xz/README
Changed
@@ -12,10 +12,10 @@ To compile this software you need to install development packages for llvm (version 2.8 or >= 3.0), opengl, curl, zlib, libavcodec, libavresample libglew, pcre, librtmp, cairo, libboost-filesystem, -gtk-2, libjpeg, libavformat, pango, liblzma +sdl2, sdl2_mixer, libjpeg, libavformat, pango, liblzma -If sound is enabled (on by default), you will also need the -development package for pulseaudio-libs and/or sdl_mixer. +If compiling the Firefox plugin is enabled (on by default), you will also need the +development package for gtk2. Install also cmake, nasm and gcc (version 4.6.0 or newer) or clang @@ -34,10 +34,6 @@ CMAKE_BUILD_TYPE available: Debug LeanDebug Release RelWithDebInfo Profile -Sound support may be disabled using the following option: --DENABLE_SOUND=0 The audio backend can be set using --DAUDIO_BACKEND=<pulseaudio|sdl> (default is pulseaudio) - EXECUTION =========
View file
lightspark.tar.xz/debian/control
Changed
@@ -2,7 +2,7 @@ Section: utils Priority: optional Maintainer: Alessandro Pignotti <a.pignotti@sssup.it> -Build-Depends: g++ (>=4.5), gnash, cmake, cdbs, nasm, debhelper (>= 7), llvm-dev, libgl1-mesa-dev, libxext-dev, libcurl4-gnutls-dev | libcurl4-openssl-dev, libxml2-dev, zlib1g-dev, libavcodec-dev, libpcre3-dev, libglew1.5-dev, libboost-filesystem-dev, libboost-system-dev, libxml++2.6-dev (>= 2.33.1), libcairo2-dev, libgtk2.0-dev, libjpeg8-dev, libavformat-dev, libavresample-dev, libpango1.0-dev, libpulse-dev, librtmp-dev, liblzma-dev, libfreetype6-dev, libpng-dev +Build-Depends: g++ (>=4.5), gnash, cmake, cdbs, nasm, debhelper (>= 7), llvm-dev, libgl1-mesa-dev, libxext-dev, libcurl4-gnutls-dev | libcurl4-openssl-dev, zlib1g-dev, libavcodec-dev, libpcre3-dev, libglew1.5-dev, libboost-filesystem-dev, libboost-system-dev, libcairo2-dev, libgtk2.0-dev, libjpeg8-dev, libavformat-dev, libavresample-dev, libpango1.0-dev, librtmp-dev, liblzma-dev, libfreetype6-dev, libpng-dev, libSDL2-dev, libSDL2-mixer-dev Standards-Version: 3.8.4 Homepage: http://lightspark.sf.net Vcs-git: git://github.com/alexp-sssup/lightspark.git
View file
lightspark.tar.xz/etc/xdg/lightspark.conf
Changed
@@ -2,10 +2,6 @@ # All values are case-sensitive # Non-existing entries default to their hard-coded default values -[audio] -# Audio backend to use, possible values: pulseaudio, sdl -backend = pulseaudio - [cache] # Directory where cached files are saved to directory = ~/.cache/lightspark
View file
lightspark.tar.xz/src/CMakeLists.txt
Changed
@@ -42,7 +42,6 @@ backends/image.cpp backends/input.cpp backends/netutils.cpp - backends/pluginmanager.cpp backends/rendering.cpp backends/rendering_context.cpp backends/rtmputils.cpp @@ -184,7 +183,7 @@ TARGET_LINK_LIBRARIES(spark ${CAIRO_LIBRARIES} ${ZLIB_LIBRARIES} ${Boost_LIBRARIES} ${LLVM_LIBS_CORE} ${LLVM_LIBS_JIT} ${LLVM_LDFLAGS} - ${OPTIONAL_LIBRARIES} ${GTK_LIBRARIES} ${FREETYPE_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} + ${OPTIONAL_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${FREETYPE_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${PCRE_LIBRARIES} ${GLIBMM_LIBRARIES} ${GMODULE_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_LIBS_LIBRARIES} ${X11_LIBRARIES}) @@ -207,7 +206,7 @@ TARGET_LINK_LIBRARIES(lightspark spark) #With STATICDEPS, all deps are compiled into spark IF(NOT STATICDEPS) - TARGET_LINK_LIBRARIES(lightspark ${Boost_LIBRARIES} ${X11_LIBRARIES} ${GTK_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTHREAD_LIBRARIES}) + TARGET_LINK_LIBRARIES(lightspark ${Boost_LIBRARIES} ${X11_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTHREAD_LIBRARIES}) ENDIF() PACK_EXECUTABLE(lightspark) @@ -237,4 +236,3 @@ ADD_SUBDIRECTORY(plugin) ENDIF(COMPILE_PLUGIN) -ADD_SUBDIRECTORY(backends/interfaces)
View file
lightspark.tar.xz/src/backends/audio.cpp
Changed
@@ -22,118 +22,175 @@ #include "backends/config.h" #include <iostream> #include "logger.h" +#include <SDL2/SDL_mixer.h> +#include <sys/time.h> -//Needed or not with compat.h and compat.cpp? -#ifdef _WIN32 -# include <windows.h> -#else -# include <dlfcn.h> -# include <sys/types.h> -#endif using namespace lightspark; using namespace std; -/**************** -AudioManager::AudioManager -***************** -It should search for a list of audio plugin lib files (liblightsparkAUDIOAPIplugin.so) -Then, it should read a config file containing the user's defined audio API choosen as audio backend -If no file or none selected - default to none -Else - Select and load the good audio plugin lib files -*****************/ - -AudioManager::AudioManager ( PluginManager *sharedPluginManager ) : - oAudioPlugin(NULL), selectedAudioBackend(""), pluginManager(sharedPluginManager) +void mixer_effect_ffmpeg_cb(int chan, void * stream, int len, void * udata) { -// string DesiredAudio = get_audioConfig(); //Looks for the audio selected in the user's config - string DesiredAudio = Config::getConfig()->getAudioBackendName(); - set_audiobackend ( DesiredAudio ); + AudioStream *s = (AudioStream*)udata; + if (!s) + return; + + uint32_t readcount = 0; + while (readcount < ((uint32_t)len)) + { + uint32_t ret = s->getDecoder()->copyFrame((int16_t *)(((unsigned char*)stream)+readcount), ((uint32_t)len)-readcount); + if (!ret) + break; + readcount += ret; + } } -bool AudioManager::pluginLoaded() const + +uint32_t AudioStream::getPlayedTime() { - return oAudioPlugin != NULL; -} + uint32_t ret; + struct timeval now; + gettimeofday(&now, NULL); -AudioStream *AudioManager::createStreamPlugin (AudioDecoder *decoder , bool startpaused) + ret = playedtime + (now.tv_sec * 1000 + now.tv_usec / 1000) - (starttime.tv_sec * 1000 + starttime.tv_usec / 1000); + return ret; +} +bool AudioStream::init() { - if ( pluginLoaded() ) - { - AudioStream * res = oAudioPlugin->createStream ( decoder ); - if (startpaused) - res->pause(); - else - res->hasStarted=true; - return res; - } - else - { - LOG ( LOG_ERROR, _ ( "No audio plugin loaded, can't create stream" ) ); - return NULL; - } + unmutevolume = curvolume = SDL_MIX_MAXVOLUME; + playedtime = 0; + gettimeofday(&starttime, NULL); + mixer_channel = -1; + + uint32_t len = LIGHTSPARK_AUDIO_SDL_BUFFERSIZE; + + uint8_t *buf = new uint8_t[len]; + memset(buf,0,len); + Mix_Chunk* chunk = Mix_QuickLoad_RAW(buf, len); + + + mixer_channel = Mix_PlayChannel(-1, chunk, -1); + Mix_RegisterEffect(mixer_channel, mixer_effect_ffmpeg_cb, NULL, this); + Mix_Resume(mixer_channel); + + return true; } -bool AudioManager::isTimingAvailablePlugin() const +void AudioStream::SetPause(bool pause_on) { - if ( pluginLoaded() ) + if (pause_on) { - return oAudioPlugin->isTimingAvailable(); + playedtime = getPlayedTime(); + if (mixer_channel != -1) + Mix_Pause(mixer_channel); } else { - LOG ( LOG_ERROR, _ ( "isTimingAvailablePlugin: No audio plugin loaded" ) ); - return false; + gettimeofday(&starttime, NULL); + if (mixer_channel != -1) + Mix_Resume(mixer_channel); } } -void AudioManager::set_audiobackend ( string desired_backend ) +bool AudioStream::ispaused() { - if ( selectedAudioBackend != desired_backend ) //Load the desired backend only if it's not already loaded - { - load_audioplugin ( desired_backend ); - selectedAudioBackend = desired_backend; - } + return Mix_Paused(mixer_channel); } -void AudioManager::get_audioBackendsList() +void AudioStream::mute() +{ + unmutevolume = curvolume; + curvolume = 0; +} +void AudioStream::unmute() { - audioplugins_list = pluginManager->get_backendsList ( AUDIO ); + curvolume = unmutevolume; +} +void AudioStream::setVolume(double volume) +{ + curvolume = SDL_MIX_MAXVOLUME * volume; + if (mixer_channel != -1) + Mix_Volume(mixer_channel, curvolume); } -void AudioManager::refresh_audioplugins_list() +AudioStream::~AudioStream() { - audioplugins_list.clear(); - get_audioBackendsList(); + manager->streams.remove(this); + if (mixer_channel != -1) + Mix_HaltChannel(mixer_channel); } -void AudioManager::release_audioplugin() +AudioManager::AudioManager():muteAllStreams(false),sdl_available(0),mixeropened(0) +{ + sdl_available = 0; + if (SDL_WasInit(0)) // some part of SDL already was initialized + sdl_available = !SDL_InitSubSystem ( SDL_INIT_AUDIO ); + else + sdl_available = !SDL_Init ( SDL_INIT_AUDIO ); + mixeropened = 0; +} +void AudioManager::muteAll() { - if ( pluginLoaded() ) + muteAllStreams = true; + for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) { - pluginManager->release_plugin ( oAudioPlugin ); + (*it)->mute(); + } +} +void AudioManager::unmuteAll() +{ + muteAllStreams = false; + for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) + { + (*it)->unmute(); } } -void AudioManager::load_audioplugin ( string selected_backend ) +AudioStream* AudioManager::createStream(AudioDecoder* decoder, bool startpaused) { - LOG ( LOG_INFO, _ ( ( ( string ) ( "the selected backend is: " + selected_backend ) ).c_str() ) ); - release_audioplugin(); - oAudioPlugin = static_cast<IAudioPlugin *> ( pluginManager->get_plugin ( selected_backend ) ); + if (!sdl_available) + return NULL; + if (!mixeropened) + { + if (Mix_OpenAudio (LIGHTSPARK_AUDIO_SDL_SAMPLERATE, AUDIO_S16, 2, LIGHTSPARK_AUDIO_SDL_BUFFERSIZE) < 0) + { + LOG(LOG_ERROR,"Couldn't open SDL_mixer"); + sdl_available = 0; + return NULL; + } + mixeropened = 1; + } - if ( !pluginLoaded() ) + AudioStream *stream = new AudioStream(this); + stream->decoder = decoder; + if (!stream->init()) { - LOG ( LOG_INFO, _ ( "Could not load the audiobackend" ) ); + delete stream; + return NULL; } + if (startpaused) + stream->pause(); + else + stream->hasStarted=true; + streams.push_back(stream); + + return stream; } -/************************** -stop AudioManager -***************************/ + AudioManager::~AudioManager() { - release_audioplugin(); - pluginManager = NULL; //The plugin manager is not deleted since it's been created outside of the audio manager + for (stream_iterator it = streams.begin(); it != streams.end(); ++it) { + delete *it; + } + if (mixeropened) + { + Mix_CloseAudio(); + } + if (sdl_available) + { + SDL_QuitSubSystem ( SDL_INIT_AUDIO ); + if (!SDL_WasInit(0)) + SDL_Quit (); + } }
View file
lightspark.tar.xz/src/backends/audio.h
Changed
@@ -25,46 +25,67 @@ #include "backends/decoder.h" #include <iostream> -#include "backends/pluginmanager.h" -#include "backends/interfaces/audio/IAudioPlugin.h" - - -//convenience typedef for the pointers to the 2 functions we expect to find in the plugin libraries -typedef IPlugin * ( *PLUGIN_FACTORY ) (); -typedef void ( *PLUGIN_CLEANUP ) ( IPlugin * ); - namespace lightspark { +#define LIGHTSPARK_AUDIO_SDL_BUFFERSIZE 4096 +#define LIGHTSPARK_AUDIO_SDL_SAMPLERATE 44100 + +class AudioStream; class AudioManager { + friend class AudioStream; private: - std::vector<std::string *>audioplugins_list; - IAudioPlugin *oAudioPlugin; - std::string selectedAudioBackend; - void load_audioplugin ( std::string selected_backend ); - void release_audioplugin(); - PluginManager *pluginManager; - + bool muteAllStreams; + int sdl_available; + int mixeropened; + std::list<AudioStream *> streams; + typedef std::list<AudioStream *>::iterator stream_iterator; public: - AudioManager ( PluginManager *sharePluginManager ); - bool pluginLoaded() const; - AudioStream *createStreamPlugin ( AudioDecoder *decoder, bool startpaused ); - bool isTimingAvailablePlugin() const; - void set_audiobackend ( std::string desired_backend ); - void get_audioBackendsList(); - void refresh_audioplugins_list(); - - void muteAll() { oAudioPlugin->muteAll(); } - void unmuteAll() { oAudioPlugin->unmuteAll(); } - void toggleMuteAll() { oAudioPlugin->toggleMuteAll(); } - bool allMuted() { return oAudioPlugin->allMuted(); } - int forcedSampleRate() const { return oAudioPlugin->forcedSampleRate();} - int forcedChannelLayout() const { return oAudioPlugin->forcedChannelLayout();} + AudioManager(); + + AudioStream *createStream(AudioDecoder *decoder, bool startpaused); + + void toggleMuteAll() { muteAllStreams ? unmuteAll() : muteAll(); } + bool allMuted() { return muteAllStreams; } + void muteAll(); + void unmuteAll(); + int forcedSampleRate() const { return LIGHTSPARK_AUDIO_SDL_SAMPLERATE;} + int forcedChannelLayout() const { return AV_CH_LAYOUT_STEREO;} ~AudioManager(); }; +class AudioStream +{ +friend class AudioManager; +friend class NetStream; +private: + AudioManager* manager; + AudioDecoder *decoder; + bool hasStarted; + int curvolume; + int unmutevolume; + uint32_t playedtime; + struct timeval starttime; + int mixer_channel; +public: + bool init(); + AudioStream(AudioManager* _manager):manager(_manager),decoder(NULL),hasStarted(false) { } + + void SetPause(bool pause_on); + uint32_t getPlayedTime(); + bool ispaused(); + void mute(); + void unmute(); + void pause() { SetPause(true); } + void resume() { SetPause(false); } + void setVolume(double volume); + inline AudioDecoder *getDecoder() const { return decoder; } + ~AudioStream(); }; + +} + #endif /* BACKENDS_AUDIO_H */
View file
lightspark.tar.xz/src/backends/config.cpp
Changed
@@ -84,7 +84,6 @@ //DEFAULT SETTINGS defaultCacheDirectory((string) g_get_user_cache_dir() + "/lightspark"), cacheDirectory(defaultCacheDirectory),cachePrefix("cache"), - audioBackend(INVALID),audioBackendName(""), renderingEnabled(true) { #ifdef _WIN32 @@ -92,9 +91,6 @@ if(exePath) userConfigDirectory = exePath; #endif - audioBackendNames[PULSEAUDIO] = "pulseaudio"; - audioBackendNames[SDL] = "sdl"; - audioBackendNames[WINMM] = "winmm"; //Try system configs first string sysDir; @@ -141,18 +137,6 @@ } } - /* If no audio backend was specified, use a default */ - if(audioBackend == INVALID) - { -#ifdef _WIN32 - audioBackend = WINMM; -#else - audioBackend = PULSEAUDIO; -#endif - } - //Set the audio backend name - audioBackendName = audioBackendNames[audioBackend]; - #ifdef _WIN32 std::string regGnashPath = readRegistryEntry("GnashPath"); if(regGnashPath.empty()) @@ -202,15 +186,8 @@ string group = parser->getGroup(); string key = parser->getKey(); string value = parser->getValue(); - //Audio backend - if(group == "audio" && key == "backend" && value == audioBackendNames[PULSEAUDIO]) - audioBackend = PULSEAUDIO; - else if(group == "audio" && key == "backend" && value == audioBackendNames[SDL]) - audioBackend = SDL; - else if(group == "audio" && key == "backend" && value == audioBackendNames[WINMM]) - audioBackend = WINMM; //Rendering - else if(group == "rendering" && key == "enabled") + if(group == "rendering" && key == "enabled") renderingEnabled = atoi(value.c_str()); //Cache directory else if(group == "cache" && key == "directory") @@ -219,5 +196,5 @@ else if(group == "cache" && key == "prefix") cachePrefix = value; else - throw ConfigException((string) _("Invalid entry encountered in configuration file") + ": '" + group + "/" + key + "'='" + value + "'"); + LOG(LOG_ERROR,_("Invalid entry encountered in configuration file") << ": '" << group << "/" << key << "'='" << value << "'"); }
View file
lightspark.tar.xz/src/backends/config.h
Changed
@@ -36,10 +36,6 @@ const char* const* systemConfigDirectories; std::string userConfigDirectory; - //-- SETTINGS VALUES - enum AUDIOBACKEND { PULSEAUDIO=0, SDL, WINMM, NUM_AUDIO_BACKENDS, INVALID=1024 }; - std::string audioBackendNames[NUM_AUDIO_BACKENDS]; - //-- SETTINGS //Specifies the default cache directory = "~/.cache/lightspark" std::string defaultCacheDirectory; @@ -50,10 +46,6 @@ //Specifies the filename including full path of the gnash executable std::string gnashPath; - //Specifies what audio backend should, default=PULSEAUDIO - AUDIOBACKEND audioBackend; - std::string audioBackendName; - //Specifies if rendering should be done bool renderingEnabled; Config(); @@ -66,9 +58,6 @@ const std::string& getCachePrefix() const { return cachePrefix; } const std::string& getGnashPath() const { return gnashPath; } - AUDIOBACKEND getAudioBackend() const { return audioBackend; } - const std::string& getAudioBackendName() const { return audioBackendName; } - bool isRenderingEnabled() const { return renderingEnabled; } }; }
View file
lightspark.tar.xz/src/backends/graphics.cpp
Changed
@@ -28,6 +28,7 @@ #include "compat.h" #include "scripting/flash/text/flashtext.h" #include "scripting/flash/display/BitmapData.h" +#include <pango/pangocairo.h> using namespace lightspark;
View file
lightspark.tar.xz/src/backends/input.cpp
Changed
@@ -24,11 +24,8 @@ #include "compat.h" #include "scripting/flash/ui/keycodes.h" -#if GTK_CHECK_VERSION (2,21,8) -#include <gdk/gdkkeysyms-compat.h> -#else -#include <gdk/gdkkeysyms.h> -#endif +#include <SDL2/SDL_keyboard.h> +#include <SDL2/SDL_clipboard.h> using namespace lightspark; using namespace std; @@ -42,15 +39,11 @@ void InputThread::start(EngineData* e) { - initKeyTable(); engineData = e; - engineData->setInputHandler(sigc::mem_fun(this, &InputThread::worker)); } InputThread::~InputThread() { - if(engineData) - engineData->removeInputHandler(); wait(); } @@ -63,15 +56,12 @@ terminated=true; } -//This is guarded gdk_threads_enter/leave -bool InputThread::worker(GdkEvent *event) +bool InputThread::worker(SDL_Event *event) { - //Set sys to this SystemState - setTLSSys(m_sys); gboolean ret=FALSE; switch(event->type) { - case GDK_KEY_PRESS: + case SDL_KEYDOWN: { bool handled = handleKeyboardShortcuts(&event->key); if (!handled) @@ -79,78 +69,60 @@ ret=TRUE; break; } - case GDK_KEY_RELEASE: + case SDL_KEYUP: { sendKeyEvent(&event->key); ret=TRUE; break; } - case GDK_EXPOSE: + case SDL_MOUSEBUTTONDOWN: { - //Signal the renderThread - m_sys->getRenderThread()->draw(false); - ret=TRUE; - break; - } - case GDK_BUTTON_PRESS: - { - if(event->button.button == 1) + if(event->button.button == SDL_BUTTON_LEFT) { //Grab focus, to receive keypresses engineData->grabFocus(); int stageX, stageY; m_sys->windowToStageCoordinates(event->button.x,event->button.y,stageX,stageY); - handleMouseDown(stageX,stageY,event->button.state); + if (event->button.clicks == 1) + handleMouseDown(stageX,stageY,SDL_GetModState(),event->button.state == SDL_PRESSED); + if (event->button.clicks == 2) + handleMouseDoubleClick(stageX,stageY,SDL_GetModState(),event->button.state == SDL_PRESSED); } ret=TRUE; break; } - case GDK_2BUTTON_PRESS: - { - if(event->button.button == 1) - { - int stageX, stageY; - m_sys->windowToStageCoordinates(event->button.x,event->button.y,stageX,stageY); - handleMouseDoubleClick(stageX,stageY,event->button.state); - } - ret=TRUE; - break; - } - case GDK_BUTTON_RELEASE: + case SDL_MOUSEBUTTONUP: { int stageX, stageY; m_sys->windowToStageCoordinates(event->button.x,event->button.y,stageX,stageY); - handleMouseUp(stageX,stageY,event->button.state); + handleMouseUp(stageX,stageY,SDL_GetModState(),event->button.state == SDL_PRESSED); ret=TRUE; break; } - case GDK_MOTION_NOTIFY: + case SDL_MOUSEMOTION: { int stageX, stageY; m_sys->windowToStageCoordinates(event->motion.x,event->motion.y,stageX,stageY); - handleMouseMove(stageX,stageY,event->button.state); + handleMouseMove(stageX,stageY,SDL_GetModState(),event->motion.state == SDL_PRESSED); ret=TRUE; break; } - case GDK_SCROLL: + case SDL_MOUSEWHEEL: { int stageX, stageY; - m_sys->windowToStageCoordinates(event->scroll.x,event->scroll.y,stageX,stageY); - handleScrollEvent(stageX,stageY,event->scroll.direction,event->scroll.state); + m_sys->windowToStageCoordinates(event->wheel.x,event->wheel.y,stageX,stageY); + handleScrollEvent(stageX,stageY,event->wheel.direction,SDL_GetModState(),false); ret=TRUE; break; } - case GDK_LEAVE_NOTIFY: + case SDL_WINDOWEVENT_LEAVE: { handleMouseLeave(); ret=TRUE; break; } default: -//#ifdef EXPENSIVE_DEBUG -// LOG(LOG_INFO, "GDKTYPE " << event->type); -//#endif break; } return ret; @@ -179,7 +151,7 @@ return selected; } -void InputThread::handleMouseDown(uint32_t x, uint32_t y, unsigned int buttonState) +void InputThread::handleMouseDown(uint32_t x, uint32_t y, SDL_Keymod buttonState, bool pressed) { if(m_sys->currentVm == NULL) return; @@ -188,11 +160,11 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseDown",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseDown",localX,localY,true,buttonState,pressed))); lastMouseDownTarget=selected; } -void InputThread::handleMouseDoubleClick(uint32_t x, uint32_t y, unsigned int buttonState) +void InputThread::handleMouseDoubleClick(uint32_t x, uint32_t y, SDL_Keymod buttonState, bool pressed) { if(m_sys->currentVm == NULL) return; @@ -201,10 +173,10 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"doubleClick",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"doubleClick",localX,localY,true,buttonState,pressed))); } -void InputThread::handleMouseUp(uint32_t x, uint32_t y, unsigned int buttonState) +void InputThread::handleMouseUp(uint32_t x, uint32_t y, SDL_Keymod buttonState, bool pressed) { if(m_sys->currentVm == NULL) return; @@ -213,17 +185,17 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseUp",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseUp",localX,localY,true,buttonState,pressed))); if(lastMouseDownTarget==selected) { //Also send the click event m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"click",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"click",localX,localY,true,buttonState,pressed))); } lastMouseDownTarget=NullRef; } -void InputThread::handleMouseMove(uint32_t x, uint32_t y, unsigned int buttonState) +void InputThread::handleMouseMove(uint32_t x, uint32_t y, SDL_Keymod buttonState, bool pressed) { if(m_sys->currentVm == NULL) return; @@ -256,7 +228,7 @@ selected->globalToLocal(x,y,localX,localY); if(currentMouseOver == selected) m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseMove",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseMove",localX,localY,true,buttonState,pressed))); else { if(!currentMouseOver.isNull()) @@ -264,28 +236,28 @@ number_t clocalX, clocalY; currentMouseOver->globalToLocal(x,y,clocalX,clocalY); m_sys->currentVm->addEvent(currentMouseOver, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOut",clocalX,clocalY,true,buttonState,selected))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOut",clocalX,clocalY,true,buttonState,pressed,selected))); m_sys->currentVm->addEvent(currentMouseOver, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOut",clocalX,clocalY,true,buttonState,selected))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOut",clocalX,clocalY,true,buttonState,pressed,selected))); } m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOver",localX,localY,true,buttonState,currentMouseOver))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOver",localX,localY,true,buttonState,pressed,currentMouseOver))); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOver",localX,localY,true,buttonState,currentMouseOver))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOver",localX,localY,true,buttonState,pressed,currentMouseOver))); currentMouseOver = selected; } } } -void InputThread::handleScrollEvent(uint32_t x, uint32_t y, GdkScrollDirection direction, unsigned int buttonState) +void InputThread::handleScrollEvent(uint32_t x, uint32_t y, uint32_t direction, SDL_Keymod buttonState,bool pressed) { if(m_sys->currentVm == NULL) return; int delta; - if(direction==GDK_SCROLL_UP) + if(direction==SDL_MOUSEWHEEL_NORMAL) delta = 1; - else if(direction==GDK_SCROLL_DOWN) + else if(direction==SDL_MOUSEWHEEL_FLIPPED) delta = -1; else return; @@ -295,7 +267,7 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseWheel",localX,localY,true,buttonState,NullRef,delta))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseWheel",localX,localY,true,buttonState,pressed,NullRef,delta))); } void InputThread::handleMouseLeave() @@ -309,83 +281,40 @@ _MR(Class<Event>::getInstanceS(m_sys,"mouseLeave"))); } -void InputThread::initKeyTable() -{ - int i = 0; - while (hardwareKeycodes[i].keyname) - { - // Map GDK keyvals to hardware keycodes. - // - // NOTE: The keycodes returned by GDK are different - // from the keycodes in the Flash documentation. - // Should add mapping from GDK codes to Flash codes - // for AS files that use raw numerical values instead - // of Keyboard.* constants. - GdkKeymapKey *keys; - int keys_len; - const char *keyname = hardwareKeycodes[i].keyname; - unsigned keyval = hardwareKeycodes[i].gdkKeyval; - if (gdk_keymap_get_entries_for_keyval(NULL, keyval, &keys, &keys_len)) - { - KeyNameCodePair key; - key.keyname = keyname; - key.keycode = keys[0].keycode; - keyNamesAndCodes.push_back(key); - g_free(keys); - } - - i++; - } -} - -const std::vector<KeyNameCodePair>& InputThread::getKeyNamesAndCodes() -{ - // No locking needed, because keyNamesAndCodes is not modified - // after being initialized - return keyNamesAndCodes; -} - -bool InputThread::handleKeyboardShortcuts(const GdkEventKey *keyevent) +bool InputThread::handleKeyboardShortcuts(const SDL_KeyboardEvent *keyevent) { bool handled = false; - if ((keyevent->state & GDK_CONTROL_MASK) != GDK_CONTROL_MASK) + if (!(keyevent->keysym.mod & KMOD_CTRL)) return handled; - switch(keyevent->keyval) + switch(keyevent->keysym.sym) { - case GDK_q: + case SDLK_q: handled = true; if(m_sys->standalone) m_sys->setShutdownFlag(); break; - case GDK_p: + case SDLK_p: handled = true; m_sys->showProfilingData=!m_sys->showProfilingData; break; - case GDK_m: + case SDLK_m: handled = true; - if (!m_sys->audioManager->pluginLoaded()) - break; m_sys->audioManager->toggleMuteAll(); if(m_sys->audioManager->allMuted()) LOG(LOG_INFO, "All sounds muted"); else LOG(LOG_INFO, "All sounds unmuted"); break; - case GDK_c: + case SDLK_c: handled = true; if(m_sys->hasError()) { - GtkClipboard *clipboard; - clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); std::string s = "SWF file: "; s.append(m_sys->mainClip->getOrigin().getParsedURL()); s.append("\n"); s.append(m_sys->getErrorCause()); - gtk_clipboard_set_text(clipboard, s.c_str(),s.size()); - clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); - gtk_clipboard_set_text(clipboard, s.c_str(), s.size()); - LOG(LOG_INFO, "Copied error to clipboard"); + engineData->setClipboardText(s); } else LOG(LOG_INFO, "No error to be copied to clipboard"); @@ -397,7 +326,151 @@ return handled; } -void InputThread::sendKeyEvent(const GdkEventKey *keyevent) +AS3KeyCode getAS3KeyCode(SDL_Keycode sdlkey) +{ + switch (sdlkey) + { + case SDLK_RETURN: return AS3KEYCODE_ENTER; + case SDLK_ESCAPE: return AS3KEYCODE_ESCAPE; + case SDLK_BACKSPACE: return AS3KEYCODE_BACKSPACE; + case SDLK_TAB: return AS3KEYCODE_TAB; + case SDLK_SPACE: return AS3KEYCODE_SPACE; + case SDLK_QUOTE: return AS3KEYCODE_QUOTE; + case SDLK_COMMA: return AS3KEYCODE_COMMA; + case SDLK_MINUS: return AS3KEYCODE_MINUS; + case SDLK_PERIOD: return AS3KEYCODE_PERIOD; + case SDLK_SLASH: return AS3KEYCODE_SLASH; + case SDLK_0: return AS3KEYCODE_NUMBER_0; + case SDLK_1: return AS3KEYCODE_NUMBER_1; + case SDLK_2: return AS3KEYCODE_NUMBER_2; + case SDLK_3: return AS3KEYCODE_NUMBER_3; + case SDLK_4: return AS3KEYCODE_NUMBER_4; + case SDLK_5: return AS3KEYCODE_NUMBER_5; + case SDLK_6: return AS3KEYCODE_NUMBER_6; + case SDLK_7: return AS3KEYCODE_NUMBER_7; + case SDLK_8: return AS3KEYCODE_NUMBER_8; + case SDLK_9: return AS3KEYCODE_NUMBER_9; + case SDLK_COLON: return AS3KEYCODE_PERIOD; + case SDLK_SEMICOLON: return AS3KEYCODE_SEMICOLON; + case SDLK_EQUALS: return AS3KEYCODE_EQUAL; + case SDLK_LEFTBRACKET: return AS3KEYCODE_LEFTBRACKET; + case SDLK_BACKSLASH: return AS3KEYCODE_BACKSLASH; + case SDLK_RIGHTBRACKET: return AS3KEYCODE_RIGHTBRACKET; + case SDLK_BACKQUOTE: return AS3KEYCODE_BACKQUOTE; + case SDLK_a: return AS3KEYCODE_A; + case SDLK_b: return AS3KEYCODE_B; + case SDLK_c: return AS3KEYCODE_C; + case SDLK_d: return AS3KEYCODE_D; + case SDLK_e: return AS3KEYCODE_E; + case SDLK_f: return AS3KEYCODE_F; + case SDLK_g: return AS3KEYCODE_G; + case SDLK_h: return AS3KEYCODE_H; + case SDLK_i: return AS3KEYCODE_I; + case SDLK_j: return AS3KEYCODE_J; + case SDLK_k: return AS3KEYCODE_K; + case SDLK_l: return AS3KEYCODE_L; + case SDLK_m: return AS3KEYCODE_M; + case SDLK_n: return AS3KEYCODE_N; + case SDLK_o: return AS3KEYCODE_O; + case SDLK_p: return AS3KEYCODE_P; + case SDLK_q: return AS3KEYCODE_Q; + case SDLK_r: return AS3KEYCODE_R; + case SDLK_s: return AS3KEYCODE_S; + case SDLK_t: return AS3KEYCODE_T; + case SDLK_u: return AS3KEYCODE_U; + case SDLK_v: return AS3KEYCODE_V; + case SDLK_w: return AS3KEYCODE_W; + case SDLK_x: return AS3KEYCODE_X; + case SDLK_y: return AS3KEYCODE_Y; + case SDLK_z: return AS3KEYCODE_Z; + case SDLK_CAPSLOCK:return AS3KEYCODE_CAPS_LOCK; + case SDLK_F1: return AS3KEYCODE_F1; + case SDLK_F2: return AS3KEYCODE_F2; + case SDLK_F3: return AS3KEYCODE_F3; + case SDLK_F4: return AS3KEYCODE_F4; + case SDLK_F5: return AS3KEYCODE_F5; + case SDLK_F6: return AS3KEYCODE_F6; + case SDLK_F7: return AS3KEYCODE_F7; + case SDLK_F8: return AS3KEYCODE_F8; + case SDLK_F9: return AS3KEYCODE_F9; + case SDLK_F10: return AS3KEYCODE_F10; + case SDLK_F11: return AS3KEYCODE_F11; + case SDLK_F12: return AS3KEYCODE_F12; + case SDLK_PAUSE: return AS3KEYCODE_PAUSE; + case SDLK_INSERT: return AS3KEYCODE_INSERT; + case SDLK_HOME: return AS3KEYCODE_HOME; + case SDLK_PAGEUP: return AS3KEYCODE_PAGE_UP; + case SDLK_DELETE: return AS3KEYCODE_DELETE; + case SDLK_END: return AS3KEYCODE_END; + case SDLK_PAGEDOWN: return AS3KEYCODE_PAGE_DOWN; + case SDLK_RIGHT: return AS3KEYCODE_RIGHT; + case SDLK_LEFT: return AS3KEYCODE_LEFT; + case SDLK_DOWN: return AS3KEYCODE_DOWN; + case SDLK_UP: return AS3KEYCODE_UP; + case SDLK_NUMLOCKCLEAR: return AS3KEYCODE_NUMPAD; + case SDLK_KP_DIVIDE: return AS3KEYCODE_NUMPAD_DIVIDE; + case SDLK_KP_MULTIPLY: return AS3KEYCODE_NUMPAD_MULTIPLY; + case SDLK_KP_MINUS:return AS3KEYCODE_NUMPAD_SUBTRACT; + case SDLK_KP_PLUS: return AS3KEYCODE_NUMPAD_ADD; + case SDLK_KP_ENTER: return AS3KEYCODE_NUMPAD_ENTER; + case SDLK_KP_1: return AS3KEYCODE_NUMPAD_1; + case SDLK_KP_2: return AS3KEYCODE_NUMPAD_2; + case SDLK_KP_3: return AS3KEYCODE_NUMPAD_3; + case SDLK_KP_4: return AS3KEYCODE_NUMPAD_4; + case SDLK_KP_5: return AS3KEYCODE_NUMPAD_5; + case SDLK_KP_6: return AS3KEYCODE_NUMPAD_6; + case SDLK_KP_7: return AS3KEYCODE_NUMPAD_7; + case SDLK_KP_8: return AS3KEYCODE_NUMPAD_8; + case SDLK_KP_9: return AS3KEYCODE_NUMPAD_9; + case SDLK_KP_0: return AS3KEYCODE_NUMPAD_0; + case SDLK_KP_PERIOD: return AS3KEYCODE_NUMPAD_DECIMAL; + case SDLK_F13: return AS3KEYCODE_F13; + case SDLK_F14: return AS3KEYCODE_F14; + case SDLK_F15: return AS3KEYCODE_F15; + case SDLK_HELP: return AS3KEYCODE_HELP; + case SDLK_MENU: return AS3KEYCODE_MENU; + case SDLK_LCTRL: return AS3KEYCODE_CONTROL; + case SDLK_LSHIFT: return AS3KEYCODE_SHIFT; + case SDLK_LALT: return AS3KEYCODE_ALTERNATE; + case SDLK_RCTRL: return AS3KEYCODE_CONTROL; + case SDLK_RSHIFT: return AS3KEYCODE_SHIFT; + case SDLK_RALT: return AS3KEYCODE_ALTERNATE; + case SDLK_AC_SEARCH: return AS3KEYCODE_SEARCH; + case SDLK_AC_BACK: return AS3KEYCODE_BACK ; + case SDLK_AC_STOP:return AS3KEYCODE_STOP; + } + //AS3KEYCODE_AUDIO + //AS3KEYCODE_BLUE + //AS3KEYCODE_YELLOW + //AS3KEYCODE_CHANNEL_DOWN + //AS3KEYCODE_CHANNEL_UP + //AS3KEYCODE_COMMAND + //AS3KEYCODE_DVR + //AS3KEYCODE_EXIT + //AS3KEYCODE_FAST_FORWARD + //AS3KEYCODE_GREEN + //AS3KEYCODE_GUIDE + //AS3KEYCODE_INFO + //AS3KEYCODE_INPUT + //AS3KEYCODE_LAST + //AS3KEYCODE_LIVE + //AS3KEYCODE_MASTER_SHELL + //AS3KEYCODE_NEXT + //AS3KEYCODE_PLAY + //AS3KEYCODE_PREVIOUS + //AS3KEYCODE_RECORD + //AS3KEYCODE_RED + //AS3KEYCODE_REWIND + //AS3KEYCODE_SETUP + //AS3KEYCODE_SKIP_BACKWARD + //AS3KEYCODE_SKIP_FORWARD + //AS3KEYCODE_SUBTITLE + //AS3KEYCODE_VOD + return AS3KEYCODE_UNKNOWN; +} + + +void InputThread::sendKeyEvent(const SDL_KeyboardEvent *keyevent) { if(m_sys->currentVm == NULL) return; @@ -409,18 +482,15 @@ return; tiny_string type; - if (keyevent->type == GDK_KEY_PRESS) + if (keyevent->type == SDL_KEYDOWN) type = "keyDown"; else type = "keyUp"; - uint32_t charcode = keyevent->keyval; - if (keyevent->is_modifier) - charcode = 0; - target->incRef(); + AS3KeyCode c = getAS3KeyCode(keyevent->keysym.sym); m_sys->currentVm->addEvent(target, - _MR(Class<KeyboardEvent>::getInstanceS(m_sys,type, charcode, keyevent->hardware_keycode, keyevent->state))); + _MR(Class<KeyboardEvent>::getInstanceS(m_sys,type,c,c, (SDL_Keymod)keyevent->keysym.mod))); } void InputThread::addListener(InteractiveObject* ob)
View file
lightspark.tar.xz/src/backends/input.h
Changed
@@ -39,11 +39,6 @@ class Sprite; class MouseEvent; -struct KeyNameCodePair { - const char *keyname; - unsigned int keycode; -}; - class InputThread { private: @@ -52,14 +47,13 @@ Thread* t; bool terminated; bool threaded; - bool worker(GdkEvent *event); + // this is called from mainloopthread + bool worker(SDL_Event *event); std::vector<InteractiveObject* > listeners; Mutex mutexListeners; Mutex mutexDragged; - std::vector<KeyNameCodePair> keyNamesAndCodes; - _NR<Sprite> curDragged; _NR<InteractiveObject> currentMouseOver; _NR<InteractiveObject> lastMouseDownTarget; @@ -73,16 +67,15 @@ MaskData(DisplayObject* _d, const MATRIX& _m):d(_d),m(_m){} }; _NR<InteractiveObject> getMouseTarget(uint32_t x, uint32_t y, DisplayObject::HIT_TYPE type); - void handleMouseDown(uint32_t x, uint32_t y, unsigned int buttonState); - void handleMouseDoubleClick(uint32_t x, uint32_t y, unsigned int buttonState); - void handleMouseUp(uint32_t x, uint32_t y, unsigned int buttonState); - void handleMouseMove(uint32_t x, uint32_t y, unsigned int buttonState); - void handleScrollEvent(uint32_t x, uint32_t y, GdkScrollDirection direction, unsigned int buttonState); - void handleMouseLeave(); + void handleMouseDown(uint32_t x, uint32_t y, SDL_Keymod buttonState,bool pressed); + void handleMouseDoubleClick(uint32_t x, uint32_t y, SDL_Keymod buttonState,bool pressed); + void handleMouseUp(uint32_t x, uint32_t y, SDL_Keymod buttonState,bool pressed); + void handleMouseMove(uint32_t x, uint32_t y, SDL_Keymod buttonState,bool pressed); + void handleScrollEvent(uint32_t x, uint32_t y, uint32_t direction, SDL_Keymod buttonState,bool pressed); + void handleMouseLeave(); - void initKeyTable(); - bool handleKeyboardShortcuts(const GdkEventKey *keyevent); - void sendKeyEvent(const GdkEventKey *keyevent); + bool handleKeyboardShortcuts(const SDL_KeyboardEvent *keyevent); + void sendKeyEvent(const SDL_KeyboardEvent *keyevent); Spinlock inputDataSpinlock; Vector2 mousePos; @@ -95,13 +88,16 @@ void removeListener(InteractiveObject* ob); void startDrag(_R<Sprite> s, const RECT* limit, Vector2f dragOffset); void stopDrag(Sprite* s); - const std::vector<KeyNameCodePair>& getKeyNamesAndCodes(); Vector2 getMousePos() { SpinlockLocker locker(inputDataSpinlock); return mousePos; } + bool handleEvent(SDL_Event *event) + { + return worker(event); + } }; };
View file
lightspark.tar.xz/src/backends/interfaces
Deleted
-(directory)
View file
lightspark.tar.xz/src/backends/interfaces/CMakeLists.txt
Deleted
@@ -1,24 +0,0 @@ -#************************************************************************** -# Lightspark, a free flash player implementation -# -# Copyright (C) 2010-2012 Alessandro Pignotti <a.pignotti@sssup.it> -# Copyright (C) 2010 Giacomo Spigler <g.spigler@sssup.it> -# Copyright (C) 2010 Alexandre Demers <papouta@hotmail.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -#************************************************************************** - -include_directories(".") -INCLUDE_DIRECTORIES("..") -add_subdirectory(audio)
View file
lightspark.tar.xz/src/backends/interfaces/IPlugin.cpp
Deleted
@@ -1,47 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#include "backends/interfaces/IPlugin.h" - -IPlugin::IPlugin ( PLUGIN_TYPES plugin_type, std::string plugin_name, std::string backend_name ) : - pluginName ( plugin_name ), backendName ( backend_name ), pluginType ( plugin_type ) -{ - -} - -const std::string IPlugin::get_pluginName() -{ - return pluginName; -} - -PLUGIN_TYPES IPlugin::get_pluginType() -{ - return pluginType; -} - -const std::string IPlugin::get_backendName() -{ - return backendName; -} - -IPlugin::~IPlugin() -{ - -}
View file
lightspark.tar.xz/src/backends/interfaces/IPlugin.h
Deleted
@@ -1,55 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - - -#ifndef BACKENDS_INTERFACES_IPLUGIN_H -#define BACKENDS_INTERFACES_IPLUGIN_H 1 - -#include <iostream> -#include "compat.h" - -enum PLUGIN_TYPES { UNDEFINED = 0, AUDIO, VIDEO, DECODER, ENCODER }; - -class IPlugin -{ -public: - virtual const std::string get_pluginName(); - virtual PLUGIN_TYPES get_pluginType(); - virtual const std::string get_backendName(); - virtual ~IPlugin(); -protected: - std::string pluginName; //name of the plugin - std::string backendName; //backend supported by the plugin - PLUGIN_TYPES pluginType; //type of plugin of PLUGIN_TYPES - IPlugin ( PLUGIN_TYPES plugin_type, std::string plugin_name, std::string backend_name ); -}; - -/************************* -Extern "C" functions that each plugin must implement in order to be recognized as a plugin by us. -It allows us to share a common interface between plugins and the application. - -Plugin factory function -extern "C" IPlugin* create(); - -Plugin cleanup function -extern "C" void release(IPlugin* p_plugin); -***************************/ - -#endif /* BACKENDS_INTERFACES_IPLUGIN_H */
View file
lightspark.tar.xz/src/backends/interfaces/audio
Deleted
-(directory)
View file
lightspark.tar.xz/src/backends/interfaces/audio/CMakeLists.txt
Deleted
@@ -1,39 +0,0 @@ -#************************************************************************** -# Lightspark, a free flash player implementation -# -# Copyright (C) 2010-2012 Alessandro Pignotti <a.pignotti@sssup.it> -# Copyright (C) 2010 Giacomo Spigler <g.spigler@sssup.it> -# Copyright (C) 2010 Alexandre Demers <papouta@hotmail.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -#************************************************************************** - -include_directories(".") -INCLUDE_DIRECTORIES("..") - -#Export symbols -IF(WIN32) - ADD_DEFINITIONS("-DDLL_PUBLIC=__declspec(dllexport)") -ENDIF() - - -IF(${AUDIO_BACKEND} MATCHES "pulse") - add_subdirectory(pulse) -ENDIF(${AUDIO_BACKEND} MATCHES "pulse") -IF(${AUDIO_BACKEND} MATCHES "winmm") - add_subdirectory(winmm) -ENDIF() -IF(${AUDIO_BACKEND} MATCHES "sdl") - add_subdirectory(sdl) -ENDIF(${AUDIO_BACKEND} MATCHES "sdl")
View file
lightspark.tar.xz/src/backends/interfaces/audio/IAudioPlugin.cpp
Deleted
@@ -1,75 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#include "backends/interfaces/audio/IAudioPlugin.h" -#include <iostream> - -using namespace std; - - -IAudioPlugin::IAudioPlugin ( string plugin_name, string backend_name, bool init_stopped ): - IPlugin(AUDIO, plugin_name, backend_name), stopped(init_stopped), muteAllStreams(false) -{ - -} - -string IAudioPlugin::get_device ( DEVICE_TYPES desiredType ) -{ - if ( PLAYBACK ) - { - return playbackDeviceName; - } - else if ( CAPTURE ) - { - return captureDeviceName; - } - else - { - return NULL; - } -} - -vector< string* > *IAudioPlugin::get_devicesList ( DEVICE_TYPES desiredType ) -{ - if ( desiredType == PLAYBACK ) - { - return &playbackDevicesList; - } - else if ( desiredType == CAPTURE ) - { - return &captureDevicesList; - } - else - { - return NULL; - } -} - -IAudioPlugin::~IAudioPlugin() -{ - -} - - -AudioStream::AudioStream ( lightspark::AudioDecoder* dec ): - decoder(dec),hasStarted(false) -{ - -}
View file
lightspark.tar.xz/src/backends/interfaces/audio/IAudioPlugin.h
Deleted
@@ -1,87 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#ifndef BACKENDS_INTERFACES_AUDIO_IAUDIOPLUGIN_H -#define BACKENDS_INTERFACES_AUDIO_IAUDIOPLUGIN_H 1 - -#include "compat.h" -#include "backends/decoder.h" -#include "backends/interfaces/IPlugin.h" -#include <iostream> - -class AudioStream -{ -protected: - AudioStream(lightspark::AudioDecoder *dec = NULL); - -public: - lightspark::AudioDecoder *decoder; - virtual bool ispaused() = 0; //Is the stream paused? (corked) - virtual bool isValid() = 0; //Is the stream alive, fully working? - virtual void pause() = 0; - virtual void resume() = 0; - virtual uint32_t getPlayedTime() = 0; - virtual ~AudioStream() {}; - virtual void setVolume(double volume) - {LOG(LOG_NOT_IMPLEMENTED,"setVolume not implemented in plugin");} - bool hasStarted; -}; - -/********************** -Abstract class for audio plugin implementation -***********************/ -class IAudioPlugin : public IPlugin -{ -protected: - bool stopped; - bool muteAllStreams; - volatile bool contextReady; - volatile bool noServer; - std::string playbackDeviceName; - std::string captureDeviceName; - std::vector<std::string *> playbackDevicesList; - std::vector<std::string *> captureDevicesList; - std::list<AudioStream *> streams; - typedef std::list<AudioStream *>::iterator stream_iterator; - - IAudioPlugin ( std::string plugin_name, std::string backend_name, bool init_stopped = false ); - -public: - enum DEVICE_TYPES { PLAYBACK, CAPTURE }; - virtual std::vector<std::string *> *get_devicesList ( DEVICE_TYPES desiredType ); - virtual void set_device ( std::string desiredDevice, DEVICE_TYPES desiredType ) = 0; - virtual std::string get_device ( DEVICE_TYPES desiredType ); - virtual AudioStream *createStream ( lightspark::AudioDecoder *decoder ) = 0; - virtual bool isTimingAvailable() const = 0; - - virtual void muteAll() { muteAllStreams = true; } - virtual void unmuteAll() { muteAllStreams = false; } - virtual void toggleMuteAll() { muteAllStreams ? unmuteAll() : muteAll(); } - virtual bool allMuted() { return muteAllStreams; } - // if not -1, all streams will be resampled to the provided sample rate - virtual int forcedSampleRate() const { return -1;} - // if not -1, all streams will be resampled to the provided channel_layout - virtual int forcedChannelLayout() const { return -1;} - - virtual ~IAudioPlugin(); -}; - -#endif /* BACKENDS_INTERFACES_AUDIO_IAUDIOPLUGIN */ -
View file
lightspark.tar.xz/src/backends/interfaces/audio/pulse
Deleted
-(directory)
View file
lightspark.tar.xz/src/backends/interfaces/audio/pulse/CMakeLists.txt
Deleted
@@ -1,55 +0,0 @@ -#************************************************************************** -# Lightspark, a free flash player implementation -# -# Copyright (C) 2010-2012 Alessandro Pignotti <a.pignotti@sssup.it> -# Copyright (C) 2010 Giacomo Spigler <g.spigler@sssup.it> -# Copyright (C) 2010 Alexandre Demers <papouta@hotmail.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -#************************************************************************** - -## Compiler defaults flags for different profiles -#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x") -# -#SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DEXPENSIVE_DEBUG") -#SET(CMAKE_CXX_FLAGS_PROFILE "-g -pg -O2") -#SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_DEBIAN "-O2 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_LEANDEBUG "-g -O2") - -INCLUDE_DIRECTORIES(".") -INCLUDE_DIRECTORIES("..") - -pkg_check_modules(PULSE_LIBS REQUIRED libpulse) -INCLUDE_DIRECTORIES(${PULSE_LIBS_INCLUDE_DIRS}) -if(!Boost_FOUND) - find_package(Boost COMPONENTS filesystem system regex) - if(Boost_FOUND) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - endif(Boost_FOUND) -endif(!Boost_FOUND) -ADD_DEFINITIONS(-DPULSE_BACKEND=TRUE) - -SET(PULSEPLUGIN_SOURCES PulsePlugin.cpp ../../IPlugin.cpp ../IAudioPlugin.cpp) - -# liblightsparkpulseplugin.so target -ADD_LIBRARY(pulseplugin MODULE ${PULSEPLUGIN_SOURCES}) -TARGET_LINK_LIBRARIES(pulseplugin spark) #Need to link some functions with the decoders -TARGET_LINK_LIBRARIES(pulseplugin ${PULSE_LIBS_LIBRARIES} ${Boost_LIBRARIES}) -SET_TARGET_PROPERTIES(pulseplugin PROPERTIES OUTPUT_NAME lightsparkpulseplugin) -#SET_TARGET_PROPERTIES(pulseplugin PROPERTIES VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") -#SET_TARGET_PROPERTIES(pulseplugin PROPERTIES SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}") - -INSTALL(TARGETS pulseplugin LIBRARY DESTINATION ${PLUGINSDIR})
View file
lightspark.tar.xz/src/backends/interfaces/audio/pulse/PulsePlugin.cpp
Deleted
@@ -1,460 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#include <iostream> -#include "backends/interfaces/audio/pulse/PulsePlugin.h" -#include "compat.h" -#include "backends/decoder.h" - -#include <clocale> -#include <libintl.h> -#define _(STRING) gettext(STRING) - -using namespace lightspark; -using namespace std; - -PulsePlugin::PulsePlugin (string init_Name, string init_audiobackend, bool init_contextReady, - bool init_noServer, bool init_stopped ) : - IAudioPlugin ( init_Name, init_audiobackend, init_stopped ) -{ - contextReady = init_contextReady; - noServer = init_noServer; - stopped = init_stopped; - - start(); -} - -void PulsePlugin::start() -{ - mainLoop = pa_threaded_mainloop_new(); - pa_threaded_mainloop_start ( mainLoop ); - - pulseLock(); - context = pa_context_new ( pa_threaded_mainloop_get_api ( mainLoop ), "Lightspark" ); - pa_context_set_state_callback ( context, ( pa_context_notify_cb_t ) contextStatusCB, this ); - pa_context_connect ( context, NULL, PA_CONTEXT_NOFLAGS, NULL ); - pulseUnlock(); -} - -void PulsePlugin::set_device ( string desiredDevice, DEVICE_TYPES desiredType ) -{ - playbackDeviceName = desiredDevice; - pulseLock(); - if(desiredType == PLAYBACK) - { - //Add code to change playback device - } - else if(desiredType == CAPTURE) - { - //Add code to change capture device - } - pulseUnlock(); -} - -void PulsePlugin::generateDevicesList ( vector< string* >* devicesList, DEVICE_TYPES desiredType ) -{ - pulseLock(); - if(desiredType == PLAYBACK) - { - pa_context_get_sink_info_list ( context, playbackListCB, &playbackDevicesList ); - } - else if(desiredType == CAPTURE) - { - pa_context_get_source_info_list ( context, captureListCB, &captureDevicesList ); - } - pulseUnlock(); - -} - -void PulsePlugin::captureListCB ( pa_context* context, const pa_source_info* list, int eol, void *th ) -{ - PulsePlugin *oPlugin = ( PulsePlugin * ) th; - string deviceName ( list->name ); - if ( !eol && list ) //Device found - { - oPlugin->captureDevicesList.push_back( new string (deviceName)); - } -} - -void PulsePlugin::playbackListCB ( pa_context* context, const pa_sink_info* list, int eol, void *th ) -{ - PulsePlugin *oPlugin = ( PulsePlugin * ) th; - string deviceName ( list->name ); - if ( !eol && list ) //Device found - { - oPlugin->playbackDevicesList.push_back( new string (deviceName) ); - } -} - -void PulsePlugin::streamStatusCB ( pa_stream *stream, PulseAudioStream *th ) -{ - if ( pa_stream_get_state ( stream ) == PA_STREAM_READY ) - { - th->streamStatus = PulseAudioStream::STREAM_READY; - if ( th->decoder->hasDecodedFrames() ) - { - //Now that the stream is ready fill it - size_t availableSize = pa_stream_writable_size ( th->stream ); - th->fillStream( availableSize ); - } - } - else if ( pa_stream_get_state ( stream ) == PA_STREAM_TERMINATED || - pa_stream_get_state ( stream ) == PA_STREAM_FAILED ) - { - assert ( stream == th->stream ); - th->streamStatus = PulseAudioStream::STREAM_DEAD; - } -} - -void PulsePlugin::streamWriteCB ( pa_stream *stream, size_t askedData, PulseAudioStream *th ) -{ - th->fillStream(askedData); -} - -bool PulsePlugin::isTimingAvailable() const -{ - return serverAvailable(); -} - -PulseAudioStream::~PulseAudioStream() -{ - manager->pulseLock(); - - if( manager->serverAvailable() ) - pa_stream_disconnect( stream ); - - //Do not delete the stream now, let's wait termination. However, removing it from the list. - manager->streams.remove(this); - - manager->pulseUnlock(); - - while( streamStatus != PulseAudioStream::STREAM_DEAD ); - - manager->pulseLock(); - if( stream ) - pa_stream_unref ( stream ); - manager->pulseUnlock(); -} - -void PulsePlugin::streamOverflowCB( pa_stream *p, void *userdata ) -{ - LOG(LOG_INFO, "AUDIO BACKEND: Stream overflow"); -} - -void PulsePlugin::streamUnderflowCB( pa_stream *p, void *userdata ) -{ - LOG(LOG_INFO, "AUDIO BACKEND: Stream underflow"); -} - -void PulsePlugin::streamStartedCB( pa_stream *p, void *userdata ) -{ - LOG(LOG_INFO, "AUDIO BACKEND: Stream started"); -} - -AudioStream *PulsePlugin::createStream ( AudioDecoder *decoder ) -{ - PulseAudioStream *audioStream = new PulseAudioStream( this ); - streams.push_back( audioStream ); //Create new SoundStream - if ( serverAvailable() ) - { - while ( !contextReady ); - pulseLock(); - assert ( decoder->isValid() ); - - audioStream->decoder = decoder; - pa_sample_spec ss; - ss.format = PA_SAMPLE_S16LE; - ss.rate = decoder->sampleRate; - ss.channels = decoder->channelCount; - pa_buffer_attr attrs; - attrs.maxlength = ( uint32_t ) - 1; - attrs.prebuf = 0; - attrs.tlength = ( uint32_t ) - 1; - attrs.fragsize = ( uint32_t ) - 1; - attrs.minreq = ( uint32_t ) - 1; - audioStream->stream = pa_stream_new ( context, "AudioStream", &ss, NULL ); - pa_stream_set_state_callback ( audioStream->stream, ( pa_stream_notify_cb_t ) streamStatusCB, audioStream ); - pa_stream_set_write_callback ( audioStream->stream, ( pa_stream_request_cb_t ) streamWriteCB, audioStream ); - pa_stream_set_underflow_callback ( audioStream->stream, ( pa_stream_notify_cb_t ) streamUnderflowCB, NULL ); - pa_stream_set_overflow_callback ( audioStream->stream, ( pa_stream_notify_cb_t ) streamOverflowCB, NULL ); - pa_stream_set_started_callback ( audioStream->stream, ( pa_stream_notify_cb_t ) streamStartedCB, NULL ); - pa_stream_flags flags = (pa_stream_flags) PA_STREAM_START_CORKED; - if(muteAllStreams) - flags = (pa_stream_flags) (flags | PA_STREAM_START_MUTED); - pa_stream_connect_playback ( audioStream->stream, NULL, &attrs, - flags, NULL, NULL ); - pulseUnlock(); - } - else - { - //Create the stream as dead - audioStream->streamStatus = PulseAudioStream::STREAM_DEAD; - } - return audioStream; -} - -void PulsePlugin::contextStatusCB ( pa_context *context, PulsePlugin *th ) -{ - switch ( pa_context_get_state ( context ) ) - { - case PA_CONTEXT_READY: - th->noServer = false; //In case something went wrong and the context is not correctly set - th->contextReady = true; - break; - case PA_CONTEXT_FAILED: - LOG(LOG_ERROR,_("AUDIO BACKEND: Connection to PulseAudio server failed")); - case PA_CONTEXT_TERMINATED: - th->noServer = true; - th->contextReady = false; //In case something went wrong and the context is not correctly set - th->stop(); //It should stop if the context can't be set - break; - default: - break; - } -} -void PulseAudioStream::pause() -{ - if(isValid() && !ispaused()) - { - pa_stream_cork(stream, 1, NULL, NULL); //This will stop the stream's time from running - paused=true; - } -} - -void PulseAudioStream::resume() -{ - if(isValid() && ispaused()) - { - pa_stream_cork(stream, 0, NULL, NULL); //This will restart time - paused=false; - } -} - -void PulsePlugin::pulseLock() -{ - pa_threaded_mainloop_lock(mainLoop);; -} - -void PulsePlugin::pulseUnlock() -{ - pa_threaded_mainloop_unlock(mainLoop); -} - -bool PulsePlugin::serverAvailable() const -{ - return !noServer; -} - -PulsePlugin::~PulsePlugin() -{ - stop(); -} - -void PulsePlugin::stop() -{ - if ( !stopped ) - { - stopped = true; - for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) - { - delete *it; - } - if(serverAvailable()) - { - pulseLock(); - pa_context_disconnect ( context ); - pa_context_unref ( context ); - pulseUnlock(); - pa_threaded_mainloop_stop ( mainLoop ); - pa_threaded_mainloop_free ( mainLoop ); - } - } -} - -void PulsePlugin::muteAll() -{ - IAudioPlugin::muteAll(); - for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) - { - ((PulseAudioStream*) (*it))->mute(); - } -} -void PulsePlugin::unmuteAll() -{ - IAudioPlugin::unmuteAll(); - for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) - { - ((PulseAudioStream*) (*it))->unmute(); - } -} - - -/**************************** -Stream's functions -****************************/ -PulseAudioStream::PulseAudioStream ( PulsePlugin* m ) : - AudioStream(NULL), paused(false), stream ( NULL ), manager ( m ), streamStatus ( STREAM_STARTING ), - streamVolume(0.0) -{ - -} - -uint32_t PulseAudioStream::getPlayedTime ( ) -{ - if ( streamStatus != STREAM_READY ) //The stream is not yet ready, delay upload - return 0; - - manager->pulseLock(); - //Request updated timing info - pa_operation* timeUpdate = pa_stream_update_timing_info ( stream, NULL, NULL ); - manager->pulseUnlock(); - while ( pa_operation_get_state ( timeUpdate ) != PA_OPERATION_DONE ); - manager->pulseLock(); - pa_operation_unref ( timeUpdate ); - - pa_usec_t time; - pa_stream_get_time ( stream, &time ); - - manager->pulseUnlock(); - return time / 1000; -} - -void PulseAudioStream::fillStream(size_t toSend) -{ - /* Write data until we have space on the server and we have data available. - * pa_stream_begin_write will return maximum 65472 bytes, but toSend is usually much bigger - * so we loop until it is filled or we have no more decoded data - */ - while(toSend) - { - int16_t *dest; - uint32_t totalWritten = 0; - size_t frameSize = toSend; - int ret = pa_stream_begin_write ( stream, ( void** ) &dest, &frameSize ); - (void)ret; // silence warning about unused variable - assert(!ret); - toSend -= frameSize; - if (frameSize == 0) - break; - - /* copy frames from the decoder until the buffer is full */ - do - { - uint32_t retSize = decoder->copyFrame ( dest + ( totalWritten / 2 ), frameSize ); - if ( retSize == 0 ) //There is no more data - break; - totalWritten += retSize; - frameSize -= retSize; - } - while ( frameSize ); - - if ( totalWritten ) - { - pa_stream_write ( stream, dest, totalWritten, NULL, 0, PA_SEEK_RELATIVE ); - } - else - { - //there was not any decoded data available - pa_stream_cancel_write ( stream ); - break; - } - } - - if(!paused && pa_stream_is_corked(stream)) - pa_stream_cork ( stream, 0, NULL, NULL ); //Start the stream, just in case it's still stopped -} - -bool PulseAudioStream::ispaused() -{ - assert_and_throw(isValid()); - return pa_stream_is_corked(stream); -} - -bool PulseAudioStream::isValid() -{ - return streamStatus != STREAM_DEAD; -} - -void PulseAudioStream::mute() -{ - pa_context_set_sink_input_mute( - pa_stream_get_context(stream), - pa_stream_get_index(stream), - 1, - NULL, - NULL - ); -} -void PulseAudioStream::unmute() -{ - pa_context_set_sink_input_mute( - pa_stream_get_context(stream), - pa_stream_get_index(stream), - 0, - NULL, - NULL - ); -} - -void PulseAudioStream::sinkInfoForSettingVolumeCB(pa_context* context, const pa_sink_info* i, int eol, PulseAudioStream* stream) -{ - if(eol) - { - //The callback is called multiple times even if querying a single device - return; - } - struct pa_cvolume volume; - pa_sw_cvolume_multiply_scalar(&volume, &i->volume, stream->streamVolume*PA_VOLUME_NORM); - - pa_context_set_sink_input_volume( - context, - pa_stream_get_index(stream->stream), - &volume, - NULL, - NULL - ); -} - -void PulseAudioStream::setVolume(double vol) -{ - if(vol==streamVolume) - return; - streamVolume=vol; - uint32_t deviceIndex = pa_stream_get_device_index(stream); - pa_operation* op=pa_context_get_sink_info_by_index( - pa_stream_get_context(stream), - deviceIndex, - (pa_sink_info_cb_t)sinkInfoForSettingVolumeCB, - this); - pa_operation_unref(op); -} - -// Plugin factory function -extern "C" DLL_PUBLIC IPlugin *create() -{ - return new PulsePlugin(); -} - -// Plugin cleanup function -extern "C" DLL_PUBLIC void release ( IPlugin *p_plugin ) -{ - //delete the previously created object - delete p_plugin; -}
View file
lightspark.tar.xz/src/backends/interfaces/audio/pulse/PulsePlugin.h
Deleted
@@ -1,95 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#ifndef BACKENDS_INTERFACES_AUDIO_PULSEPLUGIN_H -#define BACKENDS_INTERFACES_AUDIO_PULSEPLUGIN_H 1 - -#include <pulse/pulseaudio.h> -#include "backends/interfaces/audio/IAudioPlugin.h" -#include "backends/decoder.h" -#include "compat.h" -#include <iostream> - -class PulseAudioStream; //Early declaration - -class PulsePlugin : public IAudioPlugin -{ -friend class PulseAudioStream; -private: - pa_threaded_mainloop *mainLoop; - pa_context *context; - static void contextStatusCB ( pa_context *context, PulsePlugin *th ); - void start(); - void stop(); - static void playbackListCB ( pa_context *context, const pa_sink_info *list, int eol, void *th ); - static void captureListCB ( pa_context *context, const pa_source_info *list, int eol, void *th ); - //To populate the devices lists, devicesType must be playback or capture - void generateDevicesList ( std::vector<std::string *> *devicesList, DEVICE_TYPES desiredType ); - static void streamStatusCB ( pa_stream *stream, PulseAudioStream *th ); - static void streamWriteCB ( pa_stream *stream, size_t nbytes, PulseAudioStream *th ); - static void streamStartedCB ( pa_stream *p, void *userdata ); - static void streamUnderflowCB ( pa_stream *p, void *userdata ); - static void streamOverflowCB ( pa_stream *p, void *userdata ); - bool contextReady; - bool noServer; - -public: - PulsePlugin ( std::string init_Name = "Pulse plugin output only", std::string init_audiobackend = "pulseaudio", - bool init_contextReady = false, bool init_noServer = false, bool init_stopped = false ); - void set_device ( std::string desiredDevice, DEVICE_TYPES desiredType ); - AudioStream *createStream ( lightspark::AudioDecoder *decoder ); - bool isTimingAvailable() const; - void pulseLock(); - void pulseUnlock(); - bool serverAvailable() const; - - void muteAll(); - void unmuteAll(); - - ~PulsePlugin(); -}; - -class PulseAudioStream: public AudioStream -{ -friend class PulsePlugin; -public: - enum STREAM_STATUS { STREAM_STARTING = 0, STREAM_READY = 1, STREAM_DEAD = 2 }; - PulseAudioStream ( PulsePlugin *m ); - uint32_t getPlayedTime (); - bool ispaused(); - bool isValid(); - void pause(); - void resume(); - static void sinkInfoForSettingVolumeCB(pa_context* context, const pa_sink_info* i, int eol, PulseAudioStream* stream); - ~PulseAudioStream(); -private: - bool paused; - pa_stream *stream; - PulsePlugin *manager; - volatile STREAM_STATUS streamStatus; - double streamVolume; - - void mute(); - void unmute(); - void setVolume(double volume); - void fillStream(size_t frameSize); -}; - -#endif /* BACKENDS_INTERFACES_AUDIO_PULSEPLUGIN_H */
View file
lightspark.tar.xz/src/backends/interfaces/audio/sdl
Deleted
-(directory)
View file
lightspark.tar.xz/src/backends/interfaces/audio/sdl/CMakeLists.txt
Deleted
@@ -1,55 +0,0 @@ -#************************************************************************** -# Lightspark, a free flash player implementation -# -# Copyright (C) 2010-2012 Alessandro Pignotti <a.pignotti@sssup.it> -# Copyright (C) 2010 Giacomo Spigler <g.spigler@sssup.it> -# Copyright (C) 2010 Alexandre Demers <papouta@hotmail.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -#************************************************************************** - -## Compiler defaults flags for different profiles -#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x") -# -#SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DEXPENSIVE_DEBUG") -#SET(CMAKE_CXX_FLAGS_PROFILE "-g -pg -O2") -#SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_DEBIAN "-O2 -DNDEBUG") -#SET(CMAKE_CXX_FLAGS_LEANDEBUG "-g -O2") - -INCLUDE_DIRECTORIES(".") -INCLUDE_DIRECTORIES("..") - -pkg_check_modules(SDL REQUIRED sdl) -pkg_check_modules(SDL_mixer REQUIRED) -INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${SDL_mixer_INCLUDE_DIRS}) -if(!Boost_FOUND) - find_package(Boost COMPONENTS filesystem system regex) - if(Boost_FOUND) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - endif(Boost_FOUND) -endif(!Boost_FOUND) -ADD_DEFINITIONS(-DSDL_BACKEND=TRUE) - -SET(SDLPLUGIN_SOURCES SDLPlugin.cpp ../../IPlugin.cpp ../IAudioPlugin.cpp) - -# liblightsparkSDLplugin.so target -ADD_LIBRARY(sdlplugin MODULE ${SDLPLUGIN_SOURCES}) -TARGET_LINK_LIBRARIES(sdlplugin spark) #Need to link some functions with the decoders -TARGET_LINK_LIBRARIES(sdlplugin ${SDL_LIBRARIES} ${SDL_mixer_LIBRARIES} ${Boost_LIBRARIES}) -SET_TARGET_PROPERTIES(sdlplugin PROPERTIES OUTPUT_NAME lightsparksdlplugin) - -INSTALL(TARGETS sdlplugin DESTINATION ${PLUGINSDIR})
View file
lightspark.tar.xz/src/backends/interfaces/audio/sdl/SDLPlugin.cpp
Deleted
@@ -1,219 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2011-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2011 Ludger Krämer (dbluelle@blau-weissoedingen.de) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#include "backends/interfaces/audio/sdl/SDLPlugin.h" -#include <SDL.h> - -using lightspark::AudioDecoder; -using namespace std; - -void mixer_effect_ffmpeg_cb(int chan, void * stream, int len, void * udata) -{ - SDLAudioStream *s = (SDLAudioStream*)udata; - if (!s) - return; - - if (!s->decoder->hasDecodedFrames()) - return; - uint32_t readcount = 0; - while (readcount < ((uint32_t)len)) - { - if (!s->decoder->hasDecodedFrames()) - break; - uint32_t ret = s->decoder->copyFrame((int16_t *)(((unsigned char*)stream)+readcount), ((uint32_t)len)-readcount); - if (!ret) - break; - readcount += ret; - } -} - -SDLPlugin::SDLPlugin(string init_Name, string init_audiobackend, bool init_stopped ) : - IAudioPlugin ( init_Name, init_audiobackend, init_stopped ) -{ - sdl_available = 0; - if (SDL_WasInit(0)) // some part of SDL already was initialized - sdl_available = !SDL_InitSubSystem ( SDL_INIT_AUDIO ); - else - sdl_available = !SDL_Init ( SDL_INIT_AUDIO ); - mixeropened = 0; -} -void SDLPlugin::set_device(std::string desiredDevice, - IAudioPlugin::DEVICE_TYPES desiredType) -{ - /* not yet implemented */ -} - -AudioStream* SDLPlugin::createStream(AudioDecoder* decoder) -{ - if (!sdl_available) - return NULL; - if (!mixeropened) - { - if (Mix_OpenAudio (LIGHTSPARK_AUDIO_SDL_SAMPLERATE, AUDIO_S16, 2, LIGHTSPARK_AUDIO_SDL_BUFERSIZE) < 0) - { - LOG(LOG_ERROR,"Couldn't open SDL_mixer"); - sdl_available = 0; - return NULL; - } - mixeropened = 1; - } - - SDLAudioStream *stream = new SDLAudioStream(this); - stream->decoder = decoder; - if (!stream->init()) - { - delete stream; - return NULL; - } - streams.push_back(stream); - - return stream; -} - - -SDLPlugin::~SDLPlugin() -{ - for (stream_iterator it = streams.begin(); it != streams.end(); ++it) { - delete *it; - } - if (mixeropened) - { - Mix_CloseAudio(); - } - if (sdl_available) - { - SDL_QuitSubSystem ( SDL_INIT_AUDIO ); - if (!SDL_WasInit(0)) - SDL_Quit (); - } -} - - -bool SDLPlugin::isTimingAvailable() const -{ - return true; -} -void SDLPlugin::muteAll() -{ - IAudioPlugin::muteAll(); - for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) - { - ((SDLAudioStream*) (*it))->mute(); - } -} -void SDLPlugin::unmuteAll() -{ - IAudioPlugin::unmuteAll(); - for ( stream_iterator it = streams.begin();it != streams.end(); ++it ) - { - ((SDLAudioStream*) (*it))->unmute(); - } -} - -/**************************** -Stream's functions -****************************/ -uint32_t SDLAudioStream::getPlayedTime() -{ - uint32_t ret; - struct timeval now; - gettimeofday(&now, NULL); - - ret = playedtime + (now.tv_sec * 1000 + now.tv_usec / 1000) - (starttime.tv_sec * 1000 + starttime.tv_usec / 1000); - return ret; -} - -bool SDLAudioStream::init() -{ - unmutevolume = curvolume = SDL_MIX_MAXVOLUME; - playedtime = 0; - gettimeofday(&starttime, NULL); - mixer_channel = -1; - - uint32_t len = LIGHTSPARK_AUDIO_SDL_BUFERSIZE; - - uint8_t *buf = new uint8_t[len]; - memset(buf,0,len); - Mix_Chunk* chunk = Mix_QuickLoad_RAW(buf, len); - - - mixer_channel = Mix_PlayChannel(-1, chunk, -1); - Mix_RegisterEffect(mixer_channel, mixer_effect_ffmpeg_cb, NULL, this); - Mix_Resume(mixer_channel); - return true; -} - -void SDLAudioStream::SetPause(bool pause_on) -{ - if (pause_on) - { - playedtime = getPlayedTime(); - if (mixer_channel != -1) - Mix_Pause(mixer_channel); - } - else - { - gettimeofday(&starttime, NULL); - if (mixer_channel != -1) - Mix_Resume(mixer_channel); - } -} - -bool SDLAudioStream::ispaused() -{ - return Mix_Paused(mixer_channel); -} - -bool SDLAudioStream::isValid() -{ - return true; -} -void SDLAudioStream::mute() -{ - unmutevolume = curvolume; - curvolume = 0; -} -void SDLAudioStream::unmute() -{ - curvolume = unmutevolume; -} -void SDLAudioStream::setVolume(double volume) -{ - curvolume = SDL_MIX_MAXVOLUME * volume; - if (mixer_channel != -1) - Mix_Volume(mixer_channel, curvolume); -} - -SDLAudioStream::~SDLAudioStream() -{ - manager->streams.remove(this); - if (mixer_channel != -1) - Mix_HaltChannel(mixer_channel); -} - -extern "C" DLL_PUBLIC IPlugin *create() -{ - return new SDLPlugin(); -} - -extern "C" DLL_PUBLIC void release(IPlugin *plugin) -{ - delete plugin; -}
View file
lightspark.tar.xz/src/backends/interfaces/audio/sdl/SDLPlugin.h
Deleted
@@ -1,83 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2011-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2011 Ludger Krämer (dbluelle@blau-weissoedingen.de) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#ifndef BACKENDS_INTERFACES_AUDIO_SDL_SDLPLUGIN_H -#define BACKENDS_INTERFACES_AUDIO_SDL_SDLPLUGIN_H 1 - -#include "backends/interfaces/audio/IAudioPlugin.h" -#include "backends/decoder.h" -#include "compat.h" -#include <sys/time.h> -#include <SDL/SDL_mixer.h> - -using lightspark::AudioDecoder; - -#define LIGHTSPARK_AUDIO_SDL_BUFERSIZE 4096 -#define LIGHTSPARK_AUDIO_SDL_SAMPLERATE 44100 - -class SDLAudioStream; - -class SDLPlugin : public IAudioPlugin -{ -friend class SDLAudioStream; -private: - int sdl_available; - int mixeropened; -public: - SDLPlugin ( std::string init_Name = "SDL plugin", std::string init_audiobackend = "sdl", bool init_stopped = false ); - - void set_device(std::string desiredDevice, IAudioPlugin::DEVICE_TYPES desiredType); - - AudioStream *createStream(AudioDecoder *decoder); - - void muteAll(); - void unmuteAll(); - int forcedSampleRate() const { return LIGHTSPARK_AUDIO_SDL_SAMPLERATE;} - int forcedChannelLayout() const { return AV_CH_LAYOUT_STEREO;} - - bool isTimingAvailable() const; - ~SDLPlugin(); -}; - -class SDLAudioStream: public AudioStream -{ -private: - SDLPlugin* manager; - int curvolume; - int unmutevolume; - uint32_t playedtime; - struct timeval starttime; - int mixer_channel; -public: - bool init(); - SDLAudioStream(SDLPlugin* _manager) : manager(_manager) { } - - void SetPause(bool pause_on); - uint32_t getPlayedTime(); - bool ispaused(); - bool isValid(); - void mute(); - void unmute(); - void pause() { SetPause(true); } - void resume() { SetPause(false); } - void setVolume(double volume); - ~SDLAudioStream(); -}; -#endif /* BACKENDS_INTERFACES_AUDIO_SDL_SDLPLUGIN_H */
View file
lightspark.tar.xz/src/backends/interfaces/audio/winmm
Deleted
-(directory)
View file
lightspark.tar.xz/src/backends/interfaces/audio/winmm/CMakeLists.txt
Deleted
@@ -1,29 +0,0 @@ -#************************************************************************** -# Lightspark, a free flash player implementation -# -# Copyright (C) 2010-2012 Alessandro Pignotti <a.pignotti@sssup.it> -# Copyright (C) 2010 Giacomo Spigler <g.spigler@sssup.it> -# Copyright (C) 2010 Alexandre Demers <papouta@hotmail.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -#************************************************************************** - -INCLUDE_DIRECTORIES(".") -INCLUDE_DIRECTORIES("..") - -ADD_LIBRARY(winmmplugin MODULE WinMMPlugin.cpp ../../IPlugin.cpp ../IAudioPlugin.cpp) -SET_TARGET_PROPERTIES(winmmplugin PROPERTIES OUTPUT_NAME lightsparkwinmmplugin) -TARGET_LINK_LIBRARIES(winmmplugin spark winmm) - -INSTALL(TARGETS winmmplugin LIBRARY DESTINATION ${PLUGINSDIR})
View file
lightspark.tar.xz/src/backends/interfaces/audio/winmm/WinMMPlugin.cpp
Deleted
@@ -1,246 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#include <iostream> -#include "backends/interfaces/audio/winmm/WinMMPlugin.h" -#include "compat.h" -#include "backends/decoder.h" - -using namespace lightspark; -using namespace std; - -WinMMPlugin::WinMMPlugin() : IAudioPlugin( "Windows WaveOut plugin", "winmm" ) -{ -} - -void WinMMPlugin::set_device( std::string desiredDevice, DEVICE_TYPES desiredType ) -{ -} - -AudioStream *WinMMPlugin::createStream ( AudioDecoder *decoder ) -{ - WinMMStream *audioStream = new WinMMStream( decoder, this ); - streams.push_back( audioStream ); //Create new SoundStream - return audioStream; -} - -WinMMPlugin::~WinMMPlugin() -{ - while(!streams.empty()) - delete streams.front(); -} - -/**************************** -Stream's functions -****************************/ -WinMMStream::WinMMStream( AudioDecoder* d, WinMMPlugin* m ) : - AudioStream(d), manager(m), freeBuffers(NUM_BUFFERS), curBuffer(0), threadAborting(false), paused(false) -{ - assert(decoder->sampleRate > 0); - /* 1/10 seconds per buffer - * This should not cause any a/v-desync, - * as getPlayedTime() returns the actual playhead - * position, not the time we have buffered. - */ - bufferSize = decoder->sampleRate * 2 / 10; - - WAVEFORMATEX wfx; - wfx.nSamplesPerSec = decoder->sampleRate; /* sample rate */ - wfx.wBitsPerSample = 16; /* sample size */ - wfx.nChannels = decoder->channelCount; /* channels*/ - wfx.cbSize = 0; /* size of _extra_ info */ - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; - if(waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, (DWORD_PTR)&waveOutProc, (DWORD_PTR)this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"unable to open WAVE_MAPPER device"); - - if(waveOutSetVolume(hWaveOut, 0xFFFFFFFF) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutSetVolume failed"); - - memset(buffer, 0, sizeof(buffer)); - for(uint32_t i=0; i < NUM_BUFFERS; ++i) - { - aligned_malloc((void**)&buffer[i].lpData, wfx.nBlockAlign, bufferSize); - buffer[i].dwBufferLength = bufferSize; - } -#ifdef HAVE_NEW_GLIBMM_THREAD_API - workerThread = Thread::create(sigc::mem_fun(this,&WinMMStream::worker)); -#else - workerThread = Thread::create(sigc::mem_fun(this,&WinMMStream::worker), true); -#endif -} - -WinMMStream::~WinMMStream() -{ - Mutex::Lock l(mutex); - manager->streams.remove(this); - - threadAborting = true; - /* wake up worker() */ - freeBuffers.signal(); - workerThread->join(); - - /* Stop playing */ - if(waveOutReset(hWaveOut) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutReset failed"); - - /* Close handle */ - if(waveOutClose(hWaveOut) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutClose failed"); - - for(uint32_t i=0; i < NUM_BUFFERS; ++i) - aligned_free(buffer[i].lpData); -} - -void CALLBACK WinMMStream::waveOutProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - if(uMsg != WOM_DONE) - return; - WinMMStream* stream = (WinMMStream*)dwInstance; - stream->freeBuffers.signal(); -} - -void WinMMStream::worker() -{ - while(!threadAborting) - { - freeBuffers.wait(); - if(threadAborting) - return; - - Mutex::Lock l(mutex); - /* Unprepare previous data */ - if(buffer[curBuffer].dwFlags & WHDR_PREPARED - && waveOutUnprepareHeader(hWaveOut, &buffer[curBuffer], sizeof(WAVEHDR)) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutUnprepareHeader failed"); - - /* Copy data from decoder */ - uint32_t freeSize = bufferSize; - int8_t* curBufPos = (int8_t*)buffer[curBuffer].lpData; - while(freeSize && !threadAborting) - { - /* copy min(freeSize,available) to buffer */ - uint32_t retSize = decoder->copyFrame ( (int16_t*)curBufPos, freeSize ); - freeSize -= retSize; - curBufPos += retSize; - } - - buffer[curBuffer].dwBufferLength = bufferSize; - buffer[curBuffer].dwFlags = 0; - - /* Prepare current data */ - if(waveOutPrepareHeader(hWaveOut, &buffer[curBuffer], sizeof(WAVEHDR)) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutPrepareHeader failed"); - /* Write it to the device */ - if(waveOutWrite(hWaveOut, &buffer[curBuffer], sizeof(WAVEHDR)) != MMSYSERR_NOERROR) - LOG(LOG_ERROR,"waveOutWrite failed"); - - curBuffer = (curBuffer + 1) % NUM_BUFFERS; - } -} - -void WinMMStream::pause() -{ - Mutex::Lock l(mutex); - /* nop if already paused */ - waveOutPause(hWaveOut); - paused = true; -} - -void WinMMStream::resume() -{ - Mutex::Lock l(mutex); - /* nop if not paused */ - waveOutRestart(hWaveOut); - paused = false; -} - -uint32_t WinMMStream::getPlayedTime( ) -{ - Mutex::Lock l(mutex); - MMTIME mmtime; - /* TIME_MS does not work with every driver */ - mmtime.wType = TIME_SAMPLES; - if(waveOutGetPosition(hWaveOut, &mmtime, sizeof(mmtime)) != MMSYSERR_NOERROR) - { - LOG(LOG_ERROR,"waveOutGetPosition failed"); - return 0; - } - if(mmtime.wType != TIME_SAMPLES) - { - LOG(LOG_ERROR,"Could not obtain playback time correct format, is " << mmtime.wType); - return 0; - } - return (double)mmtime.u.sample / (double)decoder->sampleRate * 1000.0; -} - -bool WinMMStream::ispaused() -{ - return paused; -} - -bool WinMMStream::isValid() -{ - return true; -} - -void WinMMStream::mute() -{ - Mutex::Lock l(mutex); - DWORD curVolume; - waveOutGetVolume(hWaveOut, &curVolume); - if(curVolume != 0) - { - waveOutSetVolume(hWaveOut, 0); - preMuteVolume = curVolume; - } -} - -void WinMMStream::unmute() -{ - Mutex::Lock l(mutex); - DWORD curVolume; - waveOutGetVolume(hWaveOut, &curVolume); - if(curVolume == 0) - waveOutSetVolume(hWaveOut, preMuteVolume); -} - -void WinMMStream::setVolume(double vol) -{ - Mutex::Lock l(mutex); - /* map vol = 0.0 to 0x0000 and vol = 1.0 to 0xFFFF, - * lower word is left channel, higher word is right channel */ - DWORD dwvol = MAKELPARAM(0xFFFF*vol, 0xFFFF*vol); - waveOutSetVolume(hWaveOut, dwvol); -} - -// Plugin factory function -extern "C" DLL_PUBLIC IPlugin *create() -{ - return new WinMMPlugin(); -} - -// Plugin cleanup function -extern "C" DLL_PUBLIC void release ( IPlugin *p_plugin ) -{ - //delete the previously created object - delete p_plugin; -}
View file
lightspark.tar.xz/src/backends/interfaces/audio/winmm/WinMMPlugin.h
Deleted
@@ -1,83 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - Copyright (C) 2010 Alexandre Demers (papouta@hotmail.com) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#ifndef BACKENDS_INTERFACES_AUDIO_WINMM_WINMMPLUGIN_H -#define BACKENDS_INTERFACES_AUDIO_WINMM_WINMMPLUGIN_H 1 - -#include <iostream> -#include <windows.h> -#undef RGB //conflicts with swftypes.h -#include <mmsystem.h> -#include "backends/interfaces/audio/IAudioPlugin.h" -#include "backends/decoder.h" -#include "compat.h" -#include "threading.h" - -namespace lightspark -{ -class WinMMStream; //Early declaration - -#define NUM_BUFFERS (4) - -class WinMMPlugin : public IAudioPlugin -{ -friend class WinMMStream; -private: - -public: - WinMMPlugin(); - void set_device( std::string desiredDevice, DEVICE_TYPES desiredType ); - AudioStream *createStream( lightspark::AudioDecoder *decoder ); - bool isTimingAvailable() const { return true; }; - ~WinMMPlugin(); -}; - -class WinMMStream: public AudioStream -{ -friend class WinMMPlugin; -private: - WinMMPlugin* manager; - Semaphore freeBuffers; - WAVEHDR buffer[NUM_BUFFERS]; - uint32_t curBuffer; - Thread* workerThread; - volatile bool threadAborting; - DWORD preMuteVolume; - bool paused; - HWAVEOUT hWaveOut; - uint32_t bufferSize; - Mutex mutex; - void worker(); - static void CALLBACK waveOutProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); -public: - WinMMStream(AudioDecoder* d, WinMMPlugin* m ); - uint32_t getPlayedTime(); - bool ispaused(); - bool isValid(); - void pause(); - void resume(); - void mute(); - void unmute(); - void setVolume(double); - ~WinMMStream(); -}; - -} -#endif /* BACKENDS_INTERFACES_AUDIO_WINMM_WINMMPLUGIN_H */
View file
lightspark.tar.xz/src/backends/pluginmanager.cpp
Deleted
@@ -1,302 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ -#define BOOST_FILESYSTEM_NO_DEPRECATED - -#include "backends/pluginmanager.h" -#include <iostream> -#include <list> -#include <boost/filesystem.hpp> -#include <pcre.h> -#include "logger.h" -#include "exceptions.h" - -#include <gmodule.h> - -using namespace lightspark; -using namespace std; -using namespace boost::filesystem; - -PluginManager::PluginManager() -{ - assert( g_module_supported() ); - findPlugins(); -} - -/*************************** -Find liblightsparkBACKENDplugin libraries -****************************/ -void PluginManager::findPlugins() -{ - //Search for all files under the plugins directory - //Verify if they are audio plugins - //If true, add to list of audio plugins -#ifdef _WIN32 - const path plugins_folder = getExectuablePath(); -#else - const path plugins_folder = string(PRIVATELIBDIR) + "/plugins/"; -#endif - const string pattern ( "liblightspark+[A-Za-z]+plugin.*" ); - - //Stuff used by/for pcre - const char* patternError; - int patternErrorOffset; - pcre* file_pattern = pcre_compile ( pattern.c_str(), 0, &patternError, &patternErrorOffset, NULL ); - if(patternError) - throw RunTimeException("PluginManager::findPlugins(): can't compile file_pattern"); - //We don't expect any captured substrings, so 3 ints should be enough - -#if defined DEBUG - LOG(LOG_INFO, "Looking for plugins under " << plugins_folder << " for pattern " << pattern); -#endif - - if ( !is_directory ( plugins_folder ) ) - { - LOG ( LOG_ERROR, _ ( ( ( string ) ( "The plugins folder doesn't exists under " + plugins_folder.string() ) ).c_str() ) ); - } - else - { - for ( directory_iterator itr ( plugins_folder ), end_itr; itr != end_itr; ++itr ) - { - if ( is_regular_file ( *itr ) ) //Is it a real file? This will remove symlink - { -#if BOOST_VERSION >= 104600 - string leaf_name = itr->path().filename().string(); -#else - string leaf_name = itr->path().filename(); -#endif - int patternOvector[3]; - int rc=pcre_exec(file_pattern, NULL, leaf_name.c_str(), leaf_name.length(), 0, 0, patternOvector, 3); - if ( rc > 0 ) // Does it answer to the desired pattern? - { -#if BOOST_VERSION >= 104600 - path fullpath = plugins_folder.string(); -#else - path fullpath = plugins_folder.directory_string(); -#endif - fullpath /= leaf_name; - //Try to load the file and see if it's an audio plugin - if ( GModule* h_plugin = g_module_open( fullpath.string().c_str(), G_MODULE_BIND_LAZY) ) - { - PLUGIN_FACTORY p_factory_function; - PLUGIN_CLEANUP p_cleanup_function; - - if ( g_module_symbol(h_plugin, "create", (void**)&p_factory_function) - && g_module_symbol(h_plugin, "release", (void**)&p_cleanup_function) ) - { //Does it contain the LS IPlugin? - IPlugin *p_plugin = p_factory_function (); //Instanciate the plugin - LOG ( LOG_INFO, _ ( "A plugin was found. Adding it to the list." ) ); - addPluginToList ( p_plugin, fullpath.string() ); //Add the plugin info to the audio plugins list - - p_cleanup_function ( p_plugin ); - g_module_close ( h_plugin ); - } - else //If doesn't implement our IPlugin interface entry points, close it - { - g_module_close( h_plugin ); - } - } - } - } - } - } - pcre_free(file_pattern); -} - -//return a list of backends of the appropriated PLUGIN_TYPES -vector<string *> PluginManager::get_backendsList ( PLUGIN_TYPES typeSearched ) -{ - vector<string *> retrievedList; - uint32_t count = 0; - for ( uint32_t index = 0; index < pluginsList.size(); index++ ) - { - if ( pluginsList[index]->pluginType == typeSearched ) - { - if ( count == retrievedList.size() ) - { - retrievedList.push_back ( new string ); - } - retrievedList[count] = &pluginsList[index]->backendName; - count++; - } - } - return retrievedList; -} - -//get the desired plugin associated to the backend -IPlugin *PluginManager::get_plugin ( string desiredBackend ) -{ - LOG ( LOG_INFO, _ ( ( ( string ) ( "get_plugin: " + desiredBackend ) ).c_str() ) ); - int32_t index = findPluginInList ( "", desiredBackend, "", NULL, NULL ); - if ( index >= 0 ) - { - loadPlugin ( index ); - return pluginsList[index]->oLoadedPlugin; - } - else - { - return NULL; - } -} - -/******************* -When a plugin is not needed anymore somewhere, the client that had asked it tells the manager it doesn't -need it anymore. The PluginManager releases it (delete and unload). -*******************/ -void PluginManager::release_plugin ( IPlugin* o_plugin ) -{ - for ( uint32_t index = 0; index < pluginsList.size(); index++ ) - { - if ( pluginsList[index]->oLoadedPlugin == o_plugin ) - { - unloadPlugin ( index ); - } - } -} - -/********************* -Adds the information about a plugin in the plugins list -*********************/ -void PluginManager::addPluginToList ( IPlugin *o_plugin, string pathToPlugin ) -{ - //Verify if the plugin is already in the list - int32_t index = findPluginInList ( "", "", pathToPlugin, NULL, NULL ); - if ( index >= 0 ) //If true, plugin is already in the list, we have nothing to do - { - return; - } - else - { - index = ( int32_t ) ( pluginsList.size() ); //we want to add the plugin to the end of the list - if ( pluginsList.size() == ( uint32_t ) ( index ) ) - { - pluginsList.push_back ( new PluginModule() ); - } - pluginsList[index]->pluginName = o_plugin->get_pluginName(); - pluginsList[index]->backendName = o_plugin->get_backendName(); - pluginsList[index]->pluginPath = pathToPlugin; - pluginsList[index]->enabled = false; - LOG ( LOG_INFO, _ ( ( ( string ) ( "The plugin " + pluginsList[index]->pluginName + " was added with backend: " + pluginsList[index]->backendName ) ).c_str() ) ); - } -} - -/********************** -Removes the information about a plugin from the plugins list. -It's used only by the manager when there are modifications in the plugins folder. -**********************/ -void PluginManager::removePluginFromList ( string pluginPath ) -{ - int32_t index = findPluginInList ( "", "", pluginPath, NULL, NULL ); - if ( index >= 0 ) - { - unloadPlugin ( index ); - pluginsList.erase ( pluginsList.begin() + index ); - } -} - -/************************** -Looks in the plugins list for the desired entry. -If found, returns the location in the list (index). Else, returns -1 (which can't be an entry in the list) -**************************/ -int32_t PluginManager::findPluginInList ( string desiredname, string desiredbackend, - string desiredpath, GModule* hdesiredloadPlugin, IPlugin* o_desiredPlugin ) -{ - for ( uint32_t index = 0; index < pluginsList.size(); index++ ) - { - if ( ( desiredname != "" ) && ( pluginsList[index]->pluginName == desiredname ) ) - { - return index; - } - if ( ( desiredbackend != "" ) && ( pluginsList[index]->backendName == desiredbackend ) ) - { - return index; - } - if ( ( desiredpath != "" ) && ( pluginsList[index]->pluginPath == desiredpath ) ) - { - return index; - } - if ( ( hdesiredloadPlugin != NULL ) && ( pluginsList[index]->hLoadedPlugin == hdesiredloadPlugin ) ) - { - return index; - } - if ( ( o_desiredPlugin != NULL ) && ( pluginsList[index]->oLoadedPlugin == o_desiredPlugin ) ) - { - return index; - } - } - return -1; -} - - -//Takes care to load and instanciate anything related to the plugin -void PluginManager::loadPlugin ( uint32_t desiredindex ) -{ - if( (pluginsList[desiredindex]->hLoadedPlugin = g_module_open( pluginsList[desiredindex]->pluginPath.c_str(), G_MODULE_BIND_LAZY))) - { - PLUGIN_FACTORY p_factory_function; - if ( g_module_symbol(pluginsList[desiredindex]->hLoadedPlugin, "create", (void**)&p_factory_function) ) - { //Does it contain the LS IPlugin? - pluginsList[desiredindex]->oLoadedPlugin = ( *p_factory_function ) (); //Instanciate the plugin - pluginsList[desiredindex]->enabled = true; - } - } -} - -//Takes care of unloading and releasing anything related to the plugin -void PluginManager::unloadPlugin ( uint32_t desiredIndex ) -{ - if ( pluginsList[desiredIndex]->oLoadedPlugin || pluginsList[desiredIndex]->hLoadedPlugin ) //If there is already a backend loaded, unload it - { - if ( pluginsList[desiredIndex]->oLoadedPlugin != NULL ) - { - PLUGIN_CLEANUP p_cleanup_function; - - if ( g_module_symbol(pluginsList[desiredIndex]->hLoadedPlugin, "release", (void**)&p_cleanup_function) ) - { - p_cleanup_function ( pluginsList[desiredIndex]->oLoadedPlugin ); - } - else - { - delete pluginsList[desiredIndex]->oLoadedPlugin; - } - - pluginsList[desiredIndex]->oLoadedPlugin = NULL; - g_module_close ( pluginsList[desiredIndex]->hLoadedPlugin ); - } - pluginsList[desiredIndex]->enabled = false; //Unselecting any entry in the plugins list - } -} - -PluginManager::~PluginManager() -{ - for(auto i = pluginsList.begin(); i != pluginsList.end(); ++i) - delete *i; -} - - -PluginModule::PluginModule() - : pluginName ( "undefined" ), pluginType ( UNDEFINED ), backendName ( "undefined" ), pluginPath ( "" ), - enabled ( false ), hLoadedPlugin ( NULL ), oLoadedPlugin ( NULL ) -{ - -} - -PluginModule::~PluginModule() -{ - -}
View file
lightspark.tar.xz/src/backends/pluginmanager.h
Deleted
@@ -1,78 +0,0 @@ -/************************************************************************** - Lightspark, a free flash player implementation - - Copyright (C) 2010-2013 Alessandro Pignotti (a.pignotti@sssup.it) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -**************************************************************************/ - -#ifndef BACKENDS_PLUGINMANAGER_H -#define BACKENDS_PLUGINMANAGER_H 1 - -#include "compat.h" -#include <iostream> -#include <vector> - -#include "backends/interfaces/IPlugin.h" - -//convenience typedef for the pointers to the 2 functions we expect to find in the plugin libraries -typedef IPlugin * ( *PLUGIN_FACTORY ) (); -typedef void ( *PLUGIN_CLEANUP ) ( IPlugin * ); -typedef struct _GModule GModule; - -namespace lightspark -{ - -class PluginModule; - -class PluginManager -{ -private: - std::vector<PluginModule *> pluginsList; - void findPlugins(); - void addPluginToList ( IPlugin *o_plugin, std::string pathToPlugin ); - void removePluginFromList ( std::string plugin_path ); - int32_t findPluginInList ( std::string desiredname = "", std::string desiredbackend = "", std::string desiredpath = "", - GModule* hdesiredLoadPlugin = NULL, IPlugin *o_desiredPlugin = NULL ); - void loadPlugin ( uint32_t desiredindex ); - void unloadPlugin ( uint32_t desiredIndex ); - -public: - PluginManager(); - std::vector<std::string *> get_backendsList ( PLUGIN_TYPES typeSearched ); - IPlugin *get_plugin ( std::string desiredBackend ); - void release_plugin ( IPlugin *o_plugin ); - ~PluginManager(); -}; - -class PluginModule -{ - friend class PluginManager; -protected: - std::string pluginName; //plugin name - PLUGIN_TYPES pluginType; //plugin type to be able to filter them - std::string backendName; //backend (can be something like pulseaudio, opengl, ffmpeg) - std::string pluginPath; //full path to the plugin file - bool enabled; //should it be enabled (if the audio backend is present)? - GModule* hLoadedPlugin; //when loaded, handle to the plugin so we can unload it later - IPlugin *oLoadedPlugin; //when instanciated, object to the class - -public: - PluginModule(); - ~PluginModule(); -}; - -} - -#endif /* BACKENDS_PLUGINMANAGER_H */
View file
lightspark.tar.xz/src/backends/rendering.cpp
Changed
@@ -83,13 +83,10 @@ time_s.assign_current_time(); } -/* this is called in the context of the gtk main thread */ void RenderThread::start(EngineData* data) { status=STARTED; engineData=data; - /* this function must be called in the gtk main thread */ - engineData->setSizeChangeHandler(sigc::mem_fun(this,&RenderThread::requestResize)); #ifdef HAVE_NEW_GLIBMM_THREAD_API t = Thread::create(sigc::mem_fun(this,&RenderThread::worker)); #else @@ -194,130 +191,149 @@ windowWidth=engineData->width; windowHeight=engineData->height; -#if defined(_WIN32) - PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags - PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette. - 32, //Colordepth of the framebuffer. - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 24, //Number of bits for the depthbuffer - 0, //Number of bits for the stencilbuffer - 0, //Number of Aux buffers in the framebuffer. - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - if(!(mDC = GetDC((HWND)engineData->window))) - throw RunTimeException("GetDC failed"); - int PixelFormat; - if (!(PixelFormat=ChoosePixelFormat(mDC,&pfd))) - throw RunTimeException("ChoosePixelFormat failed"); - if(!SetPixelFormat(mDC,PixelFormat,&pfd)) - throw RunTimeException("SetPixelFormat failed"); - if (!(mRC=wglCreateContext(mDC))) - throw RunTimeException("wglCreateContext failed"); - if(!wglMakeCurrent(mDC,mRC)) - throw RunTimeException("wglMakeCurrent failed"); -#elif !defined(ENABLE_GLES2) - mDisplay = XOpenDisplay(NULL); - int a,b; - Bool glx_present=glXQueryVersion(mDisplay, &a, &b); - if(!glx_present) - throw RunTimeException("glX not present"); - - int attrib[10]={GLX_DOUBLEBUFFER, True, None}; - GLXFBConfig* fb=glXChooseFBConfig(mDisplay, 0, attrib, &a); - if(!fb) + if (SDL_GetWindowFlags(engineData->widget) & SDL_WINDOW_OPENGL) { - attrib[6]=None; - LOG(LOG_ERROR,_("Falling back to no double buffering")); - fb=glXChooseFBConfig(mDisplay, 0, attrib, &a); - } - if(!fb) - throw RunTimeException(_("Could not find any GLX configuration")); - int i; - for(i=0;i<a;i++) - { - int id; - glXGetFBConfigAttrib(mDisplay, fb[i],GLX_VISUAL_ID,&id); - if(id==(int)engineData->visual) - break; +#ifdef ENABLE_GLES2 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); +#endif + mSDLContext = SDL_GL_CreateContext(engineData->widget); + if (!mSDLContext) + LOG(LOG_ERROR,"failed to create openGL context:"<<SDL_GetError()); } - if(i==a) + else { - //No suitable id found - throw RunTimeException(_("No suitable graphics configuration available")); - } - mFBConfig=fb[i]; - LOG(LOG_INFO, "Chosen config " << hex << fb[i] << dec); - XFree(fb); - mContext = glXCreateNewContext(mDisplay, mFBConfig,GLX_RGBA_TYPE ,NULL,1); - glXMakeCurrent(mDisplay, engineData->window, mContext); - if(!glXIsDirect(mDisplay, mContext)) - LOG(LOG_INFO, "Indirect!!"); + +#if defined(_WIN32) + PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags + PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette. + 32, //Colordepth of the framebuffer. + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 24, //Number of bits for the depthbuffer + 0, //Number of bits for the stencilbuffer + 0, //Number of Aux buffers in the framebuffer. + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + if(!(mDC = GetDC((HWND)engineData->window))) + throw RunTimeException("GetDC failed"); + int PixelFormat; + if (!(PixelFormat=ChoosePixelFormat(mDC,&pfd))) + throw RunTimeException("ChoosePixelFormat failed"); + if(!SetPixelFormat(mDC,PixelFormat,&pfd)) + throw RunTimeException("SetPixelFormat failed"); + if (!(mRC=wglCreateContext(mDC))) + throw RunTimeException("wglCreateContext failed"); + if(!wglMakeCurrent(mDC,mRC)) + throw RunTimeException("wglMakeCurrent failed"); +#elif !defined(ENABLE_GLES2) + mDisplay = XOpenDisplay(NULL); + int a,b; + Bool glx_present=glXQueryVersion(mDisplay, &a, &b); + if(!glx_present) + { + XCloseDisplay(mDisplay); + throw RunTimeException("glX not present"); + } + + int attrib[10]={GLX_DOUBLEBUFFER, True, None}; + GLXFBConfig* fb=glXChooseFBConfig(mDisplay, 0, attrib, &a); + if(!fb) + { + attrib[6]=None; + LOG(LOG_ERROR,_("Falling back to no double buffering")); + fb=glXChooseFBConfig(mDisplay, 0, attrib, &a); + } + if(!fb) + { + XCloseDisplay(mDisplay); + throw RunTimeException(_("Could not find any GLX configuration")); + } + int i; + for(i=0;i<a;i++) + { + int id; + glXGetFBConfigAttrib(mDisplay, fb[i],GLX_VISUAL_ID,&id); + if(id==(int)engineData->visual) + break; + } + if(i==a) + { + //No suitable id found + XCloseDisplay(mDisplay); + throw RunTimeException(_("No suitable graphics configuration available")); + } + mFBConfig=fb[i]; + LOG(LOG_INFO, "Chosen config " << hex << fb[i] << dec); + XFree(fb); + mContext = glXCreateNewContext(mDisplay, mFBConfig,GLX_RGBA_TYPE ,NULL,1); + glXMakeCurrent(mDisplay, engineData->windowID, mContext); + if(!glXIsDirect(mDisplay, mContext)) + LOG(LOG_INFO, "Indirect!!"); #else //egl - mDisplay = XOpenDisplay(NULL); - int a; - eglBindAPI(EGL_OPENGL_ES_API); - mEGLDisplay = eglGetDisplay(mDisplay); - if (mEGLDisplay == EGL_NO_DISPLAY) - throw RunTimeException(_("EGL not present")); - EGLint major, minor; - if (eglInitialize(mEGLDisplay, &major, &minor) == EGL_FALSE) - throw RunTimeException(_("EGL initialization failed")); - - LOG(LOG_INFO, _("EGL version: ") << eglQueryString(mEGLDisplay, EGL_VERSION)); - EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NONE + mDisplay = XOpenDisplay(NULL); + int a; + eglBindAPI(EGL_OPENGL_ES_API); + mEGLDisplay = eglGetDisplay(mDisplay); + if (mEGLDisplay == EGL_NO_DISPLAY) + throw RunTimeException(_("EGL not present")); + EGLint major, minor; + if (eglInitialize(mEGLDisplay, &major, &minor) == EGL_FALSE) + throw RunTimeException(_("EGL initialization failed")); + + LOG(LOG_INFO, _("EGL version: ") << eglQueryString(mEGLDisplay, EGL_VERSION)); + EGLint config_attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE + }; + EGLint context_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE }; - EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - if (!eglChooseConfig(mEGLDisplay, config_attribs, 0, 0, &a)) - throw RunTimeException(_("Could not get number of EGL configurations")); - else - LOG(LOG_INFO, "Number of EGL configurations: " << a); - EGLConfig *conf = new EGLConfig[a]; - if (!eglChooseConfig(mEGLDisplay, config_attribs, conf, a, &a)) - throw RunTimeException(_("Could not find any EGL configuration")); - - int i; - for(i=0;i<a;i++) - { - EGLint id; - eglGetConfigAttrib(mEGLDisplay, conf[i], EGL_NATIVE_VISUAL_ID, &id); - if(id==(int)engineData->visual) - break; - } - if(i==a) - { - //No suitable id found - throw RunTimeException(_("No suitable graphics configuration available")); - } - mEGLConfig=conf[i]; - LOG(LOG_INFO, "Chosen config " << hex << conf[i] << dec); - mEGLContext = eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, context_attribs); - if (mEGLContext == EGL_NO_CONTEXT) - throw RunTimeException(_("Could not create EGL context")); - mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, engineData->window, NULL); - if (mEGLSurface == EGL_NO_SURFACE) - throw RunTimeException(_("Could not create EGL surface")); - eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); + if (!eglChooseConfig(mEGLDisplay, config_attribs, 0, 0, &a)) + throw RunTimeException(_("Could not get number of EGL configurations")); + else + LOG(LOG_INFO, "Number of EGL configurations: " << a); + EGLConfig *conf = new EGLConfig[a]; + if (!eglChooseConfig(mEGLDisplay, config_attribs, conf, a, &a)) + throw RunTimeException(_("Could not find any EGL configuration")); + + int i; + for(i=0;i<a;i++) + { + EGLint id; + eglGetConfigAttrib(mEGLDisplay, conf[i], EGL_NATIVE_VISUAL_ID, &id); + if(id==(int)engineData->visual) + break; + } + if(i==a) + { + //No suitable id found + throw RunTimeException(_("No suitable graphics configuration available")); + } + mEGLConfig=conf[i]; + LOG(LOG_INFO, "Chosen config " << hex << conf[i] << dec); + mEGLContext = eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, context_attribs); + if (mEGLContext == EGL_NO_CONTEXT) + throw RunTimeException(_("Could not create EGL context")); + mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, engineData->window, NULL); + if (mEGLSurface == EGL_NO_SURFACE) + throw RunTimeException(_("Could not create EGL surface")); + eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); #endif - + } commonGLInit(windowWidth, windowHeight); commonGLResize(); } @@ -380,14 +396,18 @@ { renderErrorPage(this, m_sys->standalone); } - + if (engineData->widget && (SDL_GetWindowFlags(engineData->widget) & SDL_WINDOW_OPENGL)) + SDL_GL_SwapWindow(engineData->widget); + else + { #if defined(_WIN32) - SwapBuffers(mDC); + SwapBuffers(mDC); #elif !defined(ENABLE_GLES2) - glXSwapBuffers(mDisplay, engineData->window); + glXSwapBuffers(mDisplay, engineData->windowID); #else - eglSwapBuffers(mEGLDisplay, mEGLSurface); + eglSwapBuffers(mEGLDisplay, mEGLSurface); #endif + } if(!m_sys->isOnError()) { coreRendering(); @@ -423,22 +443,26 @@ { glDisable(GL_TEXTURE_2D); commonGLDeinit(); - + if (engineData->widget && (SDL_GetWindowFlags(engineData->widget) & SDL_WINDOW_OPENGL)) + { + SDL_GL_DeleteContext(mSDLContext); + } + else + { #if defined(_WIN32) - wglMakeCurrent(NULL,NULL); - wglDeleteContext(mRC); - /* Do not ReleaseDC(e->window,hDC); as our window does not have CS_OWNDC */ + wglMakeCurrent(NULL,NULL); + wglDeleteContext(mRC); + /* Do not ReleaseDC(e->window,hDC); as our window does not have CS_OWNDC */ #elif !defined(ENABLE_GLES2) - glXMakeCurrent(mDisplay, None, NULL); - glXDestroyContext(mDisplay, mContext); - XCloseDisplay(mDisplay); + glXMakeCurrent(mDisplay, None, NULL); + glXDestroyContext(mDisplay, mContext); + XCloseDisplay(mDisplay); #else - eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext(mEGLDisplay, mEGLContext); - XCloseDisplay(mDisplay); + eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(mEGLDisplay, mEGLContext); + XCloseDisplay(mDisplay); #endif - engineData->removeSizeChangeHandler(); - return; + } } bool RenderThread::loadShaderPrograms() @@ -869,7 +893,7 @@ if(!diff.negative()) /* is one seconds elapsed? */ { time_s=time_d; - LOG(LOG_INFO,_("FPS: ") << dec << frameCount<<" "<<getVm(getSys())->getEventQueueSize()); + LOG(LOG_INFO,_("FPS: ") << dec << frameCount<<" "<<getVm(m_sys)->getEventQueueSize()); frameCount=0; secsCount++; }
View file
lightspark.tar.xz/src/backends/rendering.h
Changed
@@ -24,7 +24,7 @@ #include "backends/rendering_context.h" #include "timer.h" #include <glibmm/timeval.h> - +#include <SDL2/SDL.h> #ifdef _WIN32 # include <windef.h> #endif @@ -77,6 +77,7 @@ float scaleY; int offsetX; int offsetY; + SDL_GLContext mSDLContext; #ifdef _WIN32 HGLRC mRC; @@ -117,7 +118,6 @@ Semaphore initialized; Mutex mutexRendering; - static void SizeAllocateCallback(GtkWidget* widget, GdkRectangle* allocation, gpointer data); public: RenderThread(SystemState* s); ~RenderThread();
View file
lightspark.tar.xz/src/main.cpp
Changed
@@ -22,11 +22,8 @@ #include "swf.h" #include "logger.h" #include "platforms/engineutils.h" -#ifndef _WIN32 -# include <sys/resource.h> -# include <gdk/gdkx.h> -#endif #include "compat.h" +#include <SDL2/SDL.h> using namespace std; @@ -34,56 +31,27 @@ class StandaloneEngineData: public EngineData { - guint destroyHandlerId; - guint deleteHandlerId; public: - StandaloneEngineData() : destroyHandlerId(0),deleteHandlerId(0) + StandaloneEngineData() { -#ifndef _WIN32 - visual = XVisualIDFromVisual(gdk_x11_visual_get_xvisual(gdk_visual_get_system())); -#endif } - static void destroyWidget(GtkWidget* widget) + ~StandaloneEngineData() { - gdk_threads_enter(); - gtk_widget_destroy(widget); - gdk_threads_leave(); } - ~StandaloneEngineData() + SDL_Window* createWidget(uint32_t w, uint32_t h) { - if(widget) + SDL_Window* window = SDL_CreateWindow("Lightspark",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,w,h,SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + if (window == 0) { - if(deleteHandlerId) - g_signal_handler_disconnect(widget, deleteHandlerId); - if(destroyHandlerId) - g_signal_handler_disconnect(widget, destroyHandlerId); - - runInGtkThread(sigc::bind(&destroyWidget,widget)); + // try creation of window without opengl support + window = SDL_CreateWindow("Lightspark",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,w,h,SDL_WINDOW_RESIZABLE); + if (window == 0) + LOG(LOG_ERROR,"createWidget failed:"<<SDL_GetError()); } - } - static void StandaloneDestroy(GtkWidget *widget, gpointer data) - { - StandaloneEngineData* e = reinterpret_cast<StandaloneEngineData*>(data); - RecMutex::Lock l(e->mutex); - /* no need to destroy it - it's already done */ - e->widget = NULL; - getSys()->setShutdownFlag(); - } - static gboolean StandaloneDelete(GtkWidget *widget, gpointer data) - { - // wait for rendering complete - getSys()->waitRendering(); - return FALSE; - } - GtkWidget* createGtkWidget() - { - GtkWidget* window=gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title((GtkWindow*)window,"Lightspark"); - deleteHandlerId = g_signal_connect(window,"delete_event",G_CALLBACK(StandaloneDelete),this); - destroyHandlerId = g_signal_connect(window,"destroy",G_CALLBACK(StandaloneDestroy),this); return window; } - GdkNativeWindow getWindowForGnash() + + uint32_t getWindowForGnash() { /* passing and invalid window id to gnash makes * it create its own window */ @@ -103,6 +71,22 @@ { LOG(LOG_NOT_IMPLEMENTED, "openPageInBrowser not implemented in the standalone mode"); } + bool getScreenData(SDL_DisplayMode* screen) + { + if (SDL_GetDesktopDisplayMode(0, screen) != 0) { + LOG(LOG_ERROR,"Capabilities: SDL_GetDesktopDisplayMode failed:"<<SDL_GetError()); + return false; + } + return true; + } + double getScreenDPI() + { + float ddpi; + float hdpi; + float vdpi; + SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(widget),&ddpi,&hdpi,&vdpi); + return ddpi; + } }; int main(int argc, char* argv[]) @@ -133,14 +117,6 @@ LOG(LOG_INFO,"Lightspark version " << VERSION << " Copyright 2009-2013 Alessandro Pignotti and others"); - //Make GTK thread enabled -#ifdef HAVE_G_THREAD_INIT - g_thread_init(NULL); -#endif - gdk_threads_init(); - //Give GTK a chance to parse its own options - gtk_init (&argc, &argv); - for(int i=1;i<argc;i++) { if(strcmp(argv[i],"-u")==0 || @@ -263,15 +239,6 @@ exit(1); } -#ifndef _WIN32 - struct rlimit rl; - getrlimit(RLIMIT_AS,&rl); - rl.rlim_cur=400000000; - rl.rlim_max=rl.rlim_cur; - //setrlimit(RLIMIT_AS,&rl); - -#endif - Log::setLogLevel(log_level); ifstream f(fileName, ios::in|ios::binary); f.seekg(0, ios::end); @@ -286,7 +253,12 @@ cout.exceptions( ios::failbit | ios::badbit); cerr.exceptions( ios::failbit | ios::badbit); SystemState::staticInit(); - EngineData::startGTKMain(); + if (!EngineData::startSDLMain()) + { + LOG(LOG_ERROR,"SDL initialization failed, aborting"); + SystemState::staticDeinit(); + exit(3); + } //NOTE: see SystemState declaration SystemState* sys = new SystemState(fileSize, flashMode); ParseThread* pt = new ParseThread(f, sys->mainClip); @@ -363,11 +335,18 @@ * SystemState::setShutdownFlag. */ sys->destroy(); + + SDL_Event event; + SDL_zero(event); + event.type = LS_USEREVENT_QUIT; + SDL_PushEvent(&event); + EngineData::mainLoopThread->join(); + delete pt; delete sys; SystemState::staticDeinit(); - EngineData::quitGTKMain(); + return 0; }
View file
lightspark.tar.xz/src/platforms/engineutils.cpp
Changed
@@ -19,113 +19,167 @@ **************************************************************************/ #include "platforms/engineutils.h" - -#ifdef _WIN32 -# include <gdk/gdkwin32.h> -#else -# include <sys/resource.h> -# include <gdk/gdkx.h> -#endif - +#include "swf.h" +#include <SDL2/SDL.h> +#include <SDL2/SDL_mouse.h> +#include "backends/input.h" +#include "backends/rendering.h" using namespace std; using namespace lightspark; -EngineData::EngineData() : widget(0), inputHandlerId(0), sizeHandlerId(0), width(0), height(0), window(0) +uint32_t EngineData::userevent = (uint32_t)-1; +Thread* EngineData::mainLoopThread = NULL; +bool EngineData::mainthread_running = false; +Semaphore EngineData::mainthread_initialized(0); +EngineData::EngineData() : widget(0), width(0), height(0),windowID(0),visual(0) { } EngineData::~EngineData() { - RecMutex::Lock l(mutex); - removeSizeChangeHandler(); - removeInputHandler(); } - -/* gtk main loop handling */ -static void gtk_main_runner() +bool EngineData::mainloop_handleevent(SDL_Event* event,SystemState* sys) { - gdk_threads_enter(); - gtk_main(); - gdk_threads_leave(); + if (event->type == LS_USEREVENT_INIT) + { + sys = (SystemState*)event->user.data1; + setTLSSys(sys); + } + else if (event->type == LS_USEREVENT_EXEC) + { + if (event->user.data1) + ((void (*)(SystemState*))event->user.data1)(sys); + } + else if (event->type == LS_USEREVENT_QUIT) + { + setTLSSys(NULL); + SDL_Quit(); + return true; + } + else + { + if (sys && sys->getInputThread() && sys->getInputThread()->handleEvent(event)) + return false; + switch (event->type) + { + case SDL_WINDOWEVENT: + { + switch (event->window.event) + { + case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + if (sys && sys->getRenderThread()) + sys->getRenderThread()->requestResize(event->window.data1,event->window.data2,false); + break; + case SDL_WINDOWEVENT_EXPOSED: + { + //Signal the renderThread + if (sys && sys->getRenderThread()) + sys->getRenderThread()->draw(false); + break; + } + + default: + break; + } + break; + } + case SDL_QUIT: + sys->setShutdownFlag(); + break; + } + } + return false; } -Thread* EngineData::gtkThread = NULL; +/* main loop handling */ +static void mainloop_runner() +{ + bool sdl_available = false; + if (SDL_WasInit(0)) // some part of SDL already was initialized + sdl_available = SDL_InitSubSystem ( SDL_INIT_VIDEO ); + else + sdl_available = SDL_Init ( SDL_INIT_VIDEO ); + if (sdl_available) + { + LOG(LOG_ERROR,"Unable to initialize SDL:"<<SDL_GetError()); + EngineData::mainthread_initialized.signal(); + return; + } + else + { + EngineData::mainthread_running = true; + EngineData::mainthread_initialized.signal(); + SDL_Event event; + while (SDL_WaitEvent(&event)) + { + SystemState* sys = getSys(); + + if (EngineData::mainloop_handleevent(&event,sys)) + { + EngineData::mainthread_running = false; + return; + } + } + } +} +gboolean EngineData::mainloop_from_plugin(SystemState* sys) +{ + SDL_Event event; + setTLSSys(sys); + while (SDL_PollEvent(&event)) + { + mainloop_handleevent(&event,sys); + } + setTLSSys(NULL); + return G_SOURCE_CONTINUE; +} /* This is not run in the linux plugin, as firefox * runs its own gtk_main, which we must not interfere with. */ -void EngineData::startGTKMain() +bool EngineData::startSDLMain() { - assert(!gtkThread); + assert(!mainLoopThread); #ifdef HAVE_NEW_GLIBMM_THREAD_API - gtkThread = Thread::create(sigc::ptr_fun(>k_main_runner)); + mainLoopThread = Thread::create(sigc::ptr_fun(&mainloop_runner)); #else - gtkThread = Thread::create(sigc::ptr_fun(>k_main_runner),true); + mainLoopThread = Thread::create(sigc::ptr_fun(&mainloop_runner),true); #endif + mainthread_initialized.wait(); + return mainthread_running; } -void EngineData::quitGTKMain() -{ - assert(gtkThread); - gdk_threads_enter(); - gtk_main_quit(); - gdk_threads_leave(); - gtkThread->join(); - gtkThread = NULL; -} - -/* This function must be called from the gtk main thread - * and within gdk_threads_enter/leave */ void EngineData::showWindow(uint32_t w, uint32_t h) { RecMutex::Lock l(mutex); assert(!widget); - widget = createGtkWidget(); - /* create a window handle */ - gtk_widget_realize(widget); -#if _WIN32 - window = GDK_WINDOW_HWND(gtk_widget_get_window(widget)); -#else - window = GDK_WINDOW_XID(gtk_widget_get_window(widget)); -#endif - if(isSizable()) - { - gtk_widget_set_size_request(widget, w, h); - width = w; - height = h; - } - gtk_widget_show(widget); - gtk_widget_map(widget); + widget = createWidget(w,h); + this->width = w; + this->height = h; + SDL_ShowWindow(widget); + grabFocus(); + } -void EngineData::showMouseCursor() +void EngineData::showMouseCursor(SystemState* /*sys*/) { - if (!widget) - return; - - gdk_threads_enter(); - GdkWindow* gdkwindow = gtk_widget_get_window(widget); - if (gdkwindow) - gdk_window_set_cursor(gdkwindow, NULL); - gdk_threads_leave(); + SDL_ShowCursor(SDL_ENABLE); } -void EngineData::hideMouseCursor() +void EngineData::hideMouseCursor(SystemState* /*sys*/) { - if (!widget) - return; + SDL_ShowCursor(SDL_DISABLE); +} - gdk_threads_enter(); - GdkCursor* cursor = gdk_cursor_new(GDK_BLANK_CURSOR); - if (cursor) - { - GdkWindow* gdkwindow = gtk_widget_get_window(widget); - if (gdkwindow) - gdk_window_set_cursor(gdkwindow, cursor); - gdk_cursor_unref(cursor); - } - gdk_threads_leave(); +void EngineData::setClipboardText(const std::string txt) +{ + int ret = SDL_SetClipboardText(txt.c_str()); + if (ret == 0) + LOG(LOG_INFO, "Copied error to clipboard"); + else + LOG(LOG_ERROR, "copying text to clipboard failed:"<<SDL_GetError()); }
View file
lightspark.tar.xz/src/platforms/engineutils.h
Changed
@@ -20,7 +20,7 @@ #ifndef PLATFORMS_ENGINEUTILS_H #define PLATFORMS_ENGINEUTILS_H 1 -#include <gtk/gtk.h> +#include <SDL2/SDL.h> #include "compat.h" #include "threading.h" #include "tiny_string.h" @@ -31,36 +31,28 @@ #ifndef _WIN32 //taken from X11/X.h typedef unsigned long VisualID; +typedef unsigned long XID; #endif - +#define LS_USEREVENT_INIT EngineData::userevent +#define LS_USEREVENT_EXEC EngineData::userevent+1 +#define LS_USEREVENT_QUIT EngineData::userevent+2 +class SystemState; class DLL_PUBLIC EngineData { + friend class RenderThread; protected: - GtkWidget* widget; /* use a recursive mutex, because g_signal_connect may directly call * the specific handler */ RecMutex mutex; - sigc::slot<bool,GdkEvent*> inputHandler; - gulong inputHandlerId; - sigc::slot<void,int32_t,int32_t,bool> sizeHandler; - gulong sizeHandlerId; - /* This function must be called from the gtk main thread - * and within gdk_threads_enter/leave */ - virtual GtkWidget* createGtkWidget()=0; - /* This functions runs in the thread of gtk_main() */ - static int callHelper(sigc::slot<void>* slot) - { - (*slot)(); - delete slot; - /* we must return 'false' or gtk will call this periodically */ - return FALSE; - } - static Thread* gtkThread; + virtual SDL_Window* createWidget(uint32_t w,uint32_t h)=0; public: + SDL_Window* widget; + static uint32_t userevent; + static Thread* mainLoopThread; int width; int height; - GdkNativeWindow window; #ifndef _WIN32 + XID windowID; VisualID visual; #endif EngineData(); @@ -68,86 +60,37 @@ virtual bool isSizable() const = 0; virtual void stopMainDownload() = 0; /* you may not call getWindowForGnash and showWindow on the same EngineData! */ - virtual GdkNativeWindow getWindowForGnash()=0; - /* Runs 'func' in the thread of gtk_main() */ - static void runInGtkThread(const sigc::slot<void>& func) + virtual uint32_t getWindowForGnash()=0; + /* Runs 'func' in the mainLoopThread */ + static void runInMainThread(void (*func) (SystemState*) ) { - g_idle_add((GSourceFunc)callHelper,new sigc::slot<void>(func)); + SDL_Event event; + SDL_zero(event); + event.type = LS_USEREVENT_EXEC; + event.user.data1 = (void*)func; + SDL_PushEvent(&event); } - /* This function must be called from the gtk main thread - * and within gdk_threads_enter/leave. + static bool mainloop_handleevent(SDL_Event* event,SystemState* sys); + static gboolean mainloop_from_plugin(SystemState* sys); + + /* This function must be called from mainLoopThread * It fills this->widget and this->window. - */ + */ void showWindow(uint32_t w, uint32_t h); - /* This function must be called within gdk_threads_enter/leave */ + /* must be called within mainLoopThread */ virtual void grabFocus()=0; virtual void openPageInBrowser(const tiny_string& url, const tiny_string& window)=0; - static gboolean inputDispatch(GtkWidget *widget, GdkEvent *event, EngineData* e) - { - RecMutex::Lock l(e->mutex); - if(!e->inputHandler.empty()) - return e->inputHandler(event); - return false; - } - /* This function must be called from the gtk_main() thread */ - void setInputHandler(const sigc::slot<bool,GdkEvent*>& ic) - { - RecMutex::Lock l(mutex); - if(!widget) - return; - - assert(!inputHandlerId); - inputHandler = ic; - gtk_widget_set_can_focus(widget,TRUE); - gtk_widget_add_events(widget, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | - GDK_LEAVE_NOTIFY_MASK); - inputHandlerId = g_signal_connect(widget, "event", G_CALLBACK(inputDispatch), this); - } - void removeInputHandler() - { - RecMutex::Lock l(mutex); - if(!inputHandler.empty() && widget) - { - g_signal_handler_disconnect(widget, inputHandlerId); - inputHandler = sigc::slot<bool,GdkEvent*>(); - } - } - static void sizeDispatch(GtkWidget* widget, GdkRectangle* allocation, EngineData* e) - { - RecMutex::Lock l(e->mutex); - if(!e->sizeHandler.empty() && widget) - e->sizeHandler(allocation->width, allocation->height, false); - } - /* This function must be called from the gtk_main() thread */ - void setSizeChangeHandler(const sigc::slot<void,int32_t,int32_t,bool>& sc) - { - RecMutex::Lock l(mutex); - if(!widget) - return; - - assert(!sizeHandlerId); - sizeHandler = sc; - sizeHandlerId = g_signal_connect(widget, "size-allocate", G_CALLBACK(sizeDispatch), this); - } - void removeSizeChangeHandler() - { - RecMutex::Lock l(mutex); - if(!sizeHandler.empty() && widget) - { - g_signal_handler_disconnect(widget, sizeHandlerId); - sizeHandler = sigc::slot<void,int32_t,int32_t,bool>(); - } - } - static void startGTKMain(); - static void quitGTKMain(); + static bool mainthread_running; + static Semaphore mainthread_initialized; + static bool startSDLMain(); - /* show/hide mouse cursor, must be called from the gtk thread */ - void showMouseCursor(); - void hideMouseCursor(); + /* show/hide mouse cursor, must be called from mainLoopThread */ + static void showMouseCursor(SystemState *sys); + static void hideMouseCursor(SystemState *sys); + virtual void setClipboardText(const std::string txt); + virtual bool getScreenData(SDL_DisplayMode* screen) = 0; + virtual double getScreenDPI() = 0; }; };
View file
lightspark.tar.xz/src/plugin/CMakeLists.txt
Changed
@@ -23,6 +23,9 @@ INCLUDE_DIRECTORIES("..") INCLUDE_DIRECTORIES("include/npapi") +pkg_check_modules(GTK REQUIRED gtk+-2.0) + +INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS}) IF(UNIX) ADD_DEFINITIONS(-DMOZ_X11) @@ -49,7 +52,7 @@ #With STATICDEPS, all deps are compiled into spark IF(NOT STATICDEPS) - TARGET_LINK_LIBRARIES(lightsparkplugin spark ${X11_LIBRARIES} ${GLIBMM_LIBRARIES}) + TARGET_LINK_LIBRARIES(lightsparkplugin spark ${X11_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTK_LIBRARIES}) ENDIF() IF(WIN32)
View file
lightspark.tar.xz/src/plugin/plugin.cpp
Changed
@@ -32,6 +32,15 @@ #include "backends/urlutils.h" #include "plugin/npscriptobject.h" +#include <SDL2/SDL.h> +#include <SDL2/SDL_syswm.h> +#include <gtk/gtk.h> +#include <gdk/gdkx.h> +#if GTK_CHECK_VERSION (2,21,8) +#include <gdk/gdkkeysyms-compat.h> +#else +#include <gdk/gdkkeysyms.h> +#endif #define MIME_TYPES_HANDLED "application/x-shockwave-flash" #define FAKE_MIME_TYPE "application/x-lightspark" @@ -257,13 +266,6 @@ Log::setLogLevel(log_level); lightspark::SystemState::staticInit(); - /* On linux, firefox runs its own gtk main loop - * which we can utilise through g_add_idle - * but we must not create our own gtk_main. - */ -#ifdef _WIN32 - EngineData::startGTKMain(); -#endif return NPERR_NO_ERROR; } @@ -271,9 +273,6 @@ { LOG(LOG_INFO,"Lightspark plugin shutdown"); lightspark::SystemState::staticDeinit(); -#ifdef _WIN32 - EngineData::quitGTKMain(); -#endif } // get values per plugin @@ -374,7 +373,8 @@ } else LOG(LOG_ERROR, "PLUGIN: Browser doesn't support NPRuntime"); - + EngineData::mainthread_running = true; + g_idle_add((GSourceFunc)EngineData::mainloop_from_plugin,m_sys); //The sys var should be NULL in this thread setTLSSys( NULL ); } @@ -455,63 +455,340 @@ return err; } +SDL_Keycode getSDLKeyCode(unsigned gdkKeyval) +{ + switch (gdkKeyval) + { + case GDK_a: return SDLK_a; + case GDK_Alt_L: return SDLK_LALT; + case GDK_b: return SDLK_b; + case GDK_Back: return SDLK_AC_BACK; + case GDK_grave: return SDLK_BACKQUOTE; + case GDK_backslash: return SDLK_BACKSLASH; + case GDK_BackSpace: return SDLK_BACKSPACE; + case GDK_Blue: return SDLK_UNKNOWN; // TODO + case GDK_c: return SDLK_c; + case GDK_Caps_Lock: return SDLK_CAPSLOCK; + case GDK_comma: return SDLK_COMMA; + case GDK_Control_L: return SDLK_LCTRL; + case GDK_d: return SDLK_d; + case GDK_Delete: return SDLK_DELETE; + case GDK_Down: return SDLK_DOWN; + case GDK_e: return SDLK_e; + case GDK_End: return SDLK_END; + case GDK_Return: return SDLK_RETURN; + case GDK_equal: return SDLK_EQUALS; + case GDK_Escape: return SDLK_ESCAPE; + case GDK_f: return SDLK_f; + case GDK_F1: return SDLK_F1; + case GDK_F2: return SDLK_F2; + case GDK_F3: return SDLK_F3; + case GDK_F4: return SDLK_F4; + case GDK_F5: return SDLK_F5; + case GDK_F6: return SDLK_F6; + case GDK_F7: return SDLK_F7; + case GDK_F8: return SDLK_F8; + case GDK_F9: return SDLK_F9; + case GDK_F10: return SDLK_F10; + case GDK_F11: return SDLK_F11; + case GDK_F12: return SDLK_F12; + case GDK_F13: return SDLK_F13; + case GDK_F14: return SDLK_F14; + case GDK_F15: return SDLK_F15; + case GDK_g: return SDLK_g; + case GDK_Green: return SDLK_UNKNOWN; // TODO + case GDK_h: return SDLK_h; + case GDK_Help: return SDLK_HELP; + case GDK_Home: return SDLK_HOME; + case GDK_i: return SDLK_i; + case GDK_Insert: return SDLK_INSERT; + case GDK_j: return SDLK_j; + case GDK_k: return SDLK_k; + case GDK_l: return SDLK_l; + case GDK_Left: return SDLK_LEFT; + case GDK_bracketleft: return SDLK_LEFTBRACKET; + case GDK_m: return SDLK_m; + case GDK_minus: return SDLK_MINUS; + case GDK_n: return SDLK_n; + case GDK_0: return SDLK_0; + case GDK_1: return SDLK_1; + case GDK_2: return SDLK_2; + case GDK_3: return SDLK_3; + case GDK_4: return SDLK_4; + case GDK_5: return SDLK_5; + case GDK_6: return SDLK_6; + case GDK_7: return SDLK_7; + case GDK_8: return SDLK_8; + case GDK_9: return SDLK_9; + case GDK_KP_0: return SDLK_KP_0; + case GDK_KP_1: return SDLK_KP_1; + case GDK_KP_2: return SDLK_KP_2; + case GDK_KP_3: return SDLK_KP_3; + case GDK_KP_4: return SDLK_KP_4; + case GDK_KP_5: return SDLK_KP_5; + case GDK_KP_6: return SDLK_KP_6; + case GDK_KP_7: return SDLK_KP_7; + case GDK_KP_8: return SDLK_KP_8; + case GDK_KP_9: return SDLK_KP_9; + case GDK_KP_Add: return SDLK_KP_MEMADD; + case GDK_KP_Separator: return SDLK_KP_PERIOD; // TODO + case GDK_KP_Divide: return SDLK_KP_DIVIDE; + case GDK_KP_Enter: return SDLK_KP_ENTER; + case GDK_KP_Multiply: return SDLK_KP_MULTIPLY; + case GDK_KP_Subtract: return SDLK_KP_MINUS; + case GDK_o: return SDLK_o; + case GDK_p: return SDLK_p; + case GDK_Page_Down: return SDLK_PAGEDOWN; + case GDK_Page_Up: return SDLK_PAGEUP; + case GDK_Pause: return SDLK_PAUSE; + case GDK_period: return SDLK_PERIOD; + case GDK_q: return SDLK_q; + case GDK_quoteright: return SDLK_QUOTE; + case GDK_r: return SDLK_r; + case GDK_Red: return SDLK_UNKNOWN; // TODO + case GDK_Right: return SDLK_RIGHT; + case GDK_bracketright: return SDLK_RIGHTBRACKET; + case GDK_s: return SDLK_s; + case GDK_Search: return SDLK_AC_SEARCH; + case GDK_semicolon: return SDLK_SEMICOLON; + case GDK_Shift_L: return SDLK_LSHIFT; + case GDK_slash: return SDLK_SLASH; + case GDK_space: return SDLK_SPACE; + case GDK_Subtitle: return SDLK_UNKNOWN; // TODO + case GDK_t: return SDLK_t; + case GDK_Tab: return SDLK_TAB; + case GDK_u: return SDLK_u; + case GDK_Up: return SDLK_UP; + case GDK_v: return SDLK_v; + case GDK_w: return SDLK_w; + case GDK_x: return SDLK_x; + case GDK_y: return SDLK_y; + case GDK_Yellow: return SDLK_UNKNOWN; // TODO + case GDK_z: return SDLK_z; + } + return SDLK_UNKNOWN; +}; +static uint16_t getKeyModifier(GdkEvent *event) +{ + uint16_t res = KMOD_NONE; + if (event->key.state & GDK_CONTROL_MASK) + res |= KMOD_CTRL; + if (event->key.state & GDK_MOD1_MASK) + res |= KMOD_ALT; + if (event->key.state & GDK_SHIFT_MASK) + res |= KMOD_SHIFT; + return res; +} -#ifdef _WIN32 -/* - * Create a GtkWidget and embed it into that mWindow. This unifies the other code, - * because on any platform and standalone/plugin, we always handle GtkWidgets. - * Additionally, firefox always crashed on me when trying to directly draw into - * mWindow. - * This must be run in the gtk_main() thread for AttachThreadInput to make sense. - */ -GtkWidget* PluginEngineData::createGtkWidget() -{ - HWND parent_hwnd = (HWND)instance->mWindow; - - GtkWidget* widget=gtk_window_new(GTK_WINDOW_TOPLEVEL); - /* Remove window decorations */ - gtk_window_set_decorated((GtkWindow*)widget, FALSE); - /* Realize to construct hwnd */ - gtk_widget_realize(widget); - HWND window = (HWND)GDK_WINDOW_HWND(gtk_widget_get_window(widget)); - /* Set WS_CHILD, remove WS_POPUP - see MSDN on SetParent */ - DWORD dwStyle = GetWindowLong (window, GWL_STYLE); - dwStyle |= WS_CHILD; - dwStyle &= ~WS_POPUP; - SetWindowLong(window, GWL_STYLE, dwStyle); - SetForegroundWindow(window); - /* Re-parent */ - SetParent(window, parent_hwnd); - /* Attach our thread to that of the parent. - * This ensures that we get messages for input events*/ - DWORD parentThreadId; - if(!(parentThreadId = GetWindowThreadProcessId(parent_hwnd, NULL))) - LOG(LOG_ERROR,"GetWindowThreadProcessId failed"); - DWORD myThreadId; - if(!(myThreadId = GetCurrentThreadId())) - LOG(LOG_ERROR,"GetCurrentThreadId failed"); - if(!AttachThreadInput(myThreadId, parentThreadId, TRUE)) - LOG(LOG_ERROR,"AttachThreadInput failed"); - /* Set window size */ - gtk_widget_set_size_request(widget, width, height); - - return widget; +static gboolean inputDispatch(GtkWidget *widget, GdkEvent *event, PluginEngineData* e) +{ + SDL_Event ev; + switch (event->type) + { + case GDK_EXPOSE: + { + ev.type = SDL_WINDOWEVENT; + ev.window.event = SDL_WINDOWEVENT_EXPOSED; + ev.window.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_KEY_PRESS: + { + ev.type = SDL_KEYDOWN; + ev.key.keysym.sym = getSDLKeyCode(event->key.keyval); + ev.key.keysym.mod = getKeyModifier(event); + SDL_SetModState((SDL_Keymod)ev.key.keysym.mod); + ev.key.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_KEY_RELEASE: + { + ev.type = SDL_KEYUP; + ev.key.keysym.sym = getSDLKeyCode(event->key.keyval); + ev.key.keysym.mod = getKeyModifier(event); + SDL_SetModState((SDL_Keymod)ev.key.keysym.mod); + ev.key.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_BUTTON_PRESS: + { + ev.type = SDL_MOUSEBUTTONDOWN; + switch (event->button.button) + { + case 1: + ev.button.button = SDL_BUTTON_LEFT; + ev.button.state = event->button.state & GDK_BUTTON1_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + case 2: + ev.button.button = SDL_BUTTON_RIGHT; + ev.button.state = event->button.state & GDK_BUTTON2_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + default: + ev.button.button = 0; + ev.button.state = SDL_RELEASED; + break; + } + ev.button.clicks = 1; + ev.button.x = event->button.x; + ev.button.y = event->button.y; + ev.button.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_2BUTTON_PRESS: + { + ev.type = SDL_MOUSEBUTTONDOWN; + switch (event->button.button) + { + case 1: + ev.button.button = SDL_BUTTON_LEFT; + ev.button.state = event->button.state & GDK_BUTTON1_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + case 2: + ev.button.button = SDL_BUTTON_RIGHT; + ev.button.state = event->button.state & GDK_BUTTON2_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + default: + ev.button.button = 0; + ev.button.state = SDL_RELEASED; + break; + } + ev.button.clicks = 2; + ev.button.x = event->button.x; + ev.button.y = event->button.y; + ev.button.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_BUTTON_RELEASE: + { + ev.type = SDL_MOUSEBUTTONUP; + switch (event->button.button) + { + case 1: + ev.button.button = SDL_BUTTON_LEFT; + ev.button.state = event->button.state & GDK_BUTTON1_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + case 2: + ev.button.button = SDL_BUTTON_RIGHT; + ev.button.state = event->button.state & GDK_BUTTON2_MASK ? SDL_PRESSED : SDL_RELEASED; + break; + default: + ev.button.button = 0; + ev.button.state = SDL_RELEASED; + break; + } + ev.button.clicks = 0; + ev.button.x = event->button.x; + ev.button.y = event->button.y; + ev.button.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_MOTION_NOTIFY: + { + ev.type = SDL_MOUSEMOTION; + ev.motion.state = event->motion.state & GDK_BUTTON1_MASK ? SDL_PRESSED : SDL_RELEASED; + ev.motion.x = event->motion.x; + ev.motion.y = event->motion.y; + ev.motion.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_SCROLL: + { + ev.type = SDL_MOUSEWHEEL; + ev.wheel.direction = event->scroll.state == GDK_SCROLL_UP ? SDL_MOUSEWHEEL_NORMAL : SDL_MOUSEWHEEL_FLIPPED ; + ev.wheel.x = event->scroll.x; + ev.wheel.y = event->scroll.y; + ev.wheel.windowID = SDL_GetWindowID(e->widget); + break; + } + case GDK_LEAVE_NOTIFY: + { + ev.type = SDL_WINDOWEVENT_LEAVE; + ev.wheel.windowID = SDL_GetWindowID(e->widget); + break; + } + default: +#ifdef EXPENSIVE_DEBUG + LOG(LOG_INFO, "GDKTYPE " << event->type); +#endif + return false; + } + EngineData::mainloop_handleevent(&ev,e->sys); + return true; } -#else -GtkWidget* PluginEngineData::createGtkWidget() +static void sizeDispatch(GtkWidget* widget, GdkRectangle* allocation, PluginEngineData* e) { - return gtk_plug_new(instance->mWindow); + SDL_Event ev; + ev.type = SDL_WINDOWEVENT; + ev.window.event = SDL_WINDOWEVENT_SIZE_CHANGED; + ev.window.data1 = allocation->width; + ev.window.data2 = allocation->height; + ev.window.windowID = SDL_GetWindowID(e->widget); + + EngineData::mainloop_handleevent(&ev,e->sys); } + + +SDL_Window* PluginEngineData::createWidget(uint32_t w,uint32_t h) +{ + widget_gtk = gtk_plug_new(instance->mWindow); + gdk_threads_enter(); + gtk_widget_realize(widget_gtk); +#if _WIN32 + windowID = GDK_WINDOW_HWND(gtk_widget_get_window(widget_gtk)); +#else + windowID = GDK_WINDOW_XID(gtk_widget_get_window(widget_gtk)); #endif + + gtk_widget_set_size_request(widget_gtk, w, h); + gtk_widget_show(widget_gtk); + gtk_widget_map(widget_gtk); + gtk_widget_set_can_focus(widget_gtk,TRUE); + gtk_widget_add_events(widget_gtk, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | + GDK_LEAVE_NOTIFY_MASK); + inputHandlerId = g_signal_connect(widget_gtk, "event", G_CALLBACK(inputDispatch), this); + sizeHandlerId = g_signal_connect(widget_gtk, "size-allocate", G_CALLBACK(sizeDispatch), this); + + SDL_Window* sdlwin = SDL_CreateWindowFrom((const void*)gdk_x11_drawable_get_xid(gtk_widget_get_window(widget_gtk))); + gdk_threads_leave(); + return sdlwin; +} void PluginEngineData::grabFocus() { - if (!widget) + if (!widget_gtk) return; - gtk_widget_grab_focus(widget); + gtk_widget_grab_focus(widget_gtk); +} + +void PluginEngineData::setClipboardText(const std::string txt) +{ + GtkClipboard *clipboard; + clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + gtk_clipboard_set_text(clipboard, txt.c_str(),txt.size()); + clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text(clipboard, txt.c_str(), txt.size()); + LOG(LOG_INFO, "Copied error to clipboard"); +} + +bool PluginEngineData::getScreenData(SDL_DisplayMode *screen) +{ + GdkScreen* s = gdk_screen_get_default(); + screen->w = gdk_screen_get_width (s); + screen->h = gdk_screen_get_height (s); + return true; } +double PluginEngineData::getScreenDPI() +{ + GdkScreen* screen = gdk_screen_get_default(); + return gdk_screen_get_resolution (screen); +} + + NPError nsPluginInstance::SetWindow(NPWindow* aWindow) { if(aWindow == NULL) @@ -540,7 +817,7 @@ } assert(mWindow==0); - PluginEngineData* e = new PluginEngineData(this, width, height); + PluginEngineData* e = new PluginEngineData(this, width, height,m_sys); mWindow = win; LOG(LOG_INFO,"From Browser: Window " << mWindow << " Width: " << width << " Height: " << height); @@ -783,7 +1060,7 @@ instance->mainDownloader->stop(); } -GdkNativeWindow PluginEngineData::getWindowForGnash() +uint32_t PluginEngineData::getWindowForGnash() { return instance->mWindow; }
View file
lightspark.tar.xz/src/plugin/plugin.h
Changed
@@ -31,6 +31,8 @@ #include "backends/netutils.h" #include "backends/urlutils.h" #include "plugin/npscriptobject.h" +#include <gtk/gtk.h> +#include <gdk/gdk.h> namespace lightspark { @@ -75,25 +77,35 @@ { private: nsPluginInstance* instance; + gulong inputHandlerId; + gulong sizeHandlerId; + GtkWidget* widget_gtk; public: - PluginEngineData(nsPluginInstance* i, uint32_t w, uint32_t h) : instance(i) + SystemState* sys; + PluginEngineData(nsPluginInstance* i, uint32_t w, uint32_t h,SystemState* _sys) : instance(i),inputHandlerId(0),sizeHandlerId(0),widget_gtk(NULL),sys(_sys) { width = w; height = h; } - /* The widget must not be gtk_widget_destroy'ed in the destructor. This is done - * by firefox. - */ - ~PluginEngineData() {} + ~PluginEngineData() + { + if(inputHandlerId) + g_signal_handler_disconnect(widget, inputHandlerId); + if(sizeHandlerId) + g_signal_handler_disconnect(widget, sizeHandlerId); + } void stopMainDownload(); bool isSizable() const { return false; } - GdkNativeWindow getWindowForGnash(); - /* must be called within the gtk_main() thread and within gdk_threads_enter/leave */ - GtkWidget* createGtkWidget(); - /* must be called within the gtk_main() thread and within gdk_threads_enter/leave */ + uint32_t getWindowForGnash(); + /* must be called within mainLoopThread */ + SDL_Window* createWidget(uint32_t w,uint32_t h); + /* must be called within mainLoopThread */ void grabFocus(); void openPageInBrowser(const tiny_string& url, const tiny_string& window); + void setClipboardText(const std::string txt); + bool getScreenData(SDL_DisplayMode* screen); + double getScreenDPI(); }; class nsPluginInstance : public nsPluginInstanceBase
View file
lightspark.tar.xz/src/scripting/flash/events/flashevents.cpp
Changed
@@ -229,19 +229,19 @@ } MouseEvent::MouseEvent(Class_base* c) - : Event(c, "mouseEvent"), modifiers(0), delta(1), localX(0), localY(0), stageX(0), stageY(0), relatedObject(NullRef) + : Event(c, "mouseEvent"), modifiers(KMOD_NONE),buttonDown(false), delta(1), localX(0), localY(0), stageX(0), stageY(0), relatedObject(NullRef) { } MouseEvent::MouseEvent(Class_base* c, const tiny_string& t, number_t lx, number_t ly, - bool b, unsigned int buttonState, _NR<InteractiveObject> relObj, int32_t _delta) - : Event(c,t,b), modifiers(buttonState), delta(_delta), localX(lx), localY(ly), stageX(0), stageY(0), relatedObject(relObj) + bool b, SDL_Keymod _modifiers, bool _buttonDown, _NR<InteractiveObject> relObj, int32_t _delta) + : Event(c,t,b), modifiers(_modifiers), buttonDown(_buttonDown),delta(_delta), localX(lx), localY(ly), stageX(0), stageY(0), relatedObject(relObj) { } Event* MouseEvent::cloneImpl() const { - return Class<MouseEvent>::getInstanceS(getSystemState(),type,localX,localY,bubbles,modifiers,relatedObject,delta); + return Class<MouseEvent>::getInstanceS(getSystemState(),type,localX,localY,bubbles,(SDL_Keymod)modifiers,buttonDown,relatedObject,delta); } ProgressEvent::ProgressEvent(Class_base* c):Event(c, "progress",false),bytesLoaded(0),bytesTotal(0) @@ -339,23 +339,27 @@ th->relatedObject=ArgumentConversion< _NR<InteractiveObject> >::toConcrete(args[5]); if(argslen>=7) if (ArgumentConversion<bool>::toConcrete(args[6])) - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; if(argslen>=8) if (ArgumentConversion<bool>::toConcrete(args[7])) - th->modifiers |= GDK_MOD1_MASK; + th->modifiers |= KMOD_ALT; if(argslen>=9) if (ArgumentConversion<bool>::toConcrete(args[8])) - th->modifiers |= GDK_SHIFT_MASK; + th->modifiers |= KMOD_SHIFT; if(argslen>=10) if (ArgumentConversion<bool>::toConcrete(args[9])) - th->modifiers |= GDK_BUTTON1_MASK; + th->buttonDown = true; if(argslen>=11) th->delta=args[10]->toInt(); - // TODO: args[11] = command + if(argslen>=12) + if (ArgumentConversion<bool>::toConcrete(args[11])) + th->modifiers |= KMOD_GUI; if(argslen>=13) if (ArgumentConversion<bool>::toConcrete(args[12])) - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; // TODO: args[13] = clickCount + if(argslen>=14) + LOG(LOG_NOT_IMPLEMENTED,"MouseEvent: clickcount"); return NULL; } @@ -404,65 +408,65 @@ ASFUNCTIONBODY(MouseEvent,_getter_buttonDown) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_BUTTON1_MASK); + return abstract_b(obj->getSystemState(),th->buttonDown); } ASFUNCTIONBODY(MouseEvent,_setter_buttonDown) { MouseEvent* th=static_cast<MouseEvent*>(obj); - th->modifiers |= GDK_BUTTON1_MASK; + th->buttonDown = true; return NULL; } ASFUNCTIONBODY(MouseEvent,_getter_altKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_MOD1_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_ALT); } ASFUNCTIONBODY(MouseEvent,_setter_altKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - th->modifiers |= GDK_MOD1_MASK; + th->modifiers |= KMOD_ALT; return NULL; } ASFUNCTIONBODY(MouseEvent,_getter_controlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_CTRL); } ASFUNCTIONBODY(MouseEvent,_setter_controlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; return NULL; } ASFUNCTIONBODY(MouseEvent,_getter_ctrlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_CTRL); } ASFUNCTIONBODY(MouseEvent,_setter_ctrlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; return NULL; } ASFUNCTIONBODY(MouseEvent,_getter_shiftKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_SHIFT_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_SHIFT); } ASFUNCTIONBODY(MouseEvent,_setter_shiftKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - th->modifiers |= GDK_SHIFT_MASK; + th->modifiers |= KMOD_SHIFT; return NULL; } ASFUNCTIONBODY(MouseEvent,updateAfterEvent) @@ -832,7 +836,7 @@ return NULL; } -KeyboardEvent::KeyboardEvent(Class_base* c, tiny_string _type, uint32_t _charcode, uint32_t _keycode, unsigned _modifiers) +KeyboardEvent::KeyboardEvent(Class_base* c, tiny_string _type, uint32_t _charcode, uint32_t _keycode, SDL_Keymod _modifiers) : Event(c, _type), modifiers(_modifiers), charCode(_charcode), keyCode(_keycode), keyLocation(0) { } @@ -870,21 +874,25 @@ } if(argslen > 6) { if (ArgumentConversion<bool>::toConcrete(args[6])) - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; } if(argslen > 7) { if (ArgumentConversion<bool>::toConcrete(args[7])) - th->modifiers |= GDK_MOD1_MASK; + th->modifiers |= KMOD_ALT; } if(argslen > 8) { if (ArgumentConversion<bool>::toConcrete(args[8])) - th->modifiers |= GDK_SHIFT_MASK; + th->modifiers |= KMOD_SHIFT; } if(argslen > 9) { if (ArgumentConversion<bool>::toConcrete(args[9])) - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; } // args[10] (commandKeyValue) is only supported on Max OSX + if(argslen > 10) { + if (ArgumentConversion<bool>::toConcrete(args[10])) + LOG(LOG_NOT_IMPLEMENTED,"KeyboardEvent:commandKeyValue"); + } return NULL; } @@ -896,13 +904,13 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_altKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_MOD1_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_ALT); } ASFUNCTIONBODY(KeyboardEvent, _setter_altKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - th->modifiers |= GDK_MOD1_MASK; + th->modifiers |= KMOD_ALT; return NULL; } @@ -921,39 +929,39 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_controlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_CTRL); } ASFUNCTIONBODY(KeyboardEvent, _setter_controlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; return NULL; } ASFUNCTIONBODY(KeyboardEvent, _getter_ctrlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_CTRL); } ASFUNCTIONBODY(KeyboardEvent, _setter_ctrlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - th->modifiers |= GDK_CONTROL_MASK; + th->modifiers |= KMOD_CTRL; return NULL; } ASFUNCTIONBODY(KeyboardEvent, _getter_shiftKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(obj->getSystemState(),th->modifiers & GDK_SHIFT_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & KMOD_SHIFT); } ASFUNCTIONBODY(KeyboardEvent, _setter_shiftKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - th->modifiers |= GDK_SHIFT_MASK; + th->modifiers |= KMOD_SHIFT; return NULL; }
View file
lightspark.tar.xz/src/scripting/flash/events/flashevents.h
Changed
@@ -25,7 +25,7 @@ #include "scripting/toplevel/toplevel.h" #include "backends/extscriptobject.h" #include <string> - +#include <SDL2/SDL_keyboard.h> #undef MOUSE_EVENT namespace lightspark @@ -102,12 +102,12 @@ private: virtual Event* cloneImpl() const; - unsigned int modifiers; // bitflags of GdkModifierType constants + uint32_t modifiers; ASPROPERTY_GETTER_SETTER(uint32_t, charCode); ASPROPERTY_GETTER_SETTER(uint32_t, keyCode); ASPROPERTY_GETTER_SETTER(uint32_t, keyLocation); public: - KeyboardEvent(Class_base* c, tiny_string type="", uint32_t charcode=0, uint32_t keycode=0, unsigned modifiers=0); + KeyboardEvent(Class_base* c, tiny_string type="", uint32_t charcode=0, uint32_t keycode=0, SDL_Keymod modifiers=KMOD_NONE); static void sinit(Class_base*); static void buildTraits(ASObject* o) { @@ -268,12 +268,13 @@ class MouseEvent: public Event { private: - unsigned int modifiers; // bitflags of GdkModifierType constants + uint32_t modifiers; + bool buttonDown; Event* cloneImpl() const; public: MouseEvent(Class_base* c); MouseEvent(Class_base* c, const tiny_string& t, number_t lx, number_t ly, - bool b=true, unsigned int buttonState=0, + bool b=true, SDL_Keymod _modifiers=KMOD_NONE,bool _buttonDown = false, _NR<InteractiveObject> relObj = NullRef, int32_t delta=1); static void sinit(Class_base*); static void buildTraits(ASObject* o);
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.cpp
Changed
@@ -496,9 +496,8 @@ if(audioDecoder==NULL && streamDecoder->audioDecoder) audioDecoder=streamDecoder->audioDecoder; - //TODO: Move the audio plugin check before - if(audioStream==NULL && audioDecoder && audioDecoder->isValid() && getSys()->audioManager->pluginLoaded()) - audioStream=getSys()->audioManager->createStreamPlugin(audioDecoder,false); + if(audioStream==NULL && audioDecoder && audioDecoder->isValid()) + audioStream=getSys()->audioManager->createStream(audioDecoder,false); // TODO: check the position only when the getter is called if(audioStream) @@ -559,8 +558,6 @@ true); if (!decoder) return; - if(!getSys()->audioManager->pluginLoaded()) - return; AudioStream *audioStream = NULL; std::streambuf *sbuf = stream->createReader(); @@ -569,7 +566,7 @@ { decoder->decodeStreamSomePackets(stream, 0,this); if (decoder->isValid() && (audioStream == NULL)) - audioStream=getSys()->audioManager->createStreamPlugin(decoder,false); + audioStream=getSys()->audioManager->createStream(decoder,false); if(threadAborting) break; }
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.cpp
Changed
@@ -1678,7 +1678,7 @@ void NetStream::tick() { //Check if the stream is paused - if(audioStream && audioStream->isValid()) + if(audioStream) { //TODO: use soundTransform->pan if(soundTransform && soundTransform->volume != oldVolume) @@ -1689,14 +1689,14 @@ } if(paused) return; - if(audioStream && audioStream->isValid() && !audioStream->hasStarted) + if(audioStream && !audioStream->hasStarted) { audioStream->hasStarted = true; audioStream->resume(); } //Advance video and audio to current time, follow the audio stream time countermutex.lock(); - if(audioStream && getSys()->audioManager->isTimingAvailablePlugin()) + if(audioStream) { assert(audioDecoder); if (streamTime == 0) @@ -1882,8 +1882,8 @@ if(audioDecoder==NULL && streamDecoder->audioDecoder) audioDecoder=streamDecoder->audioDecoder; - if(audioStream==NULL && audioDecoder && audioDecoder->isValid() && getSys()->audioManager->pluginLoaded()) - audioStream=getSys()->audioManager->createStreamPlugin(audioDecoder,streamDecoder->hasVideo()); + if(audioStream==NULL && audioDecoder && audioDecoder->isValid()) + audioStream=getSys()->audioManager->createStream(audioDecoder,streamDecoder->hasVideo()); if(!tickStarted && isReady() && frameRate && ((framesdecoded / frameRate) >= this->bufferTime)) { tickStarted=true;
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.h
Changed
@@ -27,7 +27,7 @@ #include "backends/netutils.h" #include "timer.h" #include "backends/decoder.h" -#include "backends/interfaces/audio/IAudioPlugin.h" +#include "backends/audio.h" #include "NetStreamInfo.h" #include "scripting/flash/utils/ByteArray.h"
View file
lightspark.tar.xz/src/scripting/flash/sensors/flashsensors.h
Changed
@@ -26,7 +26,6 @@ #include "thread_pool.h" #include "backends/netutils.h" #include "timer.h" -#include "backends/interfaces/audio/IAudioPlugin.h" namespace lightspark {
View file
lightspark.tar.xz/src/scripting/flash/system/flashsystem.cpp
Changed
@@ -27,7 +27,6 @@ #include "scripting/toplevel/XMLList.h" #include <istream> -#include <gdk/gdk.h> using namespace lightspark; @@ -123,12 +122,14 @@ res +="&M="; res += MANUFACTURER; - GdkScreen* screen = gdk_screen_get_default(); - gint width = gdk_screen_get_width (screen); - gint height = gdk_screen_get_height (screen); - char buf[40]; - snprintf(buf,40,"&R=%ix%i",width,height); - res += buf; + SDL_DisplayMode screen; + if (obj->getSystemState()->getEngineData()->getScreenData(&screen)) { + gint width = screen.w; + gint height = screen.h; + char buf[40]; + snprintf(buf,40,"&R=%ix%i",width,height); + res += buf; + } /* avHardwareDisable AVD @@ -169,15 +170,17 @@ } ASFUNCTIONBODY(Capabilities,_getScreenResolutionX) { - GdkScreen* screen = gdk_screen_get_default(); - gint width = gdk_screen_get_width (screen); - return abstract_d(obj->getSystemState(),width); + SDL_DisplayMode screen; + if (!obj->getSystemState()->getEngineData()->getScreenData(&screen)) + return abstract_di(obj->getSystemState(),0); + return abstract_di(obj->getSystemState(),screen.w); } ASFUNCTIONBODY(Capabilities,_getScreenResolutionY) { - GdkScreen* screen = gdk_screen_get_default(); - gint height = gdk_screen_get_height (screen); - return abstract_d(obj->getSystemState(),height); + SDL_DisplayMode screen; + if (!obj->getSystemState()->getEngineData()->getScreenData(&screen)) + return abstract_di(obj->getSystemState(),0); + return abstract_di(obj->getSystemState(),screen.h); } ASFUNCTIONBODY(Capabilities,_getHasAccessibility) { @@ -186,8 +189,7 @@ } ASFUNCTIONBODY(Capabilities,_getScreenDPI) { - GdkScreen* screen = gdk_screen_get_default(); - gdouble dpi = gdk_screen_get_resolution (screen); + number_t dpi = obj->getSystemState()->getEngineData()->getScreenDPI(); return abstract_d(obj->getSystemState(),dpi); }
View file
lightspark.tar.xz/src/scripting/flash/ui/Keyboard.cpp
Changed
@@ -21,6 +21,7 @@ #include "scripting/class.h" #include "scripting/toplevel/ASString.h" #include "backends/input.h" +#include "scripting/flash/ui/keycodes.h" using namespace std; using namespace lightspark; @@ -34,13 +35,281 @@ c->setDeclaredMethodByQName("physicalKeyboardType","",Class<IFunction>::getFunction(c->getSystemState(),physicalKeyboardType),GETTER_METHOD,true); c->setDeclaredMethodByQName("isAccessible","",Class<IFunction>::getFunction(c->getSystemState(),isAccessible),NORMAL_METHOD,true); - // key code constants - const std::vector<KeyNameCodePair>& keys = getSys()->getInputThread()->getKeyNamesAndCodes(); - std::vector<KeyNameCodePair>::const_iterator it; - for (it=keys.begin(); it!=keys.end(); ++it) - { - c->setVariableByQName(it->keyname,"",abstract_ui(c->getSystemState(),it->keycode),DECLARED_TRAIT); - } + c->setVariableByQName("A","",abstract_ui(c->getSystemState(),AS3KEYCODE_A ),CONSTANT_TRAIT); + c->setVariableByQName("ALTERNATE","",abstract_ui(c->getSystemState(),AS3KEYCODE_ALTERNATE),CONSTANT_TRAIT); + c->setVariableByQName("AUDIO","",abstract_ui(c->getSystemState(),AS3KEYCODE_AUDIO),CONSTANT_TRAIT); + c->setVariableByQName("B","",abstract_ui(c->getSystemState(),AS3KEYCODE_B),CONSTANT_TRAIT); + c->setVariableByQName("BACK","",abstract_ui(c->getSystemState(),AS3KEYCODE_BACK),CONSTANT_TRAIT); + c->setVariableByQName("BACKQUOTE","",abstract_ui(c->getSystemState(),AS3KEYCODE_BACKQUOTE),CONSTANT_TRAIT); + c->setVariableByQName("BACKSLASH","",abstract_ui(c->getSystemState(),AS3KEYCODE_BACKSLASH),CONSTANT_TRAIT); + c->setVariableByQName("BACKSPACE","",abstract_ui(c->getSystemState(),AS3KEYCODE_BACKSPACE),CONSTANT_TRAIT); + c->setVariableByQName("BLUE","",abstract_ui(c->getSystemState(),AS3KEYCODE_BLUE),CONSTANT_TRAIT); + c->setVariableByQName("C","",abstract_ui(c->getSystemState(),AS3KEYCODE_C),CONSTANT_TRAIT); + c->setVariableByQName("CAPS_LOCK","",abstract_ui(c->getSystemState(),AS3KEYCODE_CAPS_LOCK),CONSTANT_TRAIT); + c->setVariableByQName("CHANNEL_DOWN","",abstract_ui(c->getSystemState(),AS3KEYCODE_CHANNEL_DOWN),CONSTANT_TRAIT); + c->setVariableByQName("CHANNEL_UP","",abstract_ui(c->getSystemState(),AS3KEYCODE_CHANNEL_UP),CONSTANT_TRAIT); + c->setVariableByQName("COMMA","",abstract_ui(c->getSystemState(),AS3KEYCODE_COMMA),CONSTANT_TRAIT); + c->setVariableByQName("COMMAND","",abstract_ui(c->getSystemState(),AS3KEYCODE_COMMAND),CONSTANT_TRAIT); + c->setVariableByQName("CONTROL","",abstract_ui(c->getSystemState(),AS3KEYCODE_CONTROL),CONSTANT_TRAIT); + c->setVariableByQName("D","",abstract_ui(c->getSystemState(),AS3KEYCODE_D),CONSTANT_TRAIT); + c->setVariableByQName("DELETE","",abstract_ui(c->getSystemState(),AS3KEYCODE_DELETE),CONSTANT_TRAIT); + c->setVariableByQName("DOWN","",abstract_ui(c->getSystemState(),AS3KEYCODE_DOWN),CONSTANT_TRAIT); + c->setVariableByQName("DVR","",abstract_ui(c->getSystemState(),AS3KEYCODE_DVR),CONSTANT_TRAIT); + c->setVariableByQName("E","",abstract_ui(c->getSystemState(),AS3KEYCODE_E),CONSTANT_TRAIT); + c->setVariableByQName("END","",abstract_ui(c->getSystemState(),AS3KEYCODE_END),CONSTANT_TRAIT); + c->setVariableByQName("ENTER","",abstract_ui(c->getSystemState(),AS3KEYCODE_ENTER),CONSTANT_TRAIT); + c->setVariableByQName("EQUAL","",abstract_ui(c->getSystemState(),AS3KEYCODE_EQUAL),CONSTANT_TRAIT); + c->setVariableByQName("ESCAPE","",abstract_ui(c->getSystemState(),AS3KEYCODE_ESCAPE),CONSTANT_TRAIT); + c->setVariableByQName("EXIT","",abstract_ui(c->getSystemState(),AS3KEYCODE_EXIT),CONSTANT_TRAIT); + c->setVariableByQName("F","",abstract_ui(c->getSystemState(),AS3KEYCODE_F),CONSTANT_TRAIT); + c->setVariableByQName("F1","",abstract_ui(c->getSystemState(),AS3KEYCODE_F1),CONSTANT_TRAIT); + c->setVariableByQName("F10","",abstract_ui(c->getSystemState(),AS3KEYCODE_F10),CONSTANT_TRAIT); + c->setVariableByQName("F11","",abstract_ui(c->getSystemState(),AS3KEYCODE_F11),CONSTANT_TRAIT); + c->setVariableByQName("F12","",abstract_ui(c->getSystemState(),AS3KEYCODE_F12),CONSTANT_TRAIT); + c->setVariableByQName("F13","",abstract_ui(c->getSystemState(),AS3KEYCODE_F13),CONSTANT_TRAIT); + c->setVariableByQName("F14","",abstract_ui(c->getSystemState(),AS3KEYCODE_F14),CONSTANT_TRAIT); + c->setVariableByQName("F15","",abstract_ui(c->getSystemState(),AS3KEYCODE_F15),CONSTANT_TRAIT); + c->setVariableByQName("F2","",abstract_ui(c->getSystemState(),AS3KEYCODE_F2),CONSTANT_TRAIT); + c->setVariableByQName("F3","",abstract_ui(c->getSystemState(),AS3KEYCODE_F3),CONSTANT_TRAIT); + c->setVariableByQName("F4","",abstract_ui(c->getSystemState(),AS3KEYCODE_F4),CONSTANT_TRAIT); + c->setVariableByQName("F5","",abstract_ui(c->getSystemState(),AS3KEYCODE_F5),CONSTANT_TRAIT); + c->setVariableByQName("F6","",abstract_ui(c->getSystemState(),AS3KEYCODE_F6),CONSTANT_TRAIT); + c->setVariableByQName("F7","",abstract_ui(c->getSystemState(),AS3KEYCODE_F7),CONSTANT_TRAIT); + c->setVariableByQName("F8","",abstract_ui(c->getSystemState(),AS3KEYCODE_F8),CONSTANT_TRAIT); + c->setVariableByQName("F9","",abstract_ui(c->getSystemState(),AS3KEYCODE_F9),CONSTANT_TRAIT); + c->setVariableByQName("FAST_FORWARD","",abstract_ui(c->getSystemState(),AS3KEYCODE_FAST_FORWARD),CONSTANT_TRAIT); + c->setVariableByQName("G","",abstract_ui(c->getSystemState(),AS3KEYCODE_G),CONSTANT_TRAIT); + c->setVariableByQName("GREEN","",abstract_ui(c->getSystemState(),AS3KEYCODE_GREEN),CONSTANT_TRAIT); + c->setVariableByQName("GUIDE","",abstract_ui(c->getSystemState(),AS3KEYCODE_GUIDE),CONSTANT_TRAIT); + c->setVariableByQName("H","",abstract_ui(c->getSystemState(),AS3KEYCODE_H),CONSTANT_TRAIT); + c->setVariableByQName("HELP","",abstract_ui(c->getSystemState(),AS3KEYCODE_HELP),CONSTANT_TRAIT); + c->setVariableByQName("HOME","",abstract_ui(c->getSystemState(),AS3KEYCODE_HOME),CONSTANT_TRAIT); + c->setVariableByQName("I","",abstract_ui(c->getSystemState(),AS3KEYCODE_I),CONSTANT_TRAIT); + c->setVariableByQName("INFO","",abstract_ui(c->getSystemState(),AS3KEYCODE_INFO),CONSTANT_TRAIT); + c->setVariableByQName("INPUT","",abstract_ui(c->getSystemState(),AS3KEYCODE_INPUT),CONSTANT_TRAIT); + c->setVariableByQName("INSERT","",abstract_ui(c->getSystemState(),AS3KEYCODE_INSERT),CONSTANT_TRAIT); + c->setVariableByQName("J","",abstract_ui(c->getSystemState(),AS3KEYCODE_J),CONSTANT_TRAIT); + c->setVariableByQName("K","",abstract_ui(c->getSystemState(),AS3KEYCODE_K),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_BEGIN","",abstract_s(c->getSystemState(),"Begin"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_BREAK","",abstract_s(c->getSystemState(),"Break"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_CLEARDISPLAY","",abstract_s(c->getSystemState(),"ClrDsp"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_CLEARLINE","",abstract_s(c->getSystemState(),"ClrLn"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_DELETE","",abstract_s(c->getSystemState(),"Delete"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_DELETECHAR","",abstract_s(c->getSystemState(),"DelChr"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_DELETELINE","",abstract_s(c->getSystemState(),"DelLn"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_DOWNARROW","",abstract_s(c->getSystemState(),"Down"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_END","",abstract_s(c->getSystemState(),"End"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_EXECUTE","",abstract_s(c->getSystemState(),"Exec"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F1","",abstract_s(c->getSystemState(),"F1"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F10","",abstract_s(c->getSystemState(),"F10"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F11","",abstract_s(c->getSystemState(),"F11"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F12","",abstract_s(c->getSystemState(),"F12"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F13","",abstract_s(c->getSystemState(),"F13"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F14","",abstract_s(c->getSystemState(),"F14"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F15","",abstract_s(c->getSystemState(),"F15"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F16","",abstract_s(c->getSystemState(),"F16"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F17","",abstract_s(c->getSystemState(),"F17"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F18","",abstract_s(c->getSystemState(),"F18"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F19","",abstract_s(c->getSystemState(),"F19"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F2","",abstract_s(c->getSystemState(),"F2"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F20","",abstract_s(c->getSystemState(),"F20"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F21","",abstract_s(c->getSystemState(),"F21"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F22","",abstract_s(c->getSystemState(),"F22"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F23","",abstract_s(c->getSystemState(),"F23"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F24","",abstract_s(c->getSystemState(),"F24"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F25","",abstract_s(c->getSystemState(),"F25"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F26","",abstract_s(c->getSystemState(),"F26"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F27","",abstract_s(c->getSystemState(),"F27"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F28","",abstract_s(c->getSystemState(),"F28"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F29","",abstract_s(c->getSystemState(),"F29"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F3","",abstract_s(c->getSystemState(),"F3"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F30","",abstract_s(c->getSystemState(),"F30"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F31","",abstract_s(c->getSystemState(),"F31"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F32","",abstract_s(c->getSystemState(),"F32"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F33","",abstract_s(c->getSystemState(),"F33"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F34","",abstract_s(c->getSystemState(),"F34"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F35","",abstract_s(c->getSystemState(),"F35"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F4","",abstract_s(c->getSystemState(),"F4"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F5","",abstract_s(c->getSystemState(),"F5"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F6","",abstract_s(c->getSystemState(),"F6"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F7","",abstract_s(c->getSystemState(),"F7"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F8","",abstract_s(c->getSystemState(),"F8"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_F9","",abstract_s(c->getSystemState(),"F9"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_FIND","",abstract_s(c->getSystemState(),"Find"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_HELP","",abstract_s(c->getSystemState(),"Help"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_HOME","",abstract_s(c->getSystemState(),"Home"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_INSERT","",abstract_s(c->getSystemState(),"Insert"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_INSERTCHAR","",abstract_s(c->getSystemState(),"InsChr"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_INSERTLINE","",abstract_s(c->getSystemState(),"InsLn"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_LEFTARROW","",abstract_s(c->getSystemState(),"Left"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_MENU","",abstract_s(c->getSystemState(),"Menu"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_MODESWITCH","",abstract_s(c->getSystemState(),"ModeSw"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_NEXT","",abstract_s(c->getSystemState(),"Next"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PAGEDOWN","",abstract_s(c->getSystemState(),"PgDn"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PAGEUP","",abstract_s(c->getSystemState(),"PgUp"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PAUSE","",abstract_s(c->getSystemState(),"Pause"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PREV","",abstract_s(c->getSystemState(),"Prev"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PRINT","",abstract_s(c->getSystemState(),"Print"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_PRINTSCREEN","",abstract_s(c->getSystemState(),"PrntScrn"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_REDO","",abstract_s(c->getSystemState(),"Redo"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_RESET","",abstract_s(c->getSystemState(),"Reset"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_RIGHTARROW","",abstract_s(c->getSystemState(),"Right"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_SCROLLLOCK","",abstract_s(c->getSystemState(),"ScrlLck"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_SELECT","",abstract_s(c->getSystemState(),"Select"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_STOP","",abstract_s(c->getSystemState(),"Stop"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_SYSREQ","",abstract_s(c->getSystemState(),"SysReq"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_SYSTEM","",abstract_s(c->getSystemState(),"Sys"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_UNDO","",abstract_s(c->getSystemState(),"Undo"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_UPARROW","",abstract_s(c->getSystemState(),"Up"),CONSTANT_TRAIT); + c->setVariableByQName("KEYNAME_USER","",abstract_s(c->getSystemState(),"User"),CONSTANT_TRAIT); + c->setVariableByQName("L","",abstract_ui(c->getSystemState(),AS3KEYCODE_L),CONSTANT_TRAIT); + c->setVariableByQName("LAST","",abstract_ui(c->getSystemState(),AS3KEYCODE_LAST),CONSTANT_TRAIT); + c->setVariableByQName("LEFT","",abstract_ui(c->getSystemState(),AS3KEYCODE_LEFT),CONSTANT_TRAIT); + c->setVariableByQName("LEFTBRACKET","",abstract_ui(c->getSystemState(),AS3KEYCODE_LEFTBRACKET),CONSTANT_TRAIT); + c->setVariableByQName("LIVE","",abstract_ui(c->getSystemState(),AS3KEYCODE_LIVE),CONSTANT_TRAIT); + c->setVariableByQName("M","",abstract_ui(c->getSystemState(),AS3KEYCODE_M),CONSTANT_TRAIT); + c->setVariableByQName("MASTER_SHELL","",abstract_ui(c->getSystemState(),AS3KEYCODE_MASTER_SHELL),CONSTANT_TRAIT); + c->setVariableByQName("MENU","",abstract_ui(c->getSystemState(),AS3KEYCODE_MENU),CONSTANT_TRAIT); + c->setVariableByQName("MINUS","",abstract_ui(c->getSystemState(),AS3KEYCODE_MINUS),CONSTANT_TRAIT); + c->setVariableByQName("N","",abstract_ui(c->getSystemState(),AS3KEYCODE_N),CONSTANT_TRAIT); + c->setVariableByQName("NEXT","",abstract_ui(c->getSystemState(),AS3KEYCODE_NEXT),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_0","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_0),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_1","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_1),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_2","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_2),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_3","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_3),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_4","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_4),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_5","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_5),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_6","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_6),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_7","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_7),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_8","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_8),CONSTANT_TRAIT); + c->setVariableByQName("NUMBER_9","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMBER_9),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_0","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_0),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_1","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_1),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_2","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_2),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_3","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_3),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_4","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_4),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_5","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_5),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_6","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_6),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_7","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_7),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_8","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_8),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_9","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_9),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_ADD","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_ADD),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_DECIMAL","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_DECIMAL),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_DIVIDE","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_DIVIDE),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_ENTER","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_ENTER),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_MULTIPLY","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_MULTIPLY),CONSTANT_TRAIT); + c->setVariableByQName("NUMPAD_SUBTRACT","",abstract_ui(c->getSystemState(),AS3KEYCODE_NUMPAD_SUBTRACT),CONSTANT_TRAIT); + c->setVariableByQName("O","",abstract_ui(c->getSystemState(),AS3KEYCODE_O),CONSTANT_TRAIT); + c->setVariableByQName("P","",abstract_ui(c->getSystemState(),AS3KEYCODE_P),CONSTANT_TRAIT); + c->setVariableByQName("PAGE_DOWN","",abstract_ui(c->getSystemState(),AS3KEYCODE_PAGE_DOWN),CONSTANT_TRAIT); + c->setVariableByQName("PAGE_UP","",abstract_ui(c->getSystemState(),AS3KEYCODE_PAGE_UP),CONSTANT_TRAIT); + c->setVariableByQName("PAUSE","",abstract_ui(c->getSystemState(),AS3KEYCODE_PAUSE),CONSTANT_TRAIT); + c->setVariableByQName("PERIOD","",abstract_ui(c->getSystemState(),AS3KEYCODE_PERIOD),CONSTANT_TRAIT); + c->setVariableByQName("PLAY","",abstract_ui(c->getSystemState(),AS3KEYCODE_PLAY),CONSTANT_TRAIT); + c->setVariableByQName("PREVIOUS","",abstract_ui(c->getSystemState(),AS3KEYCODE_PREVIOUS),CONSTANT_TRAIT); + c->setVariableByQName("Q","",abstract_ui(c->getSystemState(),AS3KEYCODE_Q),CONSTANT_TRAIT); + c->setVariableByQName("QUOTE","",abstract_ui(c->getSystemState(),AS3KEYCODE_QUOTE),CONSTANT_TRAIT); + c->setVariableByQName("R","",abstract_ui(c->getSystemState(),AS3KEYCODE_R),CONSTANT_TRAIT); + c->setVariableByQName("RECORD","",abstract_ui(c->getSystemState(),AS3KEYCODE_RECORD),CONSTANT_TRAIT); + c->setVariableByQName("RED","",abstract_ui(c->getSystemState(),AS3KEYCODE_RED),CONSTANT_TRAIT); + c->setVariableByQName("REWIND","",abstract_ui(c->getSystemState(),AS3KEYCODE_REWIND),CONSTANT_TRAIT); + c->setVariableByQName("RIGHT","",abstract_ui(c->getSystemState(),AS3KEYCODE_RIGHT),CONSTANT_TRAIT); + c->setVariableByQName("RIGHTBRACKET","",abstract_ui(c->getSystemState(),AS3KEYCODE_RIGHTBRACKET),CONSTANT_TRAIT); + c->setVariableByQName("S","",abstract_ui(c->getSystemState(),AS3KEYCODE_S),CONSTANT_TRAIT); + c->setVariableByQName("SEARCH","",abstract_ui(c->getSystemState(),AS3KEYCODE_SEARCH),CONSTANT_TRAIT); + c->setVariableByQName("SEMICOLON","",abstract_ui(c->getSystemState(),AS3KEYCODE_SEMICOLON),CONSTANT_TRAIT); + c->setVariableByQName("SETUP","",abstract_ui(c->getSystemState(),AS3KEYCODE_SETUP),CONSTANT_TRAIT); + c->setVariableByQName("SHIFT","",abstract_ui(c->getSystemState(),AS3KEYCODE_SHIFT),CONSTANT_TRAIT); + c->setVariableByQName("SKIP_BACKWARD","",abstract_ui(c->getSystemState(),AS3KEYCODE_SKIP_BACKWARD),CONSTANT_TRAIT); + c->setVariableByQName("SKIP_FORWARD","",abstract_ui(c->getSystemState(),AS3KEYCODE_SKIP_FORWARD),CONSTANT_TRAIT); + c->setVariableByQName("SLASH","",abstract_ui(c->getSystemState(),AS3KEYCODE_SLASH),CONSTANT_TRAIT); + c->setVariableByQName("SPACE","",abstract_ui(c->getSystemState(),AS3KEYCODE_SPACE),CONSTANT_TRAIT); + c->setVariableByQName("STOP","",abstract_ui(c->getSystemState(),AS3KEYCODE_STOP),CONSTANT_TRAIT); + c->setVariableByQName("STRING_BEGIN","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_BREAK","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_CLEARDISPLAY","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_CLEARLINE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_DELETE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_DELETECHAR","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_DELETELINE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_DOWNARROW","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_END","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_EXECUTE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F1","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F10","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F11","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F12","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F13","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F14","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F15","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F16","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F17","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F18","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F19","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F2","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F20","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F21","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F22","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F23","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F24","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F25","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F26","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F27","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F28","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F29","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F3","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F30","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F31","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F32","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F33","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F34","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F35","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F4","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F5","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F6","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F7","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F8","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_F9","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_FIND","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_HELP","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_HOME","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_INSERT","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_INSERTCHAR","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_INSERTLINE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_LEFTARROW","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_MENU","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_MODESWITCH","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_NEXT","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PAGEDOWN","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PAGEUP","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PAUSE","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PREV","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PRINT","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_PRINTSCREEN","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_REDO","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_RESET","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_RIGHTARROW","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_SCROLLLOCK","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_SELECT","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_STOP","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_SYSREQ","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_SYSTEM","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_UNDO","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_UPARROW","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("STRING_USER","",abstract_s(c->getSystemState(),""),CONSTANT_TRAIT); + c->setVariableByQName("SUBTITLE","",abstract_ui(c->getSystemState(),AS3KEYCODE_SUBTITLE),CONSTANT_TRAIT); + c->setVariableByQName("T","",abstract_ui(c->getSystemState(),AS3KEYCODE_T),CONSTANT_TRAIT); + c->setVariableByQName("TAB","",abstract_ui(c->getSystemState(),AS3KEYCODE_TAB),CONSTANT_TRAIT); + c->setVariableByQName("U","",abstract_ui(c->getSystemState(),AS3KEYCODE_U),CONSTANT_TRAIT); + c->setVariableByQName("UP","",abstract_ui(c->getSystemState(),AS3KEYCODE_UP),CONSTANT_TRAIT); + c->setVariableByQName("V","",abstract_ui(c->getSystemState(),AS3KEYCODE_V),CONSTANT_TRAIT); + c->setVariableByQName("VOD","",abstract_ui(c->getSystemState(),AS3KEYCODE_VOD),CONSTANT_TRAIT); + c->setVariableByQName("W","",abstract_ui(c->getSystemState(),AS3KEYCODE_W),CONSTANT_TRAIT); + c->setVariableByQName("X","",abstract_ui(c->getSystemState(),AS3KEYCODE_X),CONSTANT_TRAIT); + c->setVariableByQName("Y","",abstract_ui(c->getSystemState(),AS3KEYCODE_Y),CONSTANT_TRAIT); + c->setVariableByQName("YELLOW","",abstract_ui(c->getSystemState(),AS3KEYCODE_YELLOW),CONSTANT_TRAIT); + c->setVariableByQName("Z","",abstract_ui(c->getSystemState(),AS3KEYCODE_Z),CONSTANT_TRAIT); } ASFUNCTIONBODY(Keyboard, capsLock) @@ -76,16 +345,16 @@ void KeyboardType::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ALPHANUMERIC","",abstract_s(c->getSystemState(),"alphanumeric"),DECLARED_TRAIT); - c->setVariableByQName("KEYPAD","",abstract_s(c->getSystemState(),"keypad"),DECLARED_TRAIT); - c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),DECLARED_TRAIT); + c->setVariableByQName("ALPHANUMERIC","",abstract_s(c->getSystemState(),"alphanumeric"),CONSTANT_TRAIT); + c->setVariableByQName("KEYPAD","",abstract_s(c->getSystemState(),"keypad"),CONSTANT_TRAIT); + c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),CONSTANT_TRAIT); } void KeyLocation::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("LEFT","",abstract_ui(c->getSystemState(),1),DECLARED_TRAIT); - c->setVariableByQName("NUM_PAD","",abstract_ui(c->getSystemState(),3),DECLARED_TRAIT); - c->setVariableByQName("RIGHT","",abstract_ui(c->getSystemState(),2),DECLARED_TRAIT); - c->setVariableByQName("STANDARD","",abstract_ui(c->getSystemState(),0),DECLARED_TRAIT); + c->setVariableByQName("LEFT","",abstract_ui(c->getSystemState(),1),CONSTANT_TRAIT); + c->setVariableByQName("NUM_PAD","",abstract_ui(c->getSystemState(),3),CONSTANT_TRAIT); + c->setVariableByQName("RIGHT","",abstract_ui(c->getSystemState(),2),CONSTANT_TRAIT); + c->setVariableByQName("STANDARD","",abstract_ui(c->getSystemState(),0),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/ui/keycodes.h
Changed
@@ -20,153 +20,145 @@ #ifndef SCRIPTING_FLASH_UI_KEYCODES_H #define SCRIPTING_FLASH_UI_KEYCODES_H 1 -#if GTK_CHECK_VERSION (2,21,8) -#include <gdk/gdkkeysyms-compat.h> -#else -#include <gdk/gdkkeysyms.h> -#endif +#include <SDL2/SDL_keycode.h> namespace lightspark { -struct ASNameForGDKKey { - const char *keyname; - unsigned gdkKeyval; -}; -const ASNameForGDKKey hardwareKeycodes[] = \ - {{"A", GDK_a}, - {"ALTERNATE", GDK_Alt_L}, - {"B", GDK_b}, - {"BACK", GDK_Back}, - {"BACKQUOTE", GDK_grave}, - {"BACKSLASH", GDK_backslash}, - {"BACKSPACE", GDK_BackSpace}, - {"BLUE", GDK_Blue}, - {"C", GDK_c}, - {"CAPS_LOCK", GDK_Caps_Lock}, - {"COMMA", GDK_comma}, - {"CONTROL", GDK_Control_L}, - {"D", GDK_d}, - {"DELETE", GDK_Delete}, - {"DOWN", GDK_Down}, - {"E", GDK_e}, - {"END", GDK_End}, - {"ENTER", GDK_Return}, - {"EQUAL", GDK_equal}, - {"ESCAPE", GDK_Escape}, - {"F", GDK_f}, - {"F1", GDK_F1}, - {"F2", GDK_F2}, - {"F3", GDK_F3}, - {"F4", GDK_F4}, - {"F5", GDK_F5}, - {"F6", GDK_F6}, - {"F7", GDK_F7}, - {"F8", GDK_F8}, - {"F9", GDK_F9}, - {"F10", GDK_F10}, - {"F11", GDK_F11}, - {"F12", GDK_F12}, - {"F13", GDK_F13}, - {"F14", GDK_F14}, - {"F15", GDK_F15}, - {"G", GDK_g}, - {"GREEN", GDK_Green}, - {"H", GDK_h}, - {"HELP", GDK_Help}, - {"HOME", GDK_Home}, - {"I", GDK_i}, - {"INSERT", GDK_Insert}, - {"J", GDK_j}, - {"K", GDK_k}, - {"L", GDK_l}, - {"LEFT", GDK_Left}, - {"LEFTBRACKET", GDK_bracketleft}, - {"M", GDK_m}, - {"MINUS", GDK_minus}, - {"N", GDK_n}, - {"NUMBER_0", GDK_0}, - {"NUMBER_1", GDK_1}, - {"NUMBER_2", GDK_2}, - {"NUMBER_3", GDK_3}, - {"NUMBER_4", GDK_4}, - {"NUMBER_5", GDK_5}, - {"NUMBER_6", GDK_6}, - {"NUMBER_7", GDK_7}, - {"NUMBER_8", GDK_8}, - {"NUMBER_9", GDK_9}, - {"NUMPAD_0", GDK_KP_0}, - {"NUMPAD_1", GDK_KP_1}, - {"NUMPAD_2", GDK_KP_2}, - {"NUMPAD_3", GDK_KP_3}, - {"NUMPAD_4", GDK_KP_4}, - {"NUMPAD_5", GDK_KP_5}, - {"NUMPAD_6", GDK_KP_6}, - {"NUMPAD_7", GDK_KP_7}, - {"NUMPAD_8", GDK_KP_8}, - {"NUMPAD_9", GDK_KP_9}, - {"NUMPAD_ADD", GDK_KP_Add}, - {"NUMPAD_DECIMAL", GDK_KP_Separator}, - {"NUMPAD_DIVIDE", GDK_KP_Divide}, - {"NUMPAD_ENTER", GDK_KP_Enter}, - {"NUMPAD_MULTIPLY", GDK_KP_Multiply}, - {"NUMPAD_SUBTRACT", GDK_KP_Subtract}, - {"O", GDK_o}, - {"P", GDK_p}, - {"PAGE_DOWN", GDK_Page_Down}, - {"PAGE_UP", GDK_Page_Up}, - {"PAUSE", GDK_Pause}, - {"PERIOD", GDK_period}, - {"Q", GDK_q}, - {"QUOTE", GDK_quoteright}, - {"R", GDK_r}, - {"RED", GDK_Red}, - {"RIGHT", GDK_Right}, - {"RIGHTBRACKET", GDK_bracketright}, - {"S", GDK_s}, - {"SEARCH", GDK_Search}, - {"SEMICOLON", GDK_semicolon}, - {"SHIFT", GDK_Shift_L}, - {"SLASH", GDK_slash}, - {"SPACE", GDK_space}, - {"SUBTITLE", GDK_Subtitle}, - {"T", GDK_t}, - {"TAB", GDK_Tab}, - {"U", GDK_u}, - {"UP", GDK_Up}, - {"V", GDK_v}, - {"W", GDK_w}, - {"X", GDK_x}, - {"Y", GDK_y}, - {"YELLOW", GDK_Yellow}, - {"Z", GDK_z}, - {NULL, 0}}; +enum AS3KeyCode { + AS3KEYCODE_A = 65, + AS3KEYCODE_ALTERNATE = 18, + AS3KEYCODE_AUDIO = 0x01000017, + AS3KEYCODE_B = 66, + AS3KEYCODE_BACK = 0x01000016, + AS3KEYCODE_BACKQUOTE = 192, + AS3KEYCODE_BACKSLASH = 220, + AS3KEYCODE_BACKSPACE = 8, + AS3KEYCODE_BLUE = 0x01000003, + AS3KEYCODE_C = 67, + AS3KEYCODE_CAPS_LOCK = 20, + AS3KEYCODE_CHANNEL_DOWN = 0x01000005, + AS3KEYCODE_CHANNEL_UP = 0x01000004, + AS3KEYCODE_COMMA = 188, + AS3KEYCODE_COMMAND = 15, + AS3KEYCODE_CONTROL = 17, + AS3KEYCODE_D = 68, + AS3KEYCODE_DELETE = 46, + AS3KEYCODE_DOWN = 40, + AS3KEYCODE_DVR = 0x01000019, + AS3KEYCODE_E = 69, + AS3KEYCODE_END = 35, + AS3KEYCODE_ENTER = 13, + AS3KEYCODE_EQUAL = 187, + AS3KEYCODE_ESCAPE = 27, + AS3KEYCODE_EXIT = 0x01000015, + AS3KEYCODE_F = 70, + AS3KEYCODE_F1 = 112, + AS3KEYCODE_F10 = 121, + AS3KEYCODE_F11 = 122, + AS3KEYCODE_F12 = 123, + AS3KEYCODE_F13 = 124, + AS3KEYCODE_F14 = 125, + AS3KEYCODE_F15 = 126, + AS3KEYCODE_F2 = 113, + AS3KEYCODE_F3 = 114, + AS3KEYCODE_F4 = 115, + AS3KEYCODE_F5 = 116, + AS3KEYCODE_F6 = 117, + AS3KEYCODE_F7 = 118, + AS3KEYCODE_F8 = 119, + AS3KEYCODE_F9 = 120, + AS3KEYCODE_FAST_FORWARD = 0x0100000A, + AS3KEYCODE_G = 71, + AS3KEYCODE_GREEN = 0x01000001, + AS3KEYCODE_GUIDE = 0x01000014, + AS3KEYCODE_H = 72, + AS3KEYCODE_HELP = 0x0100001D, + AS3KEYCODE_HOME = 36, + AS3KEYCODE_I = 73, + AS3KEYCODE_INFO = 0x01000013, + AS3KEYCODE_INPUT = 0x0100001B, + AS3KEYCODE_INSERT = 45, + AS3KEYCODE_J = 74, + AS3KEYCODE_K = 75, + AS3KEYCODE_L = 76, + AS3KEYCODE_LAST = 0x01000011, + AS3KEYCODE_LEFT = 37, + AS3KEYCODE_LEFTBRACKET = 219, + AS3KEYCODE_LIVE = 0x01000010, + AS3KEYCODE_M = 77, + AS3KEYCODE_MASTER_SHELL = 0x0100001E, + AS3KEYCODE_MENU = 0x01000012, + AS3KEYCODE_MINUS = 189, + AS3KEYCODE_N = 78, + AS3KEYCODE_NEXT = 0x0100000E, + AS3KEYCODE_NUMBER_0 = 48, + AS3KEYCODE_NUMBER_1 = 49, + AS3KEYCODE_NUMBER_2 = 50, + AS3KEYCODE_NUMBER_3 = 51, + AS3KEYCODE_NUMBER_4 = 52, + AS3KEYCODE_NUMBER_5 = 53, + AS3KEYCODE_NUMBER_6 = 54, + AS3KEYCODE_NUMBER_7 = 55, + AS3KEYCODE_NUMBER_8 = 56, + AS3KEYCODE_NUMBER_9 = 57, + AS3KEYCODE_NUMPAD = 21, + AS3KEYCODE_NUMPAD_0 = 96, + AS3KEYCODE_NUMPAD_1 = 97, + AS3KEYCODE_NUMPAD_2 = 98, + AS3KEYCODE_NUMPAD_3 = 99, + AS3KEYCODE_NUMPAD_4 = 100, + AS3KEYCODE_NUMPAD_5 = 101, + AS3KEYCODE_NUMPAD_6 = 102, + AS3KEYCODE_NUMPAD_7 = 103, + AS3KEYCODE_NUMPAD_8 = 104, + AS3KEYCODE_NUMPAD_9 = 105, + AS3KEYCODE_NUMPAD_ADD = 107, + AS3KEYCODE_NUMPAD_DECIMAL = 110, + AS3KEYCODE_NUMPAD_DIVIDE = 111, + AS3KEYCODE_NUMPAD_ENTER = 108, + AS3KEYCODE_NUMPAD_MULTIPLY = 106, + AS3KEYCODE_NUMPAD_SUBTRACT = 109, + AS3KEYCODE_O = 79, + AS3KEYCODE_P = 80, + AS3KEYCODE_PAGE_DOWN = 34, + AS3KEYCODE_PAGE_UP = 33, + AS3KEYCODE_PAUSE = 0x01000008, + AS3KEYCODE_PERIOD = 190, + AS3KEYCODE_PLAY = 0x01000007, + AS3KEYCODE_PREVIOUS = 0x0100000F, + AS3KEYCODE_Q = 81, + AS3KEYCODE_QUOTE = 222, + AS3KEYCODE_R = 82, + AS3KEYCODE_RECORD = 0x01000006, + AS3KEYCODE_RED = 0x01000000, + AS3KEYCODE_REWIND = 0x0100000B, + AS3KEYCODE_RIGHT = 39, + AS3KEYCODE_RIGHTBRACKET = 221, + AS3KEYCODE_S = 83, + AS3KEYCODE_SEARCH = 0x0100001F, + AS3KEYCODE_SEMICOLON = 186, + AS3KEYCODE_SETUP = 0x0100001C, + AS3KEYCODE_SHIFT = 16, + AS3KEYCODE_SKIP_BACKWARD = 0x0100000D, + AS3KEYCODE_SKIP_FORWARD = 0x0100000C, + AS3KEYCODE_SLASH = 191, + AS3KEYCODE_SPACE = 32, + AS3KEYCODE_STOP = 0x01000009, + AS3KEYCODE_SUBTITLE = 0x01000018, + AS3KEYCODE_T = 84, + AS3KEYCODE_TAB = 9, + AS3KEYCODE_U = 85, + AS3KEYCODE_UP = 38, + AS3KEYCODE_V = 86, + AS3KEYCODE_VOD = 0x0100001A, + AS3KEYCODE_W = 87, + AS3KEYCODE_X = 88, + AS3KEYCODE_Y = 89, + AS3KEYCODE_YELLOW = 0x01000002, + AS3KEYCODE_Z = 90, + AS3KEYCODE_UNKNOWN = 0 }; -// AUDIO -// CHANNEL_DOWN -// CHANNEL_UP -// COMMAND -// DVR -// EXIT -// FAST_FORWARD -// GUIDE -// INFO -// INPUT -// LAST -// LIVE -// MASTER_SHELL -// MENU -// NEXT -// NUMPAD -// PLAY -// PREVIOUS -// RECORD -// REWIND -// SETUP -// SKIP_BACKWARD -// SKIP_FORWARD -// STOP -// VOD - +} #endif /* SCRIPTING_FLASH_UI_KEYCODES_H */
View file
lightspark.tar.xz/src/smartrefs.h
Changed
@@ -44,6 +44,7 @@ { RELEASE_WRITE(isConstant,true); } + inline bool getConstant() const { return isConstant; } inline void incRef() { @@ -308,7 +309,7 @@ } inline void forceDestruct() { - assert(m->isConstant()); + assert(m->getConstant()); if (m) delete m; m = NULL;
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -30,7 +30,6 @@ #include "scripting/class.h" #include "backends/audio.h" #include "backends/config.h" -#include "backends/pluginmanager.h" #include "backends/rendering.h" #include "backends/image.h" #include "backends/extscriptobject.h" @@ -250,8 +249,7 @@ threadPool=new ThreadPool(this); timerThread=new TimerThread(this); frameTimerThread=new TimerThread(this); - pluginManager = new PluginManager; - audioManager=new AudioManager(pluginManager); + audioManager=new AudioManager(); intervalManager=new IntervalManager(); securityManager=new SecurityManager(); @@ -268,6 +266,13 @@ renderThread=new RenderThread(this); inputThread=new InputThread(this); + + EngineData::userevent = SDL_RegisterEvents(3); + SDL_Event event; + SDL_zero(event); + event.type = LS_USEREVENT_INIT; + event.user.data1 = this; + SDL_PushEvent(&event); } void SystemState::setDownloadedPath(const tiny_string& p) @@ -448,9 +453,6 @@ //Now stop the managers delete audioManager; audioManager=NULL; - delete pluginManager; - pluginManager=NULL; - } #ifdef PROFILING_SUPPORT @@ -634,6 +636,7 @@ delete inputThread; inputThread=NULL; delete engineData; + engineData=NULL; for(auto it=profilingData.begin();it!=profilingData.end();it++) delete *it; @@ -657,7 +660,10 @@ void SystemState::setError(const string& c, ERROR_TYPE type) { if((exitOnError & type) != 0) - exit(1); + { + setShutdownFlag(); + return; + } //We record only the first error for easier fix and reporting if(!error) @@ -710,39 +716,33 @@ } /* - * This is run from the gtk main thread. - * gtk/gdk functions may only be called from within that - * gtk main thread for portability. Win32 does not support - * gtk/gdk calls from other threads! + * This is run from mainLoopThread */ -void SystemState::delayedCreation() +void SystemState::delayedCreation(SystemState* sys) { - gdk_threads_enter(); - - int32_t reqWidth=mainClip->getFrameSize().Xmax/20; - int32_t reqHeight=mainClip->getFrameSize().Ymax/20; + int32_t reqWidth=sys->mainClip->getFrameSize().Xmax/20; + int32_t reqHeight=sys->mainClip->getFrameSize().Ymax/20; - engineData->showWindow(reqWidth, reqHeight); + sys->engineData->showWindow(reqWidth, reqHeight); - inputThread->start(engineData); + sys->inputThread->start(sys->engineData); if(Config::getConfig()->isRenderingEnabled()) { - renderThread->start(engineData); + sys->renderThread->start(sys->engineData); } else { - getRenderThread()->windowWidth = reqWidth; - getRenderThread()->windowHeight = reqHeight; - resizeCompleted(); + sys->getRenderThread()->windowWidth = reqWidth; + sys->getRenderThread()->windowHeight = reqHeight; + sys->resizeCompleted(); //This just signals the 'initalized' semaphore - renderThread->forceInitialization(); + sys->renderThread->forceInitialization(); LOG(LOG_INFO,"Rendering is disabled by configuration"); } - if(renderRate) - startRenderTicks(); - gdk_threads_leave(); + if(sys->renderRate) + sys->startRenderTicks(); } void SystemState::delayedStopping() @@ -776,12 +776,12 @@ // and this SystemState object has been deleted. // We cannot wait for that function to finish, because we run in a ThreadPool // and the function will wait for all ThreadPool jobs to finish. - //engineData->runInGtkThread(sigc::mem_fun(this, &SystemState::delayedStopping)); + //engineData->runInMainThread(sigc::mem_fun(this, &SystemState::delayedStopping)); return; } //The engines must be created in the context of the main thread - engineData->runInGtkThread(sigc::mem_fun(this, &SystemState::delayedCreation)); + engineData->runInMainThread(&SystemState::delayedCreation); //Wait for delayedCreation to finish so it is protected by our 'mutex' //Otherwise SystemState::destroy may delete this object before delayedCreation is scheduled. @@ -1960,9 +1960,9 @@ void SystemState::showMouseCursor(bool visible) { if (visible) - EngineData::runInGtkThread(sigc::mem_fun(engineData, &EngineData::showMouseCursor)); + EngineData::runInMainThread(&EngineData::showMouseCursor); else - EngineData::runInGtkThread(sigc::mem_fun(engineData, &EngineData::hideMouseCursor)); + EngineData::runInMainThread(&EngineData::hideMouseCursor); } void SystemState::waitRendering()
View file
lightspark.tar.xz/src/swf.h
Changed
@@ -191,7 +191,7 @@ */ void stopEngines(); - void delayedCreation(); + static void delayedCreation(SystemState* sys); void delayedStopping(); /* dumpedSWFPathAvailable is signaled after dumpedSWFPath has been set */ @@ -337,7 +337,6 @@ Stage* stage; ABCVm* currentVm; - PluginManager* pluginManager; AudioManager* audioManager; //Application starting time in milliseconds @@ -457,6 +456,7 @@ void showMouseCursor(bool visible); void waitRendering() DLL_PUBLIC; + EngineData* getEngineData() { return engineData;} }; class ParseThread: public IThreadJob
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.