summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-10 22:27:04 (UTC)
committer simon <simon>2002-12-10 22:27:04 (UTC)
commit0ee7b9eb000d0ca5dfeab074e45488d0bc44314b (patch) (unidiff)
treeb10a90cc3a9eb5566bfa9219634f35954447dd68
parent34418795f4bef0466fc92aa9dfd8f25210bc2bc5 (diff)
downloadopie-0ee7b9eb000d0ca5dfeab074e45488d0bc44314b.zip
opie-0ee7b9eb000d0ca5dfeab074e45488d0bc44314b.tar.gz
opie-0ee7b9eb000d0ca5dfeab074e45488d0bc44314b.tar.bz2
- factor out the expensive xine initialization code into a separate method,
as preparation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp17
-rw-r--r--noncore/multimedia/opieplayer2/lib.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 9e818eb..641cbca 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,166 +1,173 @@
1 /* 1 /*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qdir.h>
41 42
42#include <qgfx_qws.h> 43#include <qgfx_qws.h>
43#include <qdirectpainter_qws.h> 44#include <qdirectpainter_qws.h>
44 45
45#include <assert.h> 46#include <assert.h>
46 47
47#include "xinevideowidget.h" 48#include "xinevideowidget.h"
48#include "frame.h" 49#include "frame.h"
49#include "lib.h" 50#include "lib.h"
50 51
51 52
52typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
53 int width, int height,int bytes ); 54 int width, int height,int bytes );
54 55
55extern "C" { 56extern "C" {
56 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
57 int null_is_showing_video( const xine_vo_driver_t* self ); 58 int null_is_showing_video( const xine_vo_driver_t* self );
58 void null_set_show_video( const xine_vo_driver_t* self, int show ); 59 void null_set_show_video( const xine_vo_driver_t* self, int show );
59 int null_is_fullscreen( const xine_vo_driver_t* self ); 60 int null_is_fullscreen( const xine_vo_driver_t* self );
60 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
61 int null_is_scaling( const xine_vo_driver_t* self ); 62 int null_is_scaling( const xine_vo_driver_t* self );
62 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 63 void null_set_scaling( const xine_vo_driver_t* self, int scale );
63 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 64 void null_set_gui_width( const xine_vo_driver_t* self, int width );
64 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 );
65 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 );
66 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 );
67 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 );
68} 69}
69 70
70using namespace XINE; 71using namespace XINE;
71 72
72Lib::Lib( XineVideoWidget* widget ) { 73Lib::Lib( XineVideoWidget* widget ) {
73 m_video = false; 74 m_video = false;
74 m_wid = widget; 75 m_wid = widget;
75 printf("Lib"); 76 printf("Lib");
76 QCString str( getenv("HOME") ); 77 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
77 str += "/Settings/opiexine.cf";
78 // get the configuration 78 // get the configuration
79 79
80 // not really OO, should be an extra class, later 80 // not really OO, should be an extra class, later
81 if ( !QFile(str).exists() ) { 81 if ( !QFile::exists(configPath) ) {
82 QFile f(str); 82 QFile f(configPath);
83 f.open(IO_WriteOnly); 83 f.open(IO_WriteOnly);
84 QTextStream ts( &f ); 84 QTextStream ts( &f );
85 ts << "misc.memcpy_method:glibc\n"; 85 ts << "misc.memcpy_method:glibc\n";
86 f.close(); 86 f.close();
87 } 87 }
88 88
89 initialize();
90}
91
92void Lib::initialize()
93{
89 m_xine = xine_new( ); 94 m_xine = xine_new( );
90 95
91 xine_config_load( m_xine, str.data() ); 96 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
97 xine_config_load( m_xine, QFile::encodeName( configPath ) );
92 98
93 xine_init( m_xine ); 99 xine_init( m_xine );
94 100
95 // allocate oss for sound 101 // allocate oss for sound
96 // and fb for framebuffer 102 // and fb for framebuffer
97 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 103 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
98 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 104 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
99 105
100 106
101//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 107//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
102 108
103 109
104// null_display_handler( m_videoOutput, xine_display_frame, this ); 110// null_display_handler( m_videoOutput, xine_display_frame, this );
105 111
106 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 112 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
107 113
108 if (m_wid != 0 ) { 114 if (m_wid != 0 ) {
109 printf( "!0\n" ); 115 printf( "!0\n" );
110 resize ( m_wid-> size ( ) ); 116 resize ( m_wid-> size ( ) );
111 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
112 118
113 m_wid->repaint(); 119 m_wid->repaint();
114 } 120 }
115 121
116 m_queue = xine_event_new_queue (m_stream); 122 m_queue = xine_event_new_queue (m_stream);
117 123
118 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 124 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
125
119} 126}
120 127
121Lib::~Lib() { 128Lib::~Lib() {
122// free( m_config ); 129// free( m_config );
123 130
124 xine_close( m_stream ); 131 xine_close( m_stream );
125 132
126 xine_event_dispose_queue( m_queue ); 133 xine_event_dispose_queue( m_queue );
127 134
128 xine_dispose( m_stream ); 135 xine_dispose( m_stream );
129 136
130 xine_exit( m_xine ); 137 xine_exit( m_xine );
131 /* FIXME either free or delete but valgrind bitches against both */ 138 /* FIXME either free or delete but valgrind bitches against both */
132 //free( m_videoOutput ); 139 //free( m_videoOutput );
133 //delete m_audioOutput; 140 //delete m_audioOutput;
134} 141}
135 142
136void Lib::resize ( const QSize &s ) { 143void Lib::resize ( const QSize &s ) {
137 if ( s. width ( ) && s. height ( ) ) { 144 if ( s. width ( ) && s. height ( ) ) {
138 ::null_set_gui_width( m_videoOutput, s. width() ); 145 ::null_set_gui_width( m_videoOutput, s. width() );
139 ::null_set_gui_height( m_videoOutput, s. height() ); 146 ::null_set_gui_height( m_videoOutput, s. height() );
140 } 147 }
141} 148}
142 149
143int Lib::majorVersion() { 150int Lib::majorVersion() {
144 int major, minor, sub; 151 int major, minor, sub;
145 xine_get_version ( &major, &minor, &sub ); 152 xine_get_version ( &major, &minor, &sub );
146 return major; 153 return major;
147} 154}
148 155
149int Lib::minorVersion() { 156int Lib::minorVersion() {
150 int major, minor, sub; 157 int major, minor, sub;
151 xine_get_version ( &major, &minor, &sub ); 158 xine_get_version ( &major, &minor, &sub );
152 return minor; 159 return minor;
153} 160}
154 161
155int Lib::subVersion() { 162int Lib::subVersion() {
156 int major, minor, sub; 163 int major, minor, sub;
157 xine_get_version ( &major, &minor, &sub ); 164 xine_get_version ( &major, &minor, &sub );
158 return sub; 165 return sub;
159} 166}
160 167
161int Lib::play( const QString& fileName, int startPos, int start_time ) { 168int Lib::play( const QString& fileName, int startPos, int start_time ) {
162 QString str = fileName.stripWhiteSpace(); 169 QString str = fileName.stripWhiteSpace();
163 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 170 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
164 return 0; 171 return 0;
165 } 172 }
166 return xine_play( m_stream, startPos, start_time); 173 return xine_play( m_stream, startPos, start_time);
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 37a4f9a..d546c99 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -136,70 +136,72 @@ namespace XINE {
136 * 136 *
137 */ 137 */
138 bool isScaling() const; 138 bool isScaling() const;
139 139
140 /** 140 /**
141 * seek to a position 141 * seek to a position
142 */ 142 */
143 void seekTo( int time ); 143 void seekTo( int time );
144 144
145 /** 145 /**
146 * 146 *
147 * @return is media stream has video 147 * @return is media stream has video
148 */ 148 */
149 bool hasVideo() const; 149 bool hasVideo() const;
150 150
151 /** 151 /**
152 * 152 *
153 */ 153 */
154 void setScaling( bool ); 154 void setScaling( bool );
155 155
156 /** 156 /**
157 * Set the Gamma value for video output 157 * Set the Gamma value for video output
158 * @param int the value between -100 and 100, 0 is original 158 * @param int the value between -100 and 100, 0 is original
159 */ 159 */
160 void setGamma( int ); 160 void setGamma( int );
161 161
162 /** 162 /**
163 * test 163 * test
164 */ 164 */
165 Frame currentFrame() const; 165 Frame currentFrame() const;
166 166
167 /** 167 /**
168 * Returns the error code 168 * Returns the error code
169 * XINE_ERROR_NONE 0 169 * XINE_ERROR_NONE 0
170 * XINE_ERROR_NO_INPUT_PLUGIN 1 170 * XINE_ERROR_NO_INPUT_PLUGIN 1
171 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 171 * XINE_ERROR_NO_DEMUXER_PLUGIN 2
172 * XINE_ERROR_DEMUXER_FAILED 3 172 * XINE_ERROR_DEMUXER_FAILED 3
173 */ 173 */
174 int error() const; 174 int error() const;
175 175
176 signals: 176 signals:
177 177
178 void stopped(); 178 void stopped();
179 179
180 protected: 180 protected:
181 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); 181 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );
182 182
183 private: 183 private:
184 void initialize();
185
184 int m_bytes_per_pixel; 186 int m_bytes_per_pixel;
185 bool m_video:1; 187 bool m_video:1;
186 XineVideoWidget *m_wid; 188 XineVideoWidget *m_wid;
187 xine_t *m_xine; 189 xine_t *m_xine;
188 xine_stream_t *m_stream; 190 xine_stream_t *m_stream;
189 xine_cfg_entry_t *m_config; 191 xine_cfg_entry_t *m_config;
190 xine_vo_driver_t *m_videoOutput; 192 xine_vo_driver_t *m_videoOutput;
191 xine_ao_driver_t* m_audioOutput; 193 xine_ao_driver_t* m_audioOutput;
192 xine_event_queue_t *m_queue; 194 xine_event_queue_t *m_queue;
193 195
194 void handleXineEvent( const xine_event_t* t ); 196 void handleXineEvent( const xine_event_t* t );
195 void handleXineEvent( int type ); 197 void handleXineEvent( int type );
196 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 198 void drawFrame( uint8_t* frame, int width, int height, int bytes );
197 // C -> C++ bridge for the event system 199 // C -> C++ bridge for the event system
198 static void xine_event_handler( void* user_data, const xine_event_t* t); 200 static void xine_event_handler( void* user_data, const xine_event_t* t);
199 static void xine_display_frame( void* user_data, uint8_t* frame , 201 static void xine_display_frame( void* user_data, uint8_t* frame ,
200 int width, int height, int bytes ); 202 int width, int height, int bytes );
201 }; 203 };
202}; 204};
203 205
204 206
205#endif 207#endif