summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp23
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
@@ -49,103 +49,113 @@
#include "frame.h"
#include "lib.h"
typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
int width, int height,int bytes );
extern "C" {
xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
int null_is_showing_video( const xine_vo_driver_t* self );
void null_set_show_video( const xine_vo_driver_t* self, int show );
int null_is_fullscreen( const xine_vo_driver_t* self );
void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
int null_is_scaling( const xine_vo_driver_t* self );
void null_set_scaling( const xine_vo_driver_t* self, int scale );
void null_set_gui_width( const xine_vo_driver_t* self, int width );
void null_set_gui_height( const xine_vo_driver_t* self, int height );
void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
void null_set_videoGamma( const xine_vo_driver_t* self , int value );
void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
}
using namespace XINE;
-Lib::Lib( XineVideoWidget* widget ) {
+Lib::Lib( XineVideoWidget* widget )
+{
+ ThreadUtil::AutoLock lock( m_initGuard );
m_initialized = false;
m_video = false;
m_wid = widget;
printf("Lib");
QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
// get the configuration
// not really OO, should be an extra class, later
if ( !QFile::exists(configPath) ) {
QFile f(configPath);
f.open(IO_WriteOnly);
QTextStream ts( &f );
ts << "misc.memcpy_method:glibc\n";
f.close();
}
+ start();
+}
+
+void Lib::run()
+{
initialize();
}
void Lib::initialize()
{
m_xine = xine_new( );
QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
xine_config_load( m_xine, QFile::encodeName( configPath ) );
xine_init( m_xine );
// allocate oss for sound
// and fb for framebuffer
m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
// null_display_handler( m_videoOutput, xine_display_frame, this );
m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
if (m_wid != 0 ) {
printf( "!0\n" );
resize ( m_wid-> size ( ) );
::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
// m_wid->repaint();
}
m_queue = xine_event_new_queue (m_stream);
xine_event_create_listener_thread (m_queue, xine_event_handler, this);
+ ThreadUtil::AutoLock lock( m_initGuard );
m_initialized = true;
+
+ send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay );
}
Lib::~Lib() {
ThreadUtil::AutoLock lock( m_initGuard );
assert( m_initialized );
// free( m_config );
xine_close( m_stream );
xine_event_dispose_queue( m_queue );
xine_dispose( m_stream );
xine_exit( m_xine );
/* FIXME either free or delete but valgrind bitches against both */
//free( m_videoOutput );
//delete m_audioOutput;
}
void Lib::assertInitialized() const
{
ThreadUtil::AutoLock lock( m_initGuard );
@@ -263,54 +273,61 @@ void Lib::seekTo( int time ) {
Frame Lib::currentFrame() const {
assertInitialized();
Frame frame;
return frame;
};
QString Lib::metaInfo( int number) const {
assertInitialized();
return xine_get_meta_info( m_stream, number );
}
int Lib::error() const {
assertInitialized();
return xine_get_error( m_stream );
};
void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
{
assert( sendType == ThreadUtil::Channel::OneWay );
- handleXineEvent( msg->type() );
+ switch ( msg->type() ) {
+ case XineMessageType:
+ handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent );
+ break;
+ case InitializationMessageType:
+ emit initialized();
+ break;
+ }
delete msg;
}
void Lib::handleXineEvent( const xine_event_t* t ) {
- send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
+ send( new XineMessage( t->type ), OneWay );
}
void Lib::handleXineEvent( int type ) {
assertInitialized();
if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
emit stopped();
}
}
void Lib::setShowVideo( bool video ) {
assertInitialized();
m_video = video;
::null_set_show_video( m_videoOutput, video );
}
bool Lib::isShowingVideo() const {
assertInitialized();
return ::null_is_showing_video( m_videoOutput );
}