X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fxinema.cpp;h=499154387e67eef838531e017ca944afe03007ea;hb=5649d49616296df01f821e03a064c6966561bc99;hp=953310ad93cd868f4763ac85585a603298381e0a;hpb=b59b30ecd8131677b42232722df901120bd62213;p=xinema.git diff --git a/source/xinema.cpp b/source/xinema.cpp index 953310a..4991543 100644 --- a/source/xinema.cpp +++ b/source/xinema.cpp @@ -1,10 +1,10 @@ #include -#include #include #include -#include -#include +#include +#include "xineengine.h" #include "xinema.h" +#include "xinestream.h" using namespace std; using namespace Msp; @@ -15,95 +15,85 @@ Xinema::EarlyInit::EarlyInit() } -Xinema::Xinema(int argc, char **argv): - window(display, 1920, 1080) +Xinema::Xinema(int, char **): + window(display, 1920, 1080), + network(*this), + engine(0), + stream(0), + logo_mode(false), + pending_logo(false) { - GetOpt getopt; - getopt.add_argument("filename", filename, GetOpt::REQUIRED_ARG); - getopt(argc, argv); - window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Xinema::exit), 0)); } int Xinema::main() { - xine = xine_new(); - - FS::Path config_fn = FS::get_home_dir()/".xine"/"config"; - xine_config_load(xine, config_fn.c_str()); - - xine_init(xine); - - xine_audio = xine_open_audio_driver(xine, "auto", 0); - - XLockDisplay(display.get_private().display); window.show(); - XSync(display.get_private().display, false); - XUnlockDisplay(display.get_private().display); - - xine_visual.display = display.get_private().display; - xine_visual.screen = 0; - xine_visual.d = window.get_private().window; - xine_visual.user_data = this; - xine_visual.dest_size_cb = &dest_size_cb; - xine_visual.frame_output_cb = &frame_output_cb; - - xine_video = xine_open_video_driver(xine, "auto", XINE_VISUAL_TYPE_X11, &xine_visual); - - xine_stream = xine_stream_new(xine, xine_audio, xine_video); - xine_open(xine_stream, filename.c_str()); - xine_play(xine_stream, 0, 0); + display.tick(); - xine_queue = xine_event_new_queue(xine_stream); + engine = new XineEngine(window); + show_logo(); Application::main(); - xine_close(xine_stream); - xine_event_dispose_queue(xine_queue); - xine_dispose(xine_stream); - xine_close_video_driver(xine, xine_video); - xine_close_audio_driver(xine, xine_audio); - xine_exit(xine); + if(stream) + delete stream; + delete engine; return exit_code; } void Xinema::tick() { + string mrl; + bool logo; + { + MutexLock lock(command_mutex); + mrl = pending_mrl; + logo = pending_logo; + pending_mrl.clear(); + pending_logo = false; + } + + if(!mrl.empty()) + { + bool had_stream = stream; + + delete stream; + stream = 0; + + if(had_stream && !logo_mode) + signal_stream_destroyed.emit(); + + logo_mode = logo; + stream = new XineStream(*engine, mrl); + if(!logo_mode) + stream->signal_finished.connect(sigc::mem_fun(this, &Xinema::show_logo)); + stream->play(); + + if(!logo_mode) + signal_stream_created.emit(*stream); + } + XLockDisplay(display.get_private().display); display.tick(); XUnlockDisplay(display.get_private().display); - while(xine_event_t *event = xine_event_get(xine_queue)) - { - switch(event->type) - { - case XINE_EVENT_PROGRESS: - { - xine_progress_data_t *data = reinterpret_cast(event->data); - IO::print("%s [%d%%]\n", data->description, data->percent); - } - break; - } - } + engine->tick(); + + Time::sleep(10*Time::msec); } -void Xinema::dest_size_cb(void *user_data, int, int, double, int *dest_width, int *dest_height, double *dest_pixel_aspect) +void Xinema::play_file(const FS::Path &fn) { - Xinema &xinema = *reinterpret_cast(user_data); - *dest_width = xinema.window.get_width(); - *dest_height = xinema.window.get_height(); - *dest_pixel_aspect = 1.0; + MutexLock lock(command_mutex); + pending_mrl = "file://"+fn.str(); + pending_logo = false; } -void Xinema::frame_output_cb(void *user_data, int, int, double, int *dest_x, int *dest_y, int *dest_width, int *dest_height, double *dest_pixel_aspect, int *win_x, int *win_y) +void Xinema::show_logo() { - Xinema &xinema = *reinterpret_cast(user_data); - *dest_x = 0; - *dest_y = 0; - *dest_width = xinema.window.get_width(); - *dest_height = xinema.window.get_height(); - *dest_pixel_aspect = 1.0; - *win_x = 0; - *win_y = 0; + MutexLock lock(command_mutex); + pending_mrl = "file://"+(FS::get_sys_data_dir()/"xinema.png").str(); + pending_logo = true; }