+#include <algorithm>
#include <stdexcept>
#include <msp/fs/dir.h>
#include <msp/graphics/display_private.h>
#include <msp/graphics/window_private.h>
#include "xineengine.h"
+#include "xinestream.h"
using namespace std;
using namespace Msp;
xine_exit(engine);
}
+void XineEngine::add_stream(XineStream &stream)
+{
+ streams.push_back(&stream);
+}
+
+void XineEngine::remove_stream(XineStream &stream)
+{
+ list<XineStream *>::iterator i = find(streams.begin(), streams.end(), &stream);
+ if(i!=streams.end())
+ streams.erase(i);
+}
+
void XineEngine::tick()
{
if(pending_expose)
delete pending_expose;
pending_expose = 0;
}
+
+ for(list<XineStream *>::const_iterator i=streams.begin(); i!=streams.end(); ++i)
+ (*i)->tick();
}
void XineEngine::window_exposed(unsigned, unsigned, unsigned, unsigned, const Graphics::Window::Event &event)
x11_visual_t visual;
xine_video_port_t *video_driver;
Msp::Graphics::Window::Event *pending_expose;
+ std::list<XineStream *> streams;
public:
XineEngine(Msp::Graphics::Window &, Msp::Mutex * = 0);
xine_audio_port_t *get_audio_driver() { return audio_driver; }
xine_video_port_t *get_video_driver() { return video_driver; }
+ void add_stream(XineStream &);
+ void remove_stream(XineStream &);
+
void tick();
private:
}
engine->tick();
- if(stream)
- stream->tick();
Time::sleep(10*Time::msec);
}
using namespace std;
using namespace Msp;
-XineStream::XineStream(XineEngine &engine, const string &mrl)
+XineStream::XineStream(XineEngine &e, const string &mrl):
+ engine(e)
{
stream = xine_stream_new(engine.get_engine(), engine.get_audio_driver(), engine.get_video_driver());
xine_open(stream, mrl.c_str());
queue = xine_event_new_queue(stream);
+
+ engine.add_stream(*this);
}
XineStream::~XineStream()
{
+ engine.remove_stream(*this);
+
xine_close(stream);
xine_event_dispose_queue(queue);
xine_dispose(stream);
class XineStream
{
private:
+ XineEngine &engine;
xine_stream_t *stream;
xine_event_queue_t *queue;