Browse Source
A possible way to fix application crashing when unloading last omx player video source.master
2 changed files with 65 additions and 0 deletions
@ -0,0 +1,42 @@ |
|||||
|
#include "OMXPlayerCache.h" |
||||
|
|
||||
|
namespace ofx { |
||||
|
namespace piMapper { |
||||
|
|
||||
|
OMXPlayerCache * OMXPlayerCache::_instance = 0; |
||||
|
|
||||
|
OMXPlayerCache * OMXPlayerCache::instance(){ |
||||
|
if(_instance == 0){ |
||||
|
_instance = new ofx::piMapper::OMXPlayerCache(); |
||||
|
} |
||||
|
return _instance; |
||||
|
} |
||||
|
|
||||
|
ofxOMXPlayer * OMXPlayerCache::load(string moviePath){ |
||||
|
if(_players.find(moviePath) == _players.end()){ |
||||
|
ofxOMXPlayerSettings settings; |
||||
|
settings.videoPath = moviePath; |
||||
|
settings.useHDMIForAudio = true; |
||||
|
settings.enableTexture = true; |
||||
|
settings.enableLooping = true; |
||||
|
settings.enableAudio = VideoSource::enableAudio; |
||||
|
|
||||
|
ofxOMXPlayer * p = new ofxOMXPlayer(); |
||||
|
p->setup(settings); |
||||
|
_players.push_back(p); |
||||
|
|
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
_players[moviePath]->restartMovie(); |
||||
|
return _players[moviePath]; |
||||
|
} |
||||
|
|
||||
|
void OMXPlayerCache::unload(string moviePath){ |
||||
|
if(_players.find(moviePath) != _players.end()){ |
||||
|
_players[moviePath]->setPaused(true); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -0,0 +1,23 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include "ofMain.h" |
||||
|
#include "ofxOMXPlayer.h" |
||||
|
|
||||
|
namespace ofx { |
||||
|
namespace piMapper { |
||||
|
|
||||
|
class OMXPlayerCache { |
||||
|
|
||||
|
public: |
||||
|
static OMXPlayerCache * instance(); |
||||
|
ofxOMXPlayer * load(string moviePath); |
||||
|
void unload(string moviePath); |
||||
|
|
||||
|
private: |
||||
|
static OMXPlayerCache * _instance; |
||||
|
map <string, ofxOMXPlayer *> _players; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
Loading…
Reference in new issue