<commit_before>#include "VideoSource.h"

namespace ofx {
  namespace piMapper {
    VideoSource::VideoSource() {
      //cout << "VideoSource constr" << endl;
      loadable = true;
      loaded = false;
      type = SourceType::SOURCE_TYPE_VIDEO;
#ifdef TARGET_RASPBERRY_PI
      omxPlayer = NULL;
#else
      videoPlayer = NULL;

#endif
    }
    
    VideoSource::~VideoSource() {}
    
    void VideoSource::loadVideo(std::string& filePath) {
      path = filePath;
      //cout << "loading video: " << filePath << endl;
      setNameFromPath(filePath);
#ifdef TARGET_RASPBERRY_PI
      // Do things with the OMX player
      ofxOMXPlayerSettings settings;
      settings.videoPath = filePath;
      settings.useHDMIForAudio = true;	//default true
      settings.enableTexture = true;		//default true
      settings.enableLooping = true;		//default true
      settings.enableAudio = false;		//default true, save resources by disabling
      //settings.doFlipTexture = true;		//default false
      omxPlayer = new ofxOMXPlayer();
      omxPlayer->setup(settings);
      texture = &(omxPlayer->getTextureReference());
#else
      // regular ofVideoPlayer
      videoPlayer = new ofVideoPlayer();
      videoPlayer->loadMovie(filePath);
      videoPlayer->setLoopState(OF_LOOP_NORMAL);
      videoPlayer->play();
      texture = &(videoPlayer->getTextureReference());
      ofAddListener(ofEvents().update, this, &VideoSource::update);
#endif
      loaded = true;
    }
    
    void VideoSource::clear() {
      ofRemoveListener(ofEvents().update, this, &VideoSource::update);
      texture = NULL;
#ifdef TARGET_RASPBERRY_PI
      omxPlayer->close();
      delete omxPlayer;
      omxPlayer = NULL;
#else
      videoPlayer->stop();
      videoPlayer->close();
      delete videoPlayer;
      videoPlayer = NULL;
#endif
      //path = "";
      //name = "";
      loaded = false;
    }
    
#ifndef TARGET_RASPBERRY_PI
    void VideoSource::update(ofEventArgs &args) {
      if (videoPlayer != NULL) {
        videoPlayer->update();
      }
    }
#endif
  }
}<commit_msg>Move remove update listener part from raspberry pi platform part<commit_after>#include "VideoSource.h"

namespace ofx {
  namespace piMapper {
    VideoSource::VideoSource() {
      //cout << "VideoSource constr" << endl;
      loadable = true;
      loaded = false;
      type = SourceType::SOURCE_TYPE_VIDEO;
#ifdef TARGET_RASPBERRY_PI
      omxPlayer = NULL;
#else
      videoPlayer = NULL;

#endif
    }
    
    VideoSource::~VideoSource() {}
    
    void VideoSource::loadVideo(std::string& filePath) {
      path = filePath;
      //cout << "loading video: " << filePath << endl;
      setNameFromPath(filePath);
#ifdef TARGET_RASPBERRY_PI
      // Do things with the OMX player
      ofxOMXPlayerSettings settings;
      settings.videoPath = filePath;
      settings.useHDMIForAudio = true;	//default true
      settings.enableTexture = true;		//default true
      settings.enableLooping = true;		//default true
      settings.enableAudio = false;		//default true, save resources by disabling
      //settings.doFlipTexture = true;		//default false
      omxPlayer = new ofxOMXPlayer();
      omxPlayer->setup(settings);
      texture = &(omxPlayer->getTextureReference());
#else
      // regular ofVideoPlayer
      videoPlayer = new ofVideoPlayer();
      videoPlayer->loadMovie(filePath);
      videoPlayer->setLoopState(OF_LOOP_NORMAL);
      videoPlayer->play();
      texture = &(videoPlayer->getTextureReference());
      ofAddListener(ofEvents().update, this, &VideoSource::update);
#endif
      loaded = true;
    }
    
    void VideoSource::clear() {
      texture = NULL;
#ifdef TARGET_RASPBERRY_PI
      omxPlayer->close();
      delete omxPlayer;
      omxPlayer = NULL;
#else
      ofRemoveListener(ofEvents().update, this, &VideoSource::update);
      videoPlayer->stop();
      videoPlayer->close();
      delete videoPlayer;
      videoPlayer = NULL;
#endif
      //path = "";
      //name = "";
      loaded = false;
    }
    
#ifndef TARGET_RASPBERRY_PI
    void VideoSource::update(ofEventArgs &args) {
      if (videoPlayer != NULL) {
        videoPlayer->update();
      }
    }
#endif
  }
}
{'fraction_non_alphanumeric': 0.11865618298784847, 'fraction_numerical': 0.0, 'mean_word_length': 2.788808664259928, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3487723', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1261, 'n_words': 273}