summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp92
1 files changed, 2 insertions, 90 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 20fd1e2..1e0dc21 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -72,8 +72,6 @@ using namespace XINE;
72 72
73Lib::Lib( XineVideoWidget* widget ) 73Lib::Lib( XineVideoWidget* widget )
74{ 74{
75 ThreadUtil::AutoLock lock( m_initGuard );
76 m_initialized = false;
77 m_video = false; 75 m_video = false;
78 m_wid = widget; 76 m_wid = widget;
79 printf("Lib"); 77 printf("Lib");
@@ -89,19 +87,8 @@ Lib::Lib( XineVideoWidget* widget )
89 f.close(); 87 f.close();
90 } 88 }
91 89
92 start();
93}
94
95void Lib::run()
96{
97 initialize();
98}
99
100void Lib::initialize()
101{
102 m_xine = xine_new( ); 90 m_xine = xine_new( );
103 91
104 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
105 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 92 xine_config_load( m_xine, QFile::encodeName( configPath ) );
106 93
107 xine_init( m_xine ); 94 xine_init( m_xine );
@@ -130,18 +117,9 @@ void Lib::initialize()
130 m_queue = xine_event_new_queue (m_stream); 117 m_queue = xine_event_new_queue (m_stream);
131 118
132 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 119 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
133
134 ThreadUtil::AutoLock lock( m_initGuard );
135 m_initialized = true;
136
137 send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay );
138} 120}
139 121
140Lib::~Lib() { 122Lib::~Lib() {
141 ThreadUtil::AutoLock lock( m_initGuard );
142
143 assert( m_initialized );
144
145// free( m_config ); 123// free( m_config );
146 124
147 xine_close( m_stream ); 125 xine_close( m_stream );
@@ -156,17 +134,6 @@ Lib::~Lib() {
156 //delete m_audioOutput; 134 //delete m_audioOutput;
157} 135}
158 136
159void Lib::assertInitialized() const
160{
161 ThreadUtil::AutoLock lock( m_initGuard );
162
163 if ( m_initialized )
164 return;
165
166 qDebug( "LibXine: xine function called while not being initialized, yet! Fix the caller!" );
167 assert( m_initialized );
168}
169
170void Lib::resize ( const QSize &s ) { 137void Lib::resize ( const QSize &s ) {
171 if ( s. width ( ) && s. height ( ) ) { 138 if ( s. width ( ) && s. height ( ) ) {
172 ::null_set_gui_width( m_videoOutput, s. width() ); 139 ::null_set_gui_width( m_videoOutput, s. width() );
@@ -193,8 +160,6 @@ int Lib::subVersion() {
193} 160}
194 161
195int Lib::play( const QString& fileName, int startPos, int start_time ) { 162int Lib::play( const QString& fileName, int startPos, int start_time ) {
196 assertInitialized();
197
198 QString str = fileName.stripWhiteSpace(); 163 QString str = fileName.stripWhiteSpace();
199 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 164 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
200 return 0; 165 return 0;
@@ -203,69 +168,49 @@ int Lib::play( const QString& fileName, int startPos, int start_time ) {
203} 168}
204 169
205void Lib::stop() { 170void Lib::stop() {
206 assertInitialized();
207
208 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 171 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
209 xine_stop( m_stream ); 172 xine_stop( m_stream );
210} 173}
211 174
212void Lib::pause( bool toggle ) { 175void Lib::pause( bool toggle ) {
213 assertInitialized();
214
215 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 176 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
216} 177}
217 178
218int Lib::speed() const { 179int Lib::speed() const {
219 assertInitialized();
220
221 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 180 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
222} 181}
223 182
224void Lib::setSpeed( int speed ) { 183void Lib::setSpeed( int speed ) {
225 assertInitialized();
226
227 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 184 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
228} 185}
229 186
230int Lib::status() const { 187int Lib::status() const {
231 assertInitialized();
232
233 return xine_get_status( m_stream ); 188 return xine_get_status( m_stream );
234} 189}
235 190
236int Lib::currentPosition() const { 191int Lib::currentPosition() const {
237 assertInitialized();
238
239 int pos, time, length; 192 int pos, time, length;
240 xine_get_pos_length( m_stream, &pos, &time, &length ); 193 xine_get_pos_length( m_stream, &pos, &time, &length );
241 return pos; 194 return pos;
242} 195}
243 196
244int Lib::currentTime() const { 197int Lib::currentTime() const {
245 assertInitialized();
246
247 int pos, time, length; 198 int pos, time, length;
248 xine_get_pos_length( m_stream, &pos, &time, &length ); 199 xine_get_pos_length( m_stream, &pos, &time, &length );
249 return time/1000; 200 return time/1000;
250} 201}
251 202
252int Lib::length() const { 203int Lib::length() const {
253 assertInitialized();
254
255 int pos, time, length; 204 int pos, time, length;
256 xine_get_pos_length( m_stream, &pos, &time, &length ); 205 xine_get_pos_length( m_stream, &pos, &time, &length );
257 return length/1000; 206 return length/1000;
258} 207}
259 208
260bool Lib::isSeekable() const { 209bool Lib::isSeekable() const {
261 assertInitialized();
262
263 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 210 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
264} 211}
265 212
266void Lib::seekTo( int time ) { 213void Lib::seekTo( int time ) {
267 assertInitialized();
268
269 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 214 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
270 // since its now milliseconds we need *1000 215 // since its now milliseconds we need *1000
271 xine_play( m_stream, 0, time*1000 ); 216 xine_play( m_stream, 0, time*1000 );
@@ -273,45 +218,30 @@ void Lib::seekTo( int time ) {
273 218
274 219
275Frame Lib::currentFrame() const { 220Frame Lib::currentFrame() const {
276 assertInitialized();
277
278 Frame frame; 221 Frame frame;
279 return frame; 222 return frame;
280}; 223};
281 224
282QString Lib::metaInfo( int number) const { 225QString Lib::metaInfo( int number) const {
283 assertInitialized();
284
285 return xine_get_meta_info( m_stream, number ); 226 return xine_get_meta_info( m_stream, number );
286} 227}
287 228
288int Lib::error() const { 229int Lib::error() const {
289 assertInitialized();
290
291 return xine_get_error( m_stream ); 230 return xine_get_error( m_stream );
292}; 231};
293 232
294void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 233void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
295{ 234{
296 assert( sendType == ThreadUtil::Channel::OneWay ); 235 assert( sendType == ThreadUtil::Channel::OneWay );
297 switch ( msg->type() ) { 236 handleXineEvent( msg->type() );
298 case XineMessageType:
299 handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent );
300 break;
301 case InitializationMessageType:
302 emit initialized();
303 break;
304 }
305 delete msg; 237 delete msg;
306} 238}
307 239
308void Lib::handleXineEvent( const xine_event_t* t ) { 240void Lib::handleXineEvent( const xine_event_t* t ) {
309 send( new XineMessage( t->type ), OneWay ); 241 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
310} 242}
311 243
312void Lib::handleXineEvent( int type ) { 244void Lib::handleXineEvent( int type ) {
313 assertInitialized();
314
315 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 245 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
316 emit stopped(); 246 emit stopped();
317 } 247 }
@@ -319,53 +249,37 @@ void Lib::handleXineEvent( int type ) {
319 249
320 250
321void Lib::setShowVideo( bool video ) { 251void Lib::setShowVideo( bool video ) {
322 assertInitialized();
323
324 m_video = video; 252 m_video = video;
325 ::null_set_show_video( m_videoOutput, video ); 253 ::null_set_show_video( m_videoOutput, video );
326} 254}
327 255
328bool Lib::isShowingVideo() const { 256bool Lib::isShowingVideo() const {
329 assertInitialized();
330
331 return ::null_is_showing_video( m_videoOutput ); 257 return ::null_is_showing_video( m_videoOutput );
332} 258}
333 259
334bool Lib::hasVideo() const { 260bool Lib::hasVideo() const {
335 assertInitialized();
336
337 return xine_get_stream_info( m_stream, 18 ); 261 return xine_get_stream_info( m_stream, 18 );
338} 262}
339 263
340void Lib::showVideoFullScreen( bool fullScreen ) { 264void Lib::showVideoFullScreen( bool fullScreen ) {
341 assertInitialized();
342
343 ::null_set_fullscreen( m_videoOutput, fullScreen ); 265 ::null_set_fullscreen( m_videoOutput, fullScreen );
344} 266}
345 267
346bool Lib::isVideoFullScreen() const { 268bool Lib::isVideoFullScreen() const {
347 assertInitialized();
348
349 return ::null_is_fullscreen( m_videoOutput ); 269 return ::null_is_fullscreen( m_videoOutput );
350} 270}
351 271
352void Lib::setScaling( bool scale ) { 272void Lib::setScaling( bool scale ) {
353 assertInitialized();
354
355 ::null_set_scaling( m_videoOutput, scale ); 273 ::null_set_scaling( m_videoOutput, scale );
356} 274}
357 275
358void Lib::setGamma( int value ) { 276void Lib::setGamma( int value ) {
359 assertInitialized();
360
361 //qDebug( QString( "%1").arg(value) ); 277 //qDebug( QString( "%1").arg(value) );
362 /* int gammaValue = ( 100 + value ); */ 278 /* int gammaValue = ( 100 + value ); */
363 ::null_set_videoGamma( m_videoOutput, value ); 279 ::null_set_videoGamma( m_videoOutput, value );
364} 280}
365 281
366bool Lib::isScaling() const { 282bool Lib::isScaling() const {
367 assertInitialized();
368
369 return ::null_is_scaling( m_videoOutput ); 283 return ::null_is_scaling( m_videoOutput );
370} 284}
371 285
@@ -379,8 +293,6 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame,
379} 293}
380 294
381void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 295void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
382 assertInitialized();
383
384 if ( !m_video ) { 296 if ( !m_video ) {
385 qWarning("not showing video now"); 297 qWarning("not showing video now");
386 return; 298 return;