Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 132
View file
lightspark.spec
Changed
@@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20170104.1157 +Version: 0.7.2.99+git20170107.1001 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
lightspark.tar.xz/src/backends/audio.cpp
Changed
@@ -22,31 +22,12 @@ #include "backends/config.h" #include <iostream> #include "logger.h" -#include <SDL2/SDL_mixer.h> #include <sys/time.h> -#define LIGHTSPARK_AUDIO_SDL_BUFFERSIZE 8192 using namespace lightspark; using namespace std; -void mixer_effect_ffmpeg_cb(int chan, void * stream, int len, void * udata) -{ - 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; - } -} - - uint32_t AudioStream::getPlayedTime() { uint32_t ret; @@ -58,22 +39,11 @@ } bool AudioStream::init() { - unmutevolume = curvolume = SDL_MIX_MAXVOLUME; + unmutevolume = curvolume = 1.0; 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); - + mixer_channel = manager->engineData->audio_StreamInit(this); + isPaused = false; return true; } @@ -82,55 +52,45 @@ if (pause_on) { playedtime = getPlayedTime(); - if (mixer_channel != -1) - Mix_Pause(mixer_channel); + isPaused = true; } else { gettimeofday(&starttime, NULL); - if (mixer_channel != -1) - Mix_Resume(mixer_channel); + isPaused = false; } + manager->engineData->audio_StreamPause(mixer_channel,pause_on); } bool AudioStream::ispaused() { - return Mix_Paused(mixer_channel); + return isPaused; } void AudioStream::mute() { unmutevolume = curvolume; - curvolume = 0; + setVolume(0); } void AudioStream::unmute() { - curvolume = unmutevolume; + setVolume(unmutevolume); } void AudioStream::setVolume(double volume) { - curvolume = SDL_MIX_MAXVOLUME * volume; - if (mixer_channel != -1) - Mix_Volume(mixer_channel, curvolume); + manager->engineData->audio_StreamSetVolume(mixer_channel, volume); + curvolume = volume; } AudioStream::~AudioStream() { - if (mixer_channel != -1) - Mix_HaltChannel(mixer_channel); + manager->engineData->audio_StreamDeinit(mixer_channel); manager->removeStream(this); } -AudioManager::AudioManager():muteAllStreams(false),sdl_available(0),mixeropened(0) +AudioManager::AudioManager(EngineData *engine):muteAllStreams(false),audio_available(false),mixeropened(0),engineData(engine) { - sdl_available = 0; - if (EngineData::sdl_needinit) - { - 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 ); - } + audio_available = engine->audio_ManagerInit(); mixeropened = 0; } void AudioManager::muteAll() @@ -158,7 +118,7 @@ streams.remove(s); if (streams.empty()) { - Mix_CloseAudio(); + engineData->audio_ManagerCloseMixer(); mixeropened = false; } } @@ -166,14 +126,14 @@ AudioStream* AudioManager::createStream(AudioDecoder* decoder, bool startpaused) { Locker l(streamMutex); - if (!sdl_available) + if (!audio_available) return NULL; if (!mixeropened) { - if (Mix_OpenAudio (MIX_DEFAULT_FREQUENCY, AUDIO_S16, 2, LIGHTSPARK_AUDIO_SDL_BUFFERSIZE) < 0) + if (!engineData->audio_ManagerOpenMixer()) { - LOG(LOG_ERROR,"Couldn't open SDL_mixer"); - sdl_available = 0; + LOG(LOG_ERROR,"Couldn't open mixer"); + audio_available = 0; return NULL; } mixeropened = 1; @@ -204,12 +164,10 @@ } if (mixeropened) { - Mix_CloseAudio(); + engineData->audio_ManagerCloseMixer(); } - if (sdl_available) + if (audio_available) { - SDL_QuitSubSystem ( SDL_INIT_AUDIO ); - if (!SDL_WasInit(0)) - SDL_Quit (); + engineData->audio_ManagerDeinit(); } }
View file
lightspark.tar.xz/src/backends/audio.h
Changed
@@ -28,19 +28,21 @@ namespace lightspark { class AudioStream; +class EngineData; class AudioManager { friend class AudioStream; private: bool muteAllStreams; - int sdl_available; + bool audio_available; int mixeropened; + EngineData* engineData; std::list<AudioStream *> streams; typedef std::list<AudioStream *>::iterator stream_iterator; Mutex streamMutex; public: - AudioManager(); + AudioManager(EngineData* engine); AudioStream *createStream(AudioDecoder *decoder, bool startpaused); @@ -60,14 +62,15 @@ AudioManager* manager; AudioDecoder *decoder; bool hasStarted; - int curvolume; - int unmutevolume; + bool isPaused; + double curvolume; + double unmutevolume; uint32_t playedtime; struct timeval starttime; int mixer_channel; public: bool init(); - AudioStream(AudioManager* _manager):manager(_manager),decoder(NULL),hasStarted(false) { } + AudioStream(AudioManager* _manager):manager(_manager),decoder(NULL),hasStarted(false),isPaused(true) { } void SetPause(bool pause_on); uint32_t getPlayedTime(); @@ -77,6 +80,7 @@ void pause() { SetPause(true); } void resume() { SetPause(false); } void setVolume(double volume); + inline double getVolume() const { return curvolume; } inline AudioDecoder *getDecoder() const { return decoder; } ~AudioStream(); };
View file
lightspark.tar.xz/src/backends/builtindecoder.cpp
Changed
@@ -21,6 +21,7 @@ #include "scripting/flash/display/DisplayObject.h" #include "scripting/flash/display/flashdisplay.h" #include "scripting/flash/net/flashnet.h" +#include "swf.h" using namespace lightspark; @@ -79,7 +80,7 @@ case AAC: assert_and_throw(tag.isHeader()) #ifdef ENABLE_LIBAVCODEC - audioDecoder=new FFMpegAudioDecoder(tag.SoundFormat, tag.packetData, tag.packetLen); + audioDecoder=new FFMpegAudioDecoder(netstream->getSystemState()->getEngineData(), tag.SoundFormat, tag.packetData, tag.packetLen); #else audioDecoder=new NullAudioDecoder(); #endif @@ -87,7 +88,7 @@ break; case MP3: #ifdef ENABLE_LIBAVCODEC - audioDecoder=new FFMpegAudioDecoder(tag.SoundFormat,NULL,0); + audioDecoder=new FFMpegAudioDecoder(netstream->getSystemState()->getEngineData(), tag.SoundFormat,NULL,0); #else audioDecoder=new NullAudioDecoder(); #endif
View file
lightspark.tar.xz/src/backends/decoder.cpp
Changed
@@ -570,7 +570,7 @@ } #ifdef ENABLE_LIBAVCODEC -FFMpegAudioDecoder::FFMpegAudioDecoder(LS_AUDIO_CODEC audioCodec, uint8_t* initdata, uint32_t datalen):ownedContext(true) +FFMpegAudioDecoder::FFMpegAudioDecoder(EngineData* eng,LS_AUDIO_CODEC audioCodec, uint8_t* initdata, uint32_t datalen):engine(eng),ownedContext(true) #ifdef HAVE_LIBAVRESAMPLE ,resamplecontext(NULL) #endif @@ -616,7 +616,7 @@ status=INIT; } -FFMpegAudioDecoder::FFMpegAudioDecoder(LS_AUDIO_CODEC lscodec, int sampleRate, int channels, bool):ownedContext(true) +FFMpegAudioDecoder::FFMpegAudioDecoder(EngineData* eng,LS_AUDIO_CODEC lscodec, int sampleRate, int channels, bool):engine(eng),ownedContext(true) #ifdef HAVE_LIBAVRESAMPLE ,resamplecontext(NULL) #endif @@ -646,7 +646,7 @@ } #if LIBAVFORMAT_VERSION_MAJOR > 56 -FFMpegAudioDecoder::FFMpegAudioDecoder(AVCodecID codecID):ownedContext(true),codecContext(NULL) +FFMpegAudioDecoder::FFMpegAudioDecoder(EngineData* eng,AVCodecID codecID):engine(eng),ownedContext(true),codecContext(NULL) #ifdef HAVE_LIBAVRESAMPLE ,resamplecontext(NULL) #endif @@ -674,7 +674,7 @@ #endif } #else -FFMpegAudioDecoder::FFMpegAudioDecoder(AVCodecContext* _c):ownedContext(false),codecContext(_c) +FFMpegAudioDecoder::FFMpegAudioDecoder(EngineData* eng,AVCodecContext* _c):engine(eng),ownedContext(false),codecContext(_c) #ifdef HAVE_LIBAVRESAMPLE ,resamplecontext(NULL) #endif @@ -967,7 +967,7 @@ #if defined HAVE_AVCODEC_DECODE_AUDIO4 || (defined HAVE_AVCODEC_SEND_PACKET && defined HAVE_AVCODEC_RECEIVE_FRAME) int FFMpegAudioDecoder::resampleFrameToS16(FrameSamples& curTail) { - int sample_rate = MIX_DEFAULT_FREQUENCY; + int sample_rate = engine->audio_getSampleRate(); unsigned int channel_layout = AV_CH_LAYOUT_STEREO; #ifdef HAVE_AV_FRAME_GET_SAMPLE_RATE int framesamplerate = av_frame_get_sample_rate(frameIn); @@ -1029,7 +1029,7 @@ } #ifdef ENABLE_LIBAVCODEC -FFMpegStreamDecoder::FFMpegStreamDecoder(std::istream& s,AudioFormat* format, int streamsize) +FFMpegStreamDecoder::FFMpegStreamDecoder(EngineData *eng, std::istream& s, AudioFormat* format, int streamsize) : audioFound(false),videoFound(false),stream(s),formatCtx(NULL),audioIndex(-1), videoIndex(-1),customAudioDecoder(NULL),customVideoDecoder(NULL),avioContext(NULL),availablestreamlength(streamsize) { @@ -1156,12 +1156,12 @@ if(audioFound) { if (format && (format->codec != LS_AUDIO_CODEC::CODEC_NONE)) - customAudioDecoder=new FFMpegAudioDecoder(format->codec,format->sampleRate,format->channels,true); + customAudioDecoder=new FFMpegAudioDecoder(eng,format->codec,format->sampleRate,format->channels,true); else #if LIBAVFORMAT_VERSION_MAJOR > 56 - customAudioDecoder=new FFMpegAudioDecoder(formatCtx->streams[audioIndex]->codecpar->codec_id); + customAudioDecoder=new FFMpegAudioDecoder(eng,formatCtx->streams[audioIndex]->codecpar->codec_id); #else - customAudioDecoder=new FFMpegAudioDecoder(formatCtx->streams[audioIndex]->codec); + customAudioDecoder=new FFMpegAudioDecoder(eng,formatCtx->streams[audioIndex]->codec); #endif audioDecoder=customAudioDecoder; }
View file
lightspark.tar.xz/src/backends/decoder.h
Changed
@@ -309,9 +309,11 @@ }; #ifdef ENABLE_LIBAVCODEC +class EngineData; class FFMpegAudioDecoder: public AudioDecoder { private: + EngineData* engine; bool ownedContext; AVCodecContext* codecContext; #ifdef HAVE_LIBAVRESAMPLE @@ -325,15 +327,15 @@ int resampleFrameToS16(FrameSamples& curTail); #endif public: - FFMpegAudioDecoder(LS_AUDIO_CODEC codec, uint8_t* initdata, uint32_t datalen); - FFMpegAudioDecoder(LS_AUDIO_CODEC codec, int sampleRate, int channels, bool); + FFMpegAudioDecoder(EngineData* eng,LS_AUDIO_CODEC codec, uint8_t* initdata, uint32_t datalen); + FFMpegAudioDecoder(EngineData* eng,LS_AUDIO_CODEC codec, int sampleRate, int channels, bool); /* Specialized constructor used by FFMpegStreamDecoder */ #if LIBAVFORMAT_VERSION_MAJOR > 56 - FFMpegAudioDecoder(AVCodecID codecID); + FFMpegAudioDecoder(EngineData* eng,AVCodecID codecID); #else - FFMpegAudioDecoder(AVCodecContext* codecContext); + FFMpegAudioDecoder(EngineData* eng,AVCodecContext* codecContext); #endif ~FFMpegAudioDecoder(); /* @@ -384,7 +386,7 @@ #endif int availablestreamlength; public: - FFMpegStreamDecoder(std::istream& s, AudioFormat* format = NULL, int streamsize = -1); + FFMpegStreamDecoder(EngineData* eng,std::istream& s, AudioFormat* format = NULL, int streamsize = -1); ~FFMpegStreamDecoder(); bool decodeNextFrame(); };
View file
lightspark.tar.xz/src/platforms/engineutils.cpp
Changed
@@ -22,9 +22,11 @@ #include "swf.h" #include <SDL2/SDL.h> #include <SDL2/SDL_mouse.h> +#include <SDL2/SDL_mixer.h> #include "backends/input.h" #include "backends/rendering.h" #include "backends/lsopengl.h" +#include "platforms/engineutils.h" //The interpretation of texture data change with the endianness #if __BYTE_ORDER == __BIG_ENDIAN @@ -564,3 +566,98 @@ { glGetIntegerv(GL_MAX_TEXTURE_SIZE,data); } + +void mixer_effect_ffmpeg_cb(int chan, void * stream, int len, void * udata) +{ + 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; + } +} + + + +int EngineData::audio_StreamInit(AudioStream* s) +{ + int mixer_channel = -1; + + uint32_t len = LIGHTSPARK_AUDIO_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, s); + Mix_Resume(mixer_channel); + return mixer_channel; +} + +void EngineData::audio_StreamPause(int channel, bool dopause) +{ + if (channel == -1) + return; + if(dopause) + Mix_Pause(channel); + else + Mix_Resume(channel); +} + +void EngineData::audio_StreamSetVolume(int channel, double volume) +{ + int curvolume = SDL_MIX_MAXVOLUME * volume; + if (channel != -1) + Mix_Volume(channel, curvolume); +} + +void EngineData::audio_StreamDeinit(int channel) +{ + if (channel != -1) + Mix_HaltChannel(channel); +} + +bool EngineData::audio_ManagerInit() +{ + bool sdl_available = false; + 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 ); + return sdl_available; +} + +void EngineData::audio_ManagerCloseMixer() +{ + Mix_CloseAudio(); +} + +bool EngineData::audio_ManagerOpenMixer() +{ + return Mix_OpenAudio (audio_getSampleRate(), AUDIO_S16, 2, LIGHTSPARK_AUDIO_BUFFERSIZE) >= 0; +} + +void EngineData::audio_ManagerDeinit() +{ + SDL_QuitSubSystem ( SDL_INIT_AUDIO ); + if (!SDL_WasInit(0)) + SDL_Quit (); +} + +int EngineData::audio_getSampleRate() +{ + return MIX_DEFAULT_FREQUENCY; +} + +IDrawable *EngineData::getTextRenderDrawable(const TextData &_textData, const MATRIX &_m, int32_t _x, int32_t _y, int32_t _w, int32_t _h, float _s, float _a, const std::vector<IDrawable::MaskData> &_ms) +{ + return NULL; +}
View file
lightspark.tar.xz/src/platforms/engineutils.h
Changed
@@ -24,6 +24,9 @@ #include "compat.h" #include "threading.h" #include "tiny_string.h" +#include "backends/graphics.h" + +#define LIGHTSPARK_AUDIO_BUFFERSIZE 8192 namespace lightspark { @@ -38,6 +41,7 @@ #define LS_USEREVENT_QUIT EngineData::userevent+2 class SystemState; class StreamCache; +class AudioStream; class DLL_PUBLIC EngineData { @@ -107,6 +111,7 @@ virtual double getScreenDPI() = 0; virtual StreamCache* createFileStreamCache(); + // OpenGL methods virtual void SwapBuffers() = 0; virtual void InitOpenGL() = 0; virtual void DeinitOpenGL() = 0; @@ -165,6 +170,20 @@ virtual void exec_glPixelStorei_GL_UNPACK_SKIP_ROWS(int32_t param); virtual void exec_glTexSubImage2D_GL_TEXTURE_2D(int32_t level, int32_t xoffset, int32_t yoffset, int32_t width, int32_t height, const void* pixels, uint32_t w, uint32_t curX, uint32_t curY); virtual void exec_glGetIntegerv_GL_MAX_TEXTURE_SIZE(int32_t* data); + + // Audio handling + virtual int audio_StreamInit(AudioStream* s); + virtual void audio_StreamPause(int channel, bool dopause); + virtual void audio_StreamSetVolume(int channel, double volume); + virtual void audio_StreamDeinit(int channel); + virtual bool audio_ManagerInit(); + virtual void audio_ManagerCloseMixer(); + virtual bool audio_ManagerOpenMixer(); + virtual void audio_ManagerDeinit(); + virtual int audio_getSampleRate(); + + // Text rendering + virtual IDrawable* getTextRenderDrawable(const TextData& _textData, const MATRIX& _m, int32_t _x, int32_t _y, int32_t _w, int32_t _h, float _s, float _a, const std::vector<IDrawable::MaskData>& _ms); }; }
View file
lightspark.tar.xz/src/plugin_ppapi/plugin.cpp
Changed
@@ -19,8 +19,6 @@ // TODO -// - sound -// - font loading // - register as separate plugin #include "version.h" @@ -64,6 +62,10 @@ #include "ppapi/c/ppb_file_io.h" #include "ppapi/c/ppb_file_ref.h" #include "ppapi/c/ppb_file_system.h" +#include "ppapi/c/ppb_audio.h" +#include "ppapi/c/ppb_audio_config.h" +#include "ppapi/c/ppb_image_data.h" +#include "ppapi/c/trusted/ppb_browser_font_trusted.h" #include "GLES2/gl2.h" @@ -98,8 +100,10 @@ static const PPB_FileIO* g_fileio_interface = NULL; static const PPB_FileRef* g_fileref_interface = NULL; static const PPB_FileSystem* g_filesystem_interface = NULL; - - +static const PPB_Audio* g_audio_interface = NULL; +static const PPB_AudioConfig* g_audioconfig_interface = NULL; +static const PPB_ImageData* g_imagedata_interface = NULL; +static const PPB_BrowserFont_Trusted* g_browserfont_interface = NULL; ppFileStreamCache::ppFileStreamCache(ppPluginInstance* instance):cache(0),cacheref(0),writeoffset(0),m_instance(instance) { @@ -1385,6 +1389,12 @@ g_fileio_interface = (const PPB_FileIO*)get_browser_interface(PPB_FILEIO_INTERFACE); g_fileref_interface = (const PPB_FileRef*)get_browser_interface(PPB_FILEREF_INTERFACE); g_filesystem_interface = (const PPB_FileSystem*)get_browser_interface(PPB_FILESYSTEM_INTERFACE); + g_audio_interface = (const PPB_Audio*)get_browser_interface(PPB_AUDIO_INTERFACE); + g_audioconfig_interface = (const PPB_AudioConfig*)get_browser_interface(PPB_AUDIO_CONFIG_INTERFACE); + g_imagedata_interface = (const PPB_ImageData*)get_browser_interface(PPB_IMAGEDATA_INTERFACE); + g_browserfont_interface = (const PPB_BrowserFont_Trusted*)get_browser_interface(PPB_BROWSERFONT_TRUSTED_INTERFACE); + + if (!g_core_interface || !g_instance_interface || @@ -1405,7 +1415,12 @@ !g_flashclipboard_interface || !g_fileio_interface || !g_fileref_interface || - !g_filesystem_interface) + !g_filesystem_interface || + !g_audio_interface || + !g_audioconfig_interface || + !g_imagedata_interface || + !g_browserfont_interface + ) { LOG(LOG_ERROR,"get_browser_interface failed:" << g_core_interface <<" " @@ -1427,7 +1442,12 @@ << g_flashclipboard_interface<<" " << g_fileio_interface<<" " << g_fileref_interface<<" " - << g_filesystem_interface); + << g_filesystem_interface<<" " + << g_audio_interface<<" " + << g_audioconfig_interface<<" " + << g_imagedata_interface<<" " + << g_browserfont_interface<<" " + ); return PP_ERROR_NOINTERFACE; } return PP_OK; @@ -1511,13 +1531,6 @@ void ppPluginEngineData::grabFocus() { - LOG(LOG_NOT_IMPLEMENTED,"grabFocus"); - /* - if (!widget_gtk) - return; - - gtk_widget_grab_focus(widget_gtk); - */ } void ppPluginEngineData::setClipboardText(const std::string txt) @@ -1865,3 +1878,136 @@ { g_gles2_interface->GetIntegerv(instance->m_graphics,GL_MAX_TEXTURE_SIZE,data); } + +void audio_callback(void* sample_buffer,uint32_t buffer_size_in_bytes,PP_TimeDelta latency,void* user_data) +{ + AudioStream *s = (AudioStream*)user_data; + if (!s) + return; + + uint32_t readcount = 0; + while (readcount < buffer_size_in_bytes) + { + uint32_t ret = s->getDecoder()->copyFrame((int16_t *)(((unsigned char*)sample_buffer)+readcount), buffer_size_in_bytes-readcount); + if (!ret) + break; + readcount += ret; + } + if (s->getVolume() != 1.0) + { + int16_t *p = (int16_t *)sample_buffer; + for (uint32_t i = 0; i < readcount/2; i++) + { + *p = (*p)*s->getVolume(); + p++; + } + } +} + +int ppPluginEngineData::audio_StreamInit(AudioStream *s) +{ + PP_Resource res = g_audio_interface->Create(instance->m_ppinstance,audioconfig,audio_callback,s); + if (res != 0) + g_audio_interface->StartPlayback(res); + else + LOG(LOG_ERROR,"creating audio interface failed"); + return res; +} + +void ppPluginEngineData::audio_StreamPause(int channel, bool dopause) +{ + if (dopause) + g_audio_interface->StopPlayback(channel); + else + g_audio_interface->StartPlayback(channel); +} + +void ppPluginEngineData::audio_StreamSetVolume(int channel, double volume) +{ +} + +void ppPluginEngineData::audio_StreamDeinit(int channel) +{ + g_audio_interface->StopPlayback(channel); +} + +bool ppPluginEngineData::audio_ManagerInit() +{ + uint32_t fc = g_audioconfig_interface->RecommendSampleFrameCount(instance->m_ppinstance,PP_AUDIOSAMPLERATE_44100,LIGHTSPARK_AUDIO_BUFFERSIZE/2); + audioconfig = g_audioconfig_interface->CreateStereo16Bit(instance->m_ppinstance,PP_AUDIOSAMPLERATE_44100,fc); + return audioconfig != 0; +} + +void ppPluginEngineData::audio_ManagerCloseMixer() +{ +} + +bool ppPluginEngineData::audio_ManagerOpenMixer() +{ + return true; +} + +void ppPluginEngineData::audio_ManagerDeinit() +{ + +} + +int ppPluginEngineData::audio_getSampleRate() +{ + return PP_AUDIOSAMPLERATE_44100; +} + +IDrawable *ppPluginEngineData::getTextRenderDrawable(const TextData &_textData, const MATRIX &_m, int32_t _x, int32_t _y, int32_t _w, int32_t _h, float _s, float _a, const std::vector<IDrawable::MaskData> &_ms) +{ + PP_BrowserFont_Trusted_Description desc; + desc.face = g_var_interface->VarFromUtf8(_textData.font.raw_buf(),_textData.font.numBytes()); + desc.family = PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT; + desc.size = _textData.fontSize; + desc.italic = PP_FALSE; + desc.weight = PP_BROWSERFONT_TRUSTED_WEIGHT_NORMAL; + desc.letter_spacing = 0; + desc.padding = 0; + desc.word_spacing = 0; + desc.small_caps = PP_FALSE; + + PP_Point pos = PP_MakePoint(0, _textData.textHeight); + PP_Size size = PP_MakeSize(_textData.width, _textData.height); + + PP_BrowserFont_Trusted_TextRun text; + text.text = g_var_interface->VarFromUtf8(_textData.text.raw_buf(),_textData.text.numBytes()); + text.override_direction = PP_FALSE; + text.rtl = PP_FALSE; + + uint32_t color = (_textData.textColor.Blue) + (_textData.textColor.Green<<8) + (_textData.textColor.Red<<16) + ((int)(255/_a)<<24); + + PP_Resource image_data = g_imagedata_interface->Create(instance->m_ppinstance,PP_IMAGEDATAFORMAT_BGRA_PREMUL,&size,PP_TRUE); + PP_Resource font = g_browserfont_interface->Create(instance->m_ppinstance,&desc); + if (font == 0) + LOG(LOG_ERROR,"couldn't create font:"<<_textData.font); + g_browserfont_interface->DrawTextAt(font,image_data,&text,&pos,color,NULL,PP_FALSE); + + return new ppFontRenderer(_w,_h,_x,_y,_a,_ms,image_data); +} +ppFontRenderer::ppFontRenderer(int32_t w, int32_t h, int32_t x, int32_t y, float a, const std::vector<MaskData>& m, PP_Resource _image_data) + : IDrawable(w, h, x, y, a, m),ppimage(_image_data) +{ + +} + +ppFontRenderer::~ppFontRenderer() +{ +} + +uint8_t *ppFontRenderer::getPixelBuffer() +{ + uint8_t* data = new uint8_t[this->width*this->height*sizeof(uint32_t)]; + memcpy(data,g_imagedata_interface->Map(ppimage),this->width*this->height*sizeof(uint32_t)); + g_imagedata_interface->Unmap(ppimage); + return data; +} + +void ppFontRenderer::applyCairoMask(cairo_t *cr, int32_t offsetX, int32_t offsetY) const +{ + +} +
View file
lightspark.tar.xz/src/plugin_ppapi/plugin.h
Changed
@@ -142,7 +142,8 @@ public: SystemState* sys; Semaphore swapbuffer_rendering; - ppPluginEngineData(ppPluginInstance* i, uint32_t w, uint32_t h,SystemState* _sys) : EngineData(), instance(i),sys(_sys),swapbuffer_rendering(0) + PP_Resource audioconfig; + ppPluginEngineData(ppPluginInstance* i, uint32_t w, uint32_t h,SystemState* _sys) : EngineData(), instance(i),sys(_sys),swapbuffer_rendering(0),audioconfig(0) { width = w; height = h; @@ -221,6 +222,40 @@ void exec_glPixelStorei_GL_UNPACK_SKIP_ROWS(int32_t param); void exec_glTexSubImage2D_GL_TEXTURE_2D(int32_t level,int32_t xoffset,int32_t yoffset,int32_t width,int32_t height,const void* pixels, uint32_t w, uint32_t curX, uint32_t curY); void exec_glGetIntegerv_GL_MAX_TEXTURE_SIZE(int32_t* data); + + // Audio handling + virtual int audio_StreamInit(AudioStream* s); + virtual void audio_StreamPause(int channel, bool dopause); + virtual void audio_StreamSetVolume(int channel, double volume); + virtual void audio_StreamDeinit(int channel); + virtual bool audio_ManagerInit(); + virtual void audio_ManagerCloseMixer(); + virtual bool audio_ManagerOpenMixer(); + virtual void audio_ManagerDeinit(); + virtual int audio_getSampleRate(); + + // Text rendering + virtual IDrawable* getTextRenderDrawable(const TextData& _textData, const MATRIX& _m, int32_t _x, int32_t _y, int32_t _w, int32_t _h, float _s, float _a, const std::vector<IDrawable::MaskData>& _ms); +}; + +class ppFontRenderer : public IDrawable +{ + PP_Resource ppimage; +public: + ppFontRenderer(int32_t w, int32_t h, int32_t x, int32_t y, float a, const std::vector<MaskData>& m,PP_Resource _image_data); + ~ppFontRenderer(); + /* + * This method returns a raster buffer of the image + * The various implementation are responsible for applying the + * masks + */ + virtual uint8_t* getPixelBuffer(); + /* + * This method creates a cairo path that can be used as a mask for + * another object + */ + virtual void applyCairoMask(cairo_t* cr, int32_t offsetX, int32_t offsetY) const; + }; }
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.cpp
Changed
@@ -31,7 +31,7 @@ using namespace lightspark; using namespace std; -SoundTransform::SoundTransform(Class_base* c): ASObject(c),leftToLeft(1.0),leftToRight(0),rightToLeft(0),rightToRight(1.0) +SoundTransform::SoundTransform(Class_base* c): ASObject(c),volume(1.0),pan(0.0),leftToLeft(1.0),leftToRight(0),rightToLeft(0),rightToRight(1.0) { } @@ -402,7 +402,7 @@ SoundChannel::SoundChannel(Class_base* c, _NR<StreamCache> _stream, AudioFormat _format) : EventDispatcher(c),stream(_stream),stopped(false),audioDecoder(NULL),audioStream(NULL), - format(_format),position(0),soundTransform(_MR(Class<SoundTransform>::getInstanceS(c->getSystemState()))) + format(_format),oldVolume(-1.0),position(0),soundTransform(_MR(Class<SoundTransform>::getInstanceS(c->getSystemState()))) { if (!stream.isNull()) { @@ -480,7 +480,7 @@ try { #ifdef ENABLE_LIBAVCODEC - streamDecoder=new FFMpegStreamDecoder(s,&format,stream->hasTerminated() ? stream->getReceivedLength() : -1); + streamDecoder=new FFMpegStreamDecoder(this->getSystemState()->getEngineData(),s,&format,stream->hasTerminated() ? stream->getReceivedLength() : -1); if(!streamDecoder->isValid()) threadAbort(); @@ -500,6 +500,16 @@ if(audioStream) position=audioStream->getPlayedTime(); + if(audioStream) + { + //TODO: use soundTransform->pan + if(soundTransform && soundTransform->volume != oldVolume) + { + audioStream->setVolume(soundTransform->volume); + oldVolume = soundTransform->volume; + } + } + if(threadAborting) throw JobTerminationException(); }
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.h
Changed
@@ -89,6 +89,7 @@ AudioDecoder* audioDecoder; AudioStream* audioStream; AudioFormat format; + number_t oldVolume; ASPROPERTY_GETTER_SETTER(uint32_t,position); ASPROPERTY_GETTER_SETTER(_NR<SoundTransform>,soundTransform); void validateSoundTransform(_NR<SoundTransform>);
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.cpp
Changed
@@ -1805,7 +1805,7 @@ if (!streamDecoder->isValid()) // not FLV stream, so we try ffmpeg detection { s.seekg(0); - streamDecoder=new FFMpegStreamDecoder(s); + streamDecoder=new FFMpegStreamDecoder(this->getSystemState()->getEngineData(),s); } if(!streamDecoder->isValid()) threadAbort();
View file
lightspark.tar.xz/src/scripting/flash/text/flashtext.cpp
Changed
@@ -1004,6 +1004,10 @@ return NULL; if(totalMatrix.getScaleX() != 1 || totalMatrix.getScaleY() != 1) LOG(LOG_NOT_IMPLEMENTED, "TextField when scaled is not correctly implemented"); + // use specialized Renderer from EngineData, if available, otherwise fallback to Pango + IDrawable* res = this->getSystemState()->getEngineData()->getTextRenderDrawable(*this,totalMatrix, x, y, width, height, 1.0f,getConcatenatedAlpha(), masks); + if (res != NULL) + return res; /** TODO: The scaling is done differently for textfields : height changes are applied directly on the font size. In some cases, it can change the width (if autosize is on and wordwrap off). Width changes do not change the font size, and do nothing when autosize is on and wordwrap off.
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -249,7 +249,7 @@ threadPool=new ThreadPool(this); timerThread=new TimerThread(this); frameTimerThread=new TimerThread(this); - audioManager=new AudioManager(); + audioManager=NULL; intervalManager=new IntervalManager(); securityManager=new SecurityManager(); @@ -723,6 +723,7 @@ */ void SystemState::delayedCreation(SystemState* sys) { + sys->audioManager=new AudioManager(sys->engineData); int32_t reqWidth=sys->mainClip->getFrameSize().Xmax/20; int32_t reqHeight=sys->mainClip->getFrameSize().Ymax/20;
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
.