Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

~split head file into h+cc

  • Loading branch information...
commit f6bd9793537a708835edd69966127e8c0f83bbfe 1 parent 12fe34e
@bsdelf authored
Showing with 148 additions and 131 deletions.
  1. +138 −0 frontend/ncurses/MousData.cc
  2. +10 −131 frontend/ncurses/MousData.h
View
138 frontend/ncurses/MousData.cc
@@ -0,0 +1,138 @@
+#include "MousData.h"
+
+#include <scx/Signal.hpp>
+using namespace scx;
+
+#include "Config.h"
+
+MousData::MousData():
+ playlists(6),
+ usedPlaylist(-1),
+ selectedPlaylist(1),
+ selectedItem(6, 0)
+{
+ mgr = IPluginManager::Create();
+ loader = IMediaLoader::Create();
+ player = IPlayer::Create();
+ player->SigFinished()->Connect(&MousData::SlotFinished, this);
+}
+
+MousData::~MousData()
+{
+ player->SigFinished()->DisconnectReceiver(this);
+
+ ClosePlayer();
+
+ IPluginManager::Free(mgr);
+ IMediaLoader::Free(loader);
+ IPlayer::Free(player);
+
+ ClearPlaylists();
+}
+
+bool MousData::Init()
+{
+ const Config* config = GlobalConfig::Instance();
+ if (config == NULL)
+ return false;
+
+ if (!mgr->LoadPluginDir(config->pluginDir))
+ return false;
+
+ typedef vector<const IPluginAgent*> PluginAgentArray;
+
+ PluginAgentArray decoders;
+ mgr->DumpPluginAgent(decoders, PluginType::Decoder);
+ //PluginAgentArray encoders;
+ //mgr->DumpPluginAgent(encoders, PluginType::Encoder);
+ PluginAgentArray renderers;
+ mgr->DumpPluginAgent(renderers, PluginType::Renderer);
+ PluginAgentArray mediaPacks;
+ mgr->DumpPluginAgent(mediaPacks, PluginType::MediaPack);
+ PluginAgentArray tagParsers;
+ mgr->DumpPluginAgent(tagParsers, PluginType::TagParser);
+
+ loader->RegisterMediaPackPlugin(mediaPacks);
+ loader->RegisterTagParserPlugin(tagParsers);
+
+ player->RegisterRendererPlugin(renderers[0]);
+ player->RegisterDecoderPlugin(decoders);
+
+ return true;
+}
+
+void MousData::Cleanup()
+{
+ loader->UnregisterAll();
+ player->UnregisterAll();
+ mgr->UnloadAll();
+}
+
+void MousData::ClearPlaylists()
+{
+ for (size_t i = 0; i < playlists.size(); ++i) {
+ playlist_t& list = playlists[i];
+ for (int n = 0; n < list.Count(); ++n)
+ delete list[n];
+ }
+}
+
+void MousData::PlayAt(int iList, int iItem)
+{
+ usedPlaylist = iList;
+ MousData::playlist_t& list = playlists[iList];
+
+ MediaItem* item = NULL;
+ list.SeqJumpTo(iItem);
+ list.SeqCurrent(item);
+
+ PlayItem(item);
+}
+
+void MousData::ClosePlayer()
+{
+ if (player->Status() != PlayerStatus::Closed)
+ player->Close();
+}
+
+void MousData::PausePlayer()
+{
+ switch (player->Status()) {
+ case PlayerStatus::Playing:
+ player->Pause();
+ break;
+
+ case PlayerStatus::Paused:
+ player->Resume();
+ break;
+
+ default:
+ break;
+ }
+}
+
+void MousData::SlotFinished()
+{
+ MutexLocker locker(&mutex);
+
+ playlist_t& list = playlists[usedPlaylist];
+ MediaItem* item = NULL;
+ if (list.SeqCurrent(item, 1)) {
+ list.SeqMoveNext();
+ list.SeqCurrent(item);
+ }
+ if (item != NULL) {
+ PlayItem(item);
+ }
+}
+
+void MousData::PlayItem(const MediaItem* item)
+{
+ ClosePlayer();
+
+ player->Open(item->url);
+ if (item->hasRange)
+ player->Play(item->msBeg, item->msEnd);
+ else
+ player->Play();
+}
View
141 frontend/ncurses/MousData.h
@@ -1,12 +1,10 @@
#ifndef MOUSDATA_H
#define MOUSDATA_H
-#include <string>
#include <vector>
using namespace std;
#include <scx/Mutex.hpp>
-#include <scx/Signal.hpp>
using namespace scx;
#include <util/MediaItem.h>
@@ -17,8 +15,6 @@ using namespace scx;
#include <core/ITagParserFactory.h>
using namespace mous;
-#include "Config.h"
-
struct MousData
{
Mutex mutex;
@@ -34,138 +30,21 @@ struct MousData
int selectedPlaylist;
vector<int> selectedItem;
- MousData():
- playlists(6),
- usedPlaylist(-1),
- selectedPlaylist(1),
- selectedItem(6, 0)
- {
- mgr = IPluginManager::Create();
- loader = IMediaLoader::Create();
- player = IPlayer::Create();
- player->SigFinished()->Connect(&MousData::SlotFinished, this);
- }
-
- ~MousData()
- {
- player->SigFinished()->DisconnectReceiver(this);
-
- ClosePlayer();
-
- IPluginManager::Free(mgr);
- IMediaLoader::Free(loader);
- IPlayer::Free(player);
-
- ClearPlaylists();
- }
-
- bool Init()
- {
- const Config* config = GlobalConfig::Instance();
- if (config == NULL)
- return false;
-
- if (!mgr->LoadPluginDir(config->pluginDir))
- return false;
-
- typedef vector<const IPluginAgent*> PluginAgentArray;
-
- PluginAgentArray decoders;
- mgr->DumpPluginAgent(decoders, PluginType::Decoder);
- //PluginAgentArray encoders;
- //mgr->DumpPluginAgent(encoders, PluginType::Encoder);
- PluginAgentArray renderers;
- mgr->DumpPluginAgent(renderers, PluginType::Renderer);
- PluginAgentArray mediaPacks;
- mgr->DumpPluginAgent(mediaPacks, PluginType::MediaPack);
- PluginAgentArray tagParsers;
- mgr->DumpPluginAgent(tagParsers, PluginType::TagParser);
-
- loader->RegisterMediaPackPlugin(mediaPacks);
- loader->RegisterTagParserPlugin(tagParsers);
+ MousData();
+ ~MousData();
- player->RegisterRendererPlugin(renderers[0]);
- player->RegisterDecoderPlugin(decoders);
+ bool Init();
+ void Cleanup();
+ void ClearPlaylists();
- return true;
- }
-
- void Cleanup()
- {
- loader->UnregisterAll();
- player->UnregisterAll();
- mgr->UnloadAll();
- }
-
- void ClearPlaylists()
- {
- for (size_t i = 0; i < playlists.size(); ++i) {
- playlist_t& list = playlists[i];
- for (int n = 0; n < list.Count(); ++n)
- delete list[n];
- }
- }
-
- void PlayAt(int iList, int iItem)
- {
- usedPlaylist = iList;
- MousData::playlist_t& list = playlists[iList];
-
- MediaItem* item = NULL;
- list.SeqJumpTo(iItem);
- list.SeqCurrent(item);
-
- PlayItem(item);
- }
-
- void ClosePlayer()
- {
- if (player->Status() != PlayerStatus::Closed)
- player->Close();
- }
-
- void PausePlayer()
- {
- switch (player->Status()) {
- case PlayerStatus::Playing:
- player->Pause();
- break;
-
- case PlayerStatus::Paused:
- player->Resume();
- break;
-
- default:
- break;
- }
- }
+ void PlayAt(int iList, int iItem);
+ void ClosePlayer();
+ void PausePlayer();
private:
- void SlotFinished()
- {
- MutexLocker locker(&mutex);
-
- playlist_t& list = playlists[usedPlaylist];
- MediaItem* item = NULL;
- if (list.SeqCurrent(item, 1)) {
- list.SeqMoveNext();
- list.SeqCurrent(item);
- }
- if (item != NULL) {
- PlayItem(item);
- }
- }
-
- void PlayItem(const MediaItem* item)
- {
- ClosePlayer();
+ void SlotFinished();
- player->Open(item->url);
- if (item->hasRange)
- player->Play(item->msBeg, item->msEnd);
- else
- player->Play();
- }
+ void PlayItem(const MediaItem* item);
};
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.