summaryrefslogtreecommitdiff
path: root/noncore
authorsimon <simon>2002-12-10 23:24:48 (UTC)
committer simon <simon>2002-12-10 23:24:48 (UTC)
commit7f4bd526d59aacbf750e9ee58337b6cf640ba28b (patch) (unidiff)
tree162f849f529cefe24ff5c6f9c0bdceee0cde772c /noncore
parent763b6ad10dbb7a23c446347cb7fb88cfbadd3e27 (diff)
downloadopie-7f4bd526d59aacbf750e9ee58337b6cf640ba28b.zip
opie-7f4bd526d59aacbf750e9ee58337b6cf640ba28b.tar.gz
opie-7f4bd526d59aacbf750e9ee58337b6cf640ba28b.tar.bz2
- added an m_initialized flag and a guard for it, along with an
assertion method called from all methods that access variables depending on initialization (basically all :)
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp67
-rw-r--r--noncore/multimedia/opieplayer2/lib.h5
2 files changed, 71 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 641cbca..99d5de6 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -73,2 +73,3 @@ using namespace XINE;
73Lib::Lib( XineVideoWidget* widget ) { 73Lib::Lib( XineVideoWidget* widget ) {
74 m_initialized = false;
74 m_video = false; 75 m_video = false;
@@ -118,3 +119,3 @@ void Lib::initialize()
118 119
119 m_wid->repaint(); 120// m_wid->repaint();
120 } 121 }
@@ -125,2 +126,3 @@ void Lib::initialize()
125 126
127 m_initialized = true;
126} 128}
@@ -128,2 +130,6 @@ void Lib::initialize()
128Lib::~Lib() { 130Lib::~Lib() {
131 ThreadUtil::AutoLock lock( m_initGuard );
132
133 assert( m_initialized );
134
129// free( m_config ); 135// free( m_config );
@@ -142,2 +148,13 @@ Lib::~Lib() {
142 148
149void Lib::assertInitialized() const
150{
151 ThreadUtil::AutoLock lock( m_initGuard );
152
153 if ( m_initialized )
154 return;
155
156 qDebug( "LibXine: xine function called while not being initialized, yet! Fix the caller!" );
157 assert( m_initialized );
158}
159
143void Lib::resize ( const QSize &s ) { 160void Lib::resize ( const QSize &s ) {
@@ -168,2 +185,4 @@ int Lib::subVersion() {
168int Lib::play( const QString& fileName, int startPos, int start_time ) { 185int Lib::play( const QString& fileName, int startPos, int start_time ) {
186 assertInitialized();
187
169 QString str = fileName.stripWhiteSpace(); 188 QString str = fileName.stripWhiteSpace();
@@ -176,2 +195,4 @@ int Lib::play( const QString& fileName, int startPos, int start_time ) {
176void Lib::stop() { 195void Lib::stop() {
196 assertInitialized();
197
177 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 198 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
@@ -181,2 +202,4 @@ void Lib::stop() {
181void Lib::pause( bool toggle ) { 202void Lib::pause( bool toggle ) {
203 assertInitialized();
204
182 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 205 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
@@ -185,2 +208,4 @@ void Lib::pause( bool toggle ) {
185int Lib::speed() const { 208int Lib::speed() const {
209 assertInitialized();
210
186 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 211 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
@@ -189,2 +214,4 @@ int Lib::speed() const {
189void Lib::setSpeed( int speed ) { 214void Lib::setSpeed( int speed ) {
215 assertInitialized();
216
190 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 217 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
@@ -193,2 +220,4 @@ void Lib::setSpeed( int speed ) {
193int Lib::status() const { 220int Lib::status() const {
221 assertInitialized();
222
194 return xine_get_status( m_stream ); 223 return xine_get_status( m_stream );
@@ -197,2 +226,4 @@ int Lib::status() const {
197int Lib::currentPosition() const { 226int Lib::currentPosition() const {
227 assertInitialized();
228
198 int pos, time, length; 229 int pos, time, length;
@@ -203,2 +234,4 @@ int Lib::currentPosition() const {
203int Lib::currentTime() const { 234int Lib::currentTime() const {
235 assertInitialized();
236
204 int pos, time, length; 237 int pos, time, length;
@@ -209,2 +242,4 @@ int Lib::currentTime() const {
209int Lib::length() const { 242int Lib::length() const {
243 assertInitialized();
244
210 int pos, time, length; 245 int pos, time, length;
@@ -215,2 +250,4 @@ int Lib::length() const {
215bool Lib::isSeekable() const { 250bool Lib::isSeekable() const {
251 assertInitialized();
252
216 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 253 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
@@ -219,2 +256,4 @@ bool Lib::isSeekable() const {
219void Lib::seekTo( int time ) { 256void Lib::seekTo( int time ) {
257 assertInitialized();
258
220 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 259 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
@@ -226,2 +265,4 @@ void Lib::seekTo( int time ) {
226Frame Lib::currentFrame() const { 265Frame Lib::currentFrame() const {
266 assertInitialized();
267
227 Frame frame; 268 Frame frame;
@@ -231,2 +272,4 @@ Frame Lib::currentFrame() const {
231QString Lib::metaInfo( int number) const { 272QString Lib::metaInfo( int number) const {
273 assertInitialized();
274
232 return xine_get_meta_info( m_stream, number ); 275 return xine_get_meta_info( m_stream, number );
@@ -235,2 +278,4 @@ QString Lib::metaInfo( int number) const {
235int Lib::error() const { 278int Lib::error() const {
279 assertInitialized();
280
236 return xine_get_error( m_stream ); 281 return xine_get_error( m_stream );
@@ -250,2 +295,4 @@ void Lib::handleXineEvent( const xine_event_t* t ) {
250void Lib::handleXineEvent( int type ) { 295void Lib::handleXineEvent( int type ) {
296 assertInitialized();
297
251 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 298 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
@@ -257,2 +304,4 @@ void Lib::handleXineEvent( int type ) {
257void Lib::setShowVideo( bool video ) { 304void Lib::setShowVideo( bool video ) {
305 assertInitialized();
306
258 m_video = video; 307 m_video = video;
@@ -262,2 +311,4 @@ void Lib::setShowVideo( bool video ) {
262bool Lib::isShowingVideo() const { 311bool Lib::isShowingVideo() const {
312 assertInitialized();
313
263 return ::null_is_showing_video( m_videoOutput ); 314 return ::null_is_showing_video( m_videoOutput );
@@ -266,2 +317,4 @@ bool Lib::isShowingVideo() const {
266bool Lib::hasVideo() const { 317bool Lib::hasVideo() const {
318 assertInitialized();
319
267 return xine_get_stream_info( m_stream, 18 ); 320 return xine_get_stream_info( m_stream, 18 );
@@ -270,2 +323,4 @@ bool Lib::hasVideo() const {
270void Lib::showVideoFullScreen( bool fullScreen ) { 323void Lib::showVideoFullScreen( bool fullScreen ) {
324 assertInitialized();
325
271 ::null_set_fullscreen( m_videoOutput, fullScreen ); 326 ::null_set_fullscreen( m_videoOutput, fullScreen );
@@ -274,2 +329,4 @@ void Lib::showVideoFullScreen( bool fullScreen ) {
274bool Lib::isVideoFullScreen() const { 329bool Lib::isVideoFullScreen() const {
330 assertInitialized();
331
275 return ::null_is_fullscreen( m_videoOutput ); 332 return ::null_is_fullscreen( m_videoOutput );
@@ -278,2 +335,4 @@ bool Lib::isVideoFullScreen() const {
278void Lib::setScaling( bool scale ) { 335void Lib::setScaling( bool scale ) {
336 assertInitialized();
337
279 ::null_set_scaling( m_videoOutput, scale ); 338 ::null_set_scaling( m_videoOutput, scale );
@@ -282,2 +341,4 @@ void Lib::setScaling( bool scale ) {
282void Lib::setGamma( int value ) { 341void Lib::setGamma( int value ) {
342 assertInitialized();
343
283 //qDebug( QString( "%1").arg(value) ); 344 //qDebug( QString( "%1").arg(value) );
@@ -288,2 +349,4 @@ void Lib::setGamma( int value ) {
288bool Lib::isScaling() const { 349bool Lib::isScaling() const {
350 assertInitialized();
351
289 return ::null_is_scaling( m_videoOutput ); 352 return ::null_is_scaling( m_videoOutput );
@@ -301,2 +364,4 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame,
301void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 364void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
365 assertInitialized();
366
302 if ( !m_video ) { 367 if ( !m_video ) {
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index d546c99..4b8dc81 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -185,2 +185,7 @@ namespace XINE {
185 185
186 void assertInitialized() const;
187
188 mutable ThreadUtil::Mutex m_initGuard;
189 bool m_initialized : 1;
190
186 int m_bytes_per_pixel; 191 int m_bytes_per_pixel;