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.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 1ab5c96..248221b 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -37,24 +37,25 @@
37 37
38/* OPIE */ 38/* OPIE */
39#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40using namespace Opie::Core; 40using namespace Opie::Core;
41 41
42/* QT */ 42/* QT */
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qgfx_qws.h> 45#include <qgfx_qws.h>
46 46
47/* STD */ 47/* STD */
48#include <assert.h> 48#include <assert.h>
49#include <unistd.h>
49 50
50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 51typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
51 int width, int height,int bytes ); 52 int width, int height,int bytes );
52 53
53extern "C" { 54extern "C" {
54 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 55 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
55 int null_is_showing_video( const xine_vo_driver_t* self ); 56 int null_is_showing_video( const xine_vo_driver_t* self );
56 void null_set_show_video( const xine_vo_driver_t* self, int show ); 57 void null_set_show_video( const xine_vo_driver_t* self, int show );
57 int null_is_fullscreen( const xine_vo_driver_t* self ); 58 int null_is_fullscreen( const xine_vo_driver_t* self );
58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 59 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
59 int null_is_scaling( const xine_vo_driver_t* self ); 60 int null_is_scaling( const xine_vo_driver_t* self );
60 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 61 void null_set_scaling( const xine_vo_driver_t* self, int scale );
@@ -99,28 +100,28 @@ Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
99 } 100 }
100 101
101 if ( initMode == InitializeImmediately ) { 102 if ( initMode == InitializeImmediately ) {
102 initialize(); 103 initialize();
103 m_initialized = true; 104 m_initialized = true;
104 } 105 }
105 else 106 else
106 start(); 107 start();
107} 108}
108 109
109void Lib::run() 110void Lib::run()
110{ 111{
111 odebug << "Lib::run() started" << oendl; 112 odebug << "Lib::run() started" << oendl;
112 initialize(); 113 initialize();
113 m_initialized = true; 114 m_initialized = true;
114 odebug << "Lib::run() finished" << oendl; 115 odebug << "Lib::run() finished" << oendl;
115} 116}
116 117
117void Lib::initialize() 118void Lib::initialize()
118{ 119{
119 m_duringInitialization = true; 120 m_duringInitialization = true;
120 m_xine = xine_new( ); 121 m_xine = xine_new( );
121 122
122 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
123 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 124 xine_config_load( m_xine, QFile::encodeName( configPath ) );
124 125
125 xine_init( m_xine ); 126 xine_init( m_xine );
126 127
@@ -137,25 +138,25 @@ void Lib::initialize()
137 138
138 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 139 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
139 140
140 if (m_wid != 0 ) { 141 if (m_wid != 0 ) {
141 printf( "!0\n" ); 142 printf( "!0\n" );
142 setWidget( m_wid ); 143 setWidget( m_wid );
143 } 144 }
144 145
145 m_queue = xine_event_new_queue (m_stream); 146 m_queue = xine_event_new_queue (m_stream);
146 147
147 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 148 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
148 149
149 ::null_preload_decoders( m_stream ); 150 ::null_preload_decoders( m_stream );
150 151
151 m_duringInitialization = false; 152 m_duringInitialization = false;
152} 153}
153 154
154Lib::~Lib() { 155Lib::~Lib() {
155 assert( isRunning() == false ); 156 assert( isRunning() == false );
156 assert( m_initialized ); 157 assert( m_initialized );
157 158
158// free( m_config ); 159// free( m_config );
159 160
160 xine_close( m_stream ); 161 xine_close( m_stream );
161 162
@@ -208,25 +209,25 @@ int Lib::play( const QString& fileName, int startPos, int start_time ) {
208 //m_queue = xine_event_new_queue (m_stream); 209 //m_queue = xine_event_new_queue (m_stream);
209 //xine_event_create_listener_thread (m_queue, xine_event_handler, this); 210 //xine_event_create_listener_thread (m_queue, xine_event_handler, this);
210 211
211 if ( !xine_open( m_stream, str.utf8().data() ) ) { 212 if ( !xine_open( m_stream, str.utf8().data() ) ) {
212 return 0; 213 return 0;
213 } 214 }
214 return xine_play( m_stream, startPos, start_time); 215 return xine_play( m_stream, startPos, start_time);
215} 216}
216 217
217void Lib::stop() { 218void Lib::stop() {
218 assert( m_initialized ); 219 assert( m_initialized );
219 220
220 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; 221 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl;
221 xine_stop( m_stream ); 222 xine_stop( m_stream );
222} 223}
223 224
224void Lib::pause( bool toggle ) { 225void Lib::pause( bool toggle ) {
225 assert( m_initialized ); 226 assert( m_initialized );
226 227
227 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 228 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
228} 229}
229 230
230int Lib::speed() const { 231int Lib::speed() const {
231 assert( m_initialized ); 232 assert( m_initialized );
232 233
@@ -320,27 +321,27 @@ QString Lib::metaInfo( int number) const {
320 321
321int Lib::error() const { 322int Lib::error() const {
322 assert( m_initialized ); 323 assert( m_initialized );
323 324
324 return xine_get_error( m_stream ); 325 return xine_get_error( m_stream );
325}; 326};
326 327
327void Lib::ensureInitialized() 328void Lib::ensureInitialized()
328{ 329{
329 if ( m_initialized ) 330 if ( m_initialized )
330 return; 331 return;
331 332
332 odebug << "waiting for initialization thread to finish" << oendl; 333 odebug << "waiting for initialization thread to finish" << oendl;
333 wait(); 334 wait();
334 odebug << "initialization thread finished!" << oendl; 335 odebug << "initialization thread finished!" << oendl;
335} 336}
336 337
337void Lib::setWidget( XineVideoWidget *widget ) 338void Lib::setWidget( XineVideoWidget *widget )
338{ 339{
339 m_wid = widget; 340 m_wid = widget;
340 resize ( m_wid-> size ( ) ); 341 resize ( m_wid-> size ( ) );
341 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 342 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
342 m_wid->repaint(); 343 m_wid->repaint();
343} 344}
344 345
345void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 346void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
346{ 347{
@@ -415,20 +416,20 @@ void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
415 ( (Lib*)user_data)->handleXineEvent( t ); 416 ( (Lib*)user_data)->handleXineEvent( t );
416} 417}
417 418
418void Lib::xine_display_frame( void* user_data, uint8_t *frame, 419void Lib::xine_display_frame( void* user_data, uint8_t *frame,
419 int width, int height, int bytes ) { 420 int width, int height, int bytes ) {
420 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 421 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
421} 422}
422 423
423void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 424void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
424 assert( m_initialized ); 425 assert( m_initialized );
425 426
426 if ( !m_video ) { 427 if ( !m_video ) {
427 owarn << "not showing video now" << oendl; 428 owarn << "not showing video now" << oendl;
428 return; 429 return;
429 } 430 }
430 431
431 assert( m_wid ); 432 assert( m_wid );
432 433
433 m_wid-> setVideoFrame ( frame, width, height, bytes ); 434 m_wid-> setVideoFrame ( frame, width, height, bytes );
434} 435}