author | simon <simon> | 2002-12-11 00:29:22 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 00:29:22 (UTC) |
commit | 7d5782ef4fd19498a141ed68c23145dcc6128146 (patch) (unidiff) | |
tree | 8cdbd360962b3fa161823fa88b43e9584b23a464 /noncore/multimedia/opieplayer2/lib.cpp | |
parent | 6c71f5ccd9506234a317d9ff3d119613c457e769 (diff) | |
download | opie-7d5782ef4fd19498a141ed68c23145dcc6128146.zip opie-7d5782ef4fd19498a141ed68c23145dcc6128146.tar.gz opie-7d5782ef4fd19498a141ed68c23145dcc6128146.tar.bz2 |
- initialized xine in a background thread. much time is still spend in
skin loading though.
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 99d5de6..20fd1e2 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -65,33 +65,40 @@ extern "C" { | |||
65 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 65 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
66 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 66 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
67 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 67 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
68 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 68 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
69 | } | 69 | } |
70 | 70 | ||
71 | using namespace XINE; | 71 | using namespace XINE; |
72 | 72 | ||
73 | Lib::Lib( XineVideoWidget* widget ) { | 73 | Lib::Lib( XineVideoWidget* widget ) |
74 | { | ||
75 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
74 | m_initialized = false; | 76 | m_initialized = false; |
75 | m_video = false; | 77 | m_video = false; |
76 | m_wid = widget; | 78 | m_wid = widget; |
77 | printf("Lib"); | 79 | printf("Lib"); |
78 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 80 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
79 | // get the configuration | 81 | // get the configuration |
80 | 82 | ||
81 | // not really OO, should be an extra class, later | 83 | // not really OO, should be an extra class, later |
82 | if ( !QFile::exists(configPath) ) { | 84 | if ( !QFile::exists(configPath) ) { |
83 | QFile f(configPath); | 85 | QFile f(configPath); |
84 | f.open(IO_WriteOnly); | 86 | f.open(IO_WriteOnly); |
85 | QTextStream ts( &f ); | 87 | QTextStream ts( &f ); |
86 | ts << "misc.memcpy_method:glibc\n"; | 88 | ts << "misc.memcpy_method:glibc\n"; |
87 | f.close(); | 89 | f.close(); |
88 | } | 90 | } |
89 | 91 | ||
92 | start(); | ||
93 | } | ||
94 | |||
95 | void Lib::run() | ||
96 | { | ||
90 | initialize(); | 97 | initialize(); |
91 | } | 98 | } |
92 | 99 | ||
93 | void Lib::initialize() | 100 | void Lib::initialize() |
94 | { | 101 | { |
95 | m_xine = xine_new( ); | 102 | m_xine = xine_new( ); |
96 | 103 | ||
97 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 104 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
@@ -119,17 +126,20 @@ void Lib::initialize() | |||
119 | 126 | ||
120 | // m_wid->repaint(); | 127 | // m_wid->repaint(); |
121 | } | 128 | } |
122 | 129 | ||
123 | m_queue = xine_event_new_queue (m_stream); | 130 | m_queue = xine_event_new_queue (m_stream); |
124 | 131 | ||
125 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 132 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
126 | 133 | ||
134 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
127 | m_initialized = true; | 135 | m_initialized = true; |
136 | |||
137 | send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay ); | ||
128 | } | 138 | } |
129 | 139 | ||
130 | Lib::~Lib() { | 140 | Lib::~Lib() { |
131 | ThreadUtil::AutoLock lock( m_initGuard ); | 141 | ThreadUtil::AutoLock lock( m_initGuard ); |
132 | 142 | ||
133 | assert( m_initialized ); | 143 | assert( m_initialized ); |
134 | 144 | ||
135 | // free( m_config ); | 145 | // free( m_config ); |
@@ -279,22 +289,29 @@ int Lib::error() const { | |||
279 | assertInitialized(); | 289 | assertInitialized(); |
280 | 290 | ||
281 | return xine_get_error( m_stream ); | 291 | return xine_get_error( m_stream ); |
282 | }; | 292 | }; |
283 | 293 | ||
284 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 294 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
285 | { | 295 | { |
286 | assert( sendType == ThreadUtil::Channel::OneWay ); | 296 | assert( sendType == ThreadUtil::Channel::OneWay ); |
287 | handleXineEvent( msg->type() ); | 297 | switch ( msg->type() ) { |
298 | case XineMessageType: | ||
299 | handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent ); | ||
300 | break; | ||
301 | case InitializationMessageType: | ||
302 | emit initialized(); | ||
303 | break; | ||
304 | } | ||
288 | delete msg; | 305 | delete msg; |
289 | } | 306 | } |
290 | 307 | ||
291 | void Lib::handleXineEvent( const xine_event_t* t ) { | 308 | void Lib::handleXineEvent( const xine_event_t* t ) { |
292 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 309 | send( new XineMessage( t->type ), OneWay ); |
293 | } | 310 | } |
294 | 311 | ||
295 | void Lib::handleXineEvent( int type ) { | 312 | void Lib::handleXineEvent( int type ) { |
296 | assertInitialized(); | 313 | assertInitialized(); |
297 | 314 | ||
298 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 315 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
299 | emit stopped(); | 316 | emit stopped(); |
300 | } | 317 | } |