author | simon <simon> | 2002-12-13 22:49:10 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-13 22:49:10 (UTC) |
commit | 789181777295e96d75c68d5136dcfdb4c77b85ca (patch) (unidiff) | |
tree | b3bd3b288068cc75246db7821ca7194b29fc75dc | |
parent | b90d33132c1191fd299e902da9684e51615d1c41 (diff) | |
download | opie-789181777295e96d75c68d5136dcfdb4c77b85ca.zip opie-789181777295e96d75c68d5136dcfdb4c77b85ca.tar.gz opie-789181777295e96d75c68d5136dcfdb4c77b85ca.tar.bz2 |
- assert everything is initialized when accessing xine functionality
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 58 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 1 |
2 files changed, 58 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 6431de7..9d4b1be 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -72,6 +72,7 @@ using namespace XINE; | |||
72 | 72 | ||
73 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 73 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
74 | { | 74 | { |
75 | m_initialized = false; | ||
75 | m_video = false; | 76 | m_video = false; |
76 | m_wid = widget; | 77 | m_wid = widget; |
77 | printf("Lib"); | 78 | printf("Lib"); |
@@ -87,8 +88,10 @@ Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | |||
87 | f.close(); | 88 | f.close(); |
88 | } | 89 | } |
89 | 90 | ||
90 | if ( initMode == InitializeImmediately ) | 91 | if ( initMode == InitializeImmediately ) { |
91 | initialize(); | 92 | initialize(); |
93 | m_initialized = true; | ||
94 | } | ||
92 | else | 95 | else |
93 | assert( false ); | 96 | assert( false ); |
94 | } | 97 | } |
@@ -134,6 +137,9 @@ void Lib::initialize() | |||
134 | } | 137 | } |
135 | 138 | ||
136 | Lib::~Lib() { | 139 | Lib::~Lib() { |
140 | assert( isRunning() == false ) | ||
141 | assert( m_initialized ); | ||
142 | |||
137 | // free( m_config ); | 143 | // free( m_config ); |
138 | 144 | ||
139 | xine_close( m_stream ); | 145 | xine_close( m_stream ); |
@@ -149,6 +155,8 @@ Lib::~Lib() { | |||
149 | } | 155 | } |
150 | 156 | ||
151 | void Lib::resize ( const QSize &s ) { | 157 | void Lib::resize ( const QSize &s ) { |
158 | assert( m_initialized ); | ||
159 | |||
152 | if ( s. width ( ) && s. height ( ) ) { | 160 | if ( s. width ( ) && s. height ( ) ) { |
153 | ::null_set_gui_width( m_videoOutput, s. width() ); | 161 | ::null_set_gui_width( m_videoOutput, s. width() ); |
154 | ::null_set_gui_height( m_videoOutput, s. height() ); | 162 | ::null_set_gui_height( m_videoOutput, s. height() ); |
@@ -174,6 +182,8 @@ int Lib::subVersion() { | |||
174 | } | 182 | } |
175 | 183 | ||
176 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 184 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
185 | assert( m_initialized ); | ||
186 | |||
177 | QString str = fileName.stripWhiteSpace(); | 187 | QString str = fileName.stripWhiteSpace(); |
178 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 188 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { |
179 | return 0; | 189 | return 0; |
@@ -182,49 +192,69 @@ int Lib::play( const QString& fileName, int startPos, int start_time ) { | |||
182 | } | 192 | } |
183 | 193 | ||
184 | void Lib::stop() { | 194 | void Lib::stop() { |
195 | assert( m_initialized ); | ||
196 | |||
185 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 197 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
186 | xine_stop( m_stream ); | 198 | xine_stop( m_stream ); |
187 | } | 199 | } |
188 | 200 | ||
189 | void Lib::pause( bool toggle ) { | 201 | void Lib::pause( bool toggle ) { |
202 | assert( m_initialized ); | ||
203 | |||
190 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 204 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
191 | } | 205 | } |
192 | 206 | ||
193 | int Lib::speed() const { | 207 | int Lib::speed() const { |
208 | assert( m_initialized ); | ||
209 | |||
194 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 210 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
195 | } | 211 | } |
196 | 212 | ||
197 | void Lib::setSpeed( int speed ) { | 213 | void Lib::setSpeed( int speed ) { |
214 | assert( m_initialized ); | ||
215 | |||
198 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 216 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
199 | } | 217 | } |
200 | 218 | ||
201 | int Lib::status() const { | 219 | int Lib::status() const { |
220 | assert( m_initialized ); | ||
221 | |||
202 | return xine_get_status( m_stream ); | 222 | return xine_get_status( m_stream ); |
203 | } | 223 | } |
204 | 224 | ||
205 | int Lib::currentPosition() const { | 225 | int Lib::currentPosition() const { |
226 | assert( m_initialized ); | ||
227 | |||
206 | int pos, time, length; | 228 | int pos, time, length; |
207 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 229 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
208 | return pos; | 230 | return pos; |
209 | } | 231 | } |
210 | 232 | ||
211 | int Lib::currentTime() const { | 233 | int Lib::currentTime() const { |
234 | assert( m_initialized ); | ||
235 | |||
212 | int pos, time, length; | 236 | int pos, time, length; |
213 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 237 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
214 | return time/1000; | 238 | return time/1000; |
215 | } | 239 | } |
216 | 240 | ||
217 | int Lib::length() const { | 241 | int Lib::length() const { |
242 | assert( m_initialized ); | ||
243 | |||
218 | int pos, time, length; | 244 | int pos, time, length; |
219 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 245 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
220 | return length/1000; | 246 | return length/1000; |
221 | } | 247 | } |
222 | 248 | ||
223 | bool Lib::isSeekable() const { | 249 | bool Lib::isSeekable() const { |
250 | assert( m_initialized ); | ||
251 | |||
224 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 252 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
225 | } | 253 | } |
226 | 254 | ||
227 | void Lib::seekTo( int time ) { | 255 | void Lib::seekTo( int time ) { |
256 | assert( m_initialized ); | ||
257 | |||
228 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 258 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
229 | // since its now milliseconds we need *1000 | 259 | // since its now milliseconds we need *1000 |
230 | xine_play( m_stream, 0, time*1000 ); | 260 | xine_play( m_stream, 0, time*1000 ); |
@@ -232,15 +262,21 @@ void Lib::seekTo( int time ) { | |||
232 | 262 | ||
233 | 263 | ||
234 | Frame Lib::currentFrame() const { | 264 | Frame Lib::currentFrame() const { |
265 | assert( m_initialized ); | ||
266 | |||
235 | Frame frame; | 267 | Frame frame; |
236 | return frame; | 268 | return frame; |
237 | }; | 269 | }; |
238 | 270 | ||
239 | QString Lib::metaInfo( int number) const { | 271 | QString Lib::metaInfo( int number) const { |
272 | assert( m_initialized ); | ||
273 | |||
240 | return xine_get_meta_info( m_stream, number ); | 274 | return xine_get_meta_info( m_stream, number ); |
241 | } | 275 | } |
242 | 276 | ||
243 | int Lib::error() const { | 277 | int Lib::error() const { |
278 | assert( m_initialized ); | ||
279 | |||
244 | return xine_get_error( m_stream ); | 280 | return xine_get_error( m_stream ); |
245 | }; | 281 | }; |
246 | 282 | ||
@@ -256,6 +292,8 @@ void Lib::handleXineEvent( const xine_event_t* t ) { | |||
256 | } | 292 | } |
257 | 293 | ||
258 | void Lib::handleXineEvent( int type ) { | 294 | void Lib::handleXineEvent( int type ) { |
295 | assert( m_initialized ); | ||
296 | |||
259 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 297 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
260 | emit stopped(); | 298 | emit stopped(); |
261 | } | 299 | } |
@@ -263,37 +301,53 @@ void Lib::handleXineEvent( int type ) { | |||
263 | 301 | ||
264 | 302 | ||
265 | void Lib::setShowVideo( bool video ) { | 303 | void Lib::setShowVideo( bool video ) { |
304 | assert( m_initialized ); | ||
305 | |||
266 | m_video = video; | 306 | m_video = video; |
267 | ::null_set_show_video( m_videoOutput, video ); | 307 | ::null_set_show_video( m_videoOutput, video ); |
268 | } | 308 | } |
269 | 309 | ||
270 | bool Lib::isShowingVideo() const { | 310 | bool Lib::isShowingVideo() const { |
311 | assert( m_initialized ); | ||
312 | |||
271 | return ::null_is_showing_video( m_videoOutput ); | 313 | return ::null_is_showing_video( m_videoOutput ); |
272 | } | 314 | } |
273 | 315 | ||
274 | bool Lib::hasVideo() const { | 316 | bool Lib::hasVideo() const { |
317 | assert( m_initialized ); | ||
318 | |||
275 | return xine_get_stream_info( m_stream, 18 ); | 319 | return xine_get_stream_info( m_stream, 18 ); |
276 | } | 320 | } |
277 | 321 | ||
278 | void Lib::showVideoFullScreen( bool fullScreen ) { | 322 | void Lib::showVideoFullScreen( bool fullScreen ) { |
323 | assert( m_initialized ); | ||
324 | |||
279 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 325 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
280 | } | 326 | } |
281 | 327 | ||
282 | bool Lib::isVideoFullScreen() const { | 328 | bool Lib::isVideoFullScreen() const { |
329 | assert( m_initialized ); | ||
330 | |||
283 | return ::null_is_fullscreen( m_videoOutput ); | 331 | return ::null_is_fullscreen( m_videoOutput ); |
284 | } | 332 | } |
285 | 333 | ||
286 | void Lib::setScaling( bool scale ) { | 334 | void Lib::setScaling( bool scale ) { |
335 | assert( m_initialized ); | ||
336 | |||
287 | ::null_set_scaling( m_videoOutput, scale ); | 337 | ::null_set_scaling( m_videoOutput, scale ); |
288 | } | 338 | } |
289 | 339 | ||
290 | void Lib::setGamma( int value ) { | 340 | void Lib::setGamma( int value ) { |
341 | assert( m_initialized ); | ||
342 | |||
291 | //qDebug( QString( "%1").arg(value) ); | 343 | //qDebug( QString( "%1").arg(value) ); |
292 | /* int gammaValue = ( 100 + value ); */ | 344 | /* int gammaValue = ( 100 + value ); */ |
293 | ::null_set_videoGamma( m_videoOutput, value ); | 345 | ::null_set_videoGamma( m_videoOutput, value ); |
294 | } | 346 | } |
295 | 347 | ||
296 | bool Lib::isScaling() const { | 348 | bool Lib::isScaling() const { |
349 | assert( m_initialized ); | ||
350 | |||
297 | return ::null_is_scaling( m_videoOutput ); | 351 | return ::null_is_scaling( m_videoOutput ); |
298 | } | 352 | } |
299 | 353 | ||
@@ -307,6 +361,8 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame, | |||
307 | } | 361 | } |
308 | 362 | ||
309 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 363 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
364 | assert( m_initialized ); | ||
365 | |||
310 | if ( !m_video ) { | 366 | if ( !m_video ) { |
311 | qWarning("not showing video now"); | 367 | qWarning("not showing video now"); |
312 | return; | 368 | return; |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 6363918..7e3a912 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -192,6 +192,7 @@ namespace XINE { | |||
192 | void initialize(); | 192 | void initialize(); |
193 | 193 | ||
194 | int m_bytes_per_pixel; | 194 | int m_bytes_per_pixel; |
195 | bool m_initialized:1; | ||
195 | bool m_video:1; | 196 | bool m_video:1; |
196 | XineVideoWidget *m_wid; | 197 | XineVideoWidget *m_wid; |
197 | xine_t *m_xine; | 198 | xine_t *m_xine; |