summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2009-10-27 11:48:36 +0000
committerPhilipp Lohmann <pl@openoffice.org>2009-10-27 11:48:36 +0000
commit812592a71b1aa1449140c0541c935b83fc96d766 (patch)
treed2e3232219cc733d26216d78adcf20ab6659b206 /avmedia
parentef1ec7001a06a6ba0fdbed702bcd7a6fec58eaf9 (diff)
#i106261# avoid duplicate initialization
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/quicktime/player.cxx75
-rw-r--r--avmedia/source/quicktime/player.hxx2
2 files changed, 42 insertions, 35 deletions
diff --git a/avmedia/source/quicktime/player.cxx b/avmedia/source/quicktime/player.cxx
index e8289570b5ae..29332698016e 100644
--- a/avmedia/source/quicktime/player.cxx
+++ b/avmedia/source/quicktime/player.cxx
@@ -100,8 +100,6 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
if ((result == noErr) && (mnVersion >= QT701))
{
// we have version 7.01 or later, initialize
- mpMovie = [QTMovie movie];
- [mpMovie retain];
mbInitialized = true;
}
[pool release];
@@ -111,44 +109,58 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
Player::~Player()
{
- if( mbInitialized )
+ if( mpMovie )
{
- if( mpMovie )
- {
- [mpMovie release];
- mpMovie = nil;
- }
-
+ [mpMovie release];
+ mpMovie = nil;
}
}
+// ------------------------------------------------------------------------------
+QTMovie* Player::getMovie()
+{
+ OSL_ASSERT( mpMovie );
+ return mpMovie;
+}
// ------------------------------------------------------------------------------
bool Player::create( const ::rtl::OUString& rURL )
{
bool bRet = false;
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
-// NSString * aNSStringEscaped = [aNSStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL* aURL = [NSURL URLWithString:aNSStr ];
-
// create the Movie
-
if( mbInitialized )
{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+
+ NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
+ NSURL* aURL = [NSURL URLWithString:aNSStr ];
+
- mpMovie = [mpMovie initWithURL:aURL error:nil];
+ NSError* pErr = nil;
+ mpMovie = [QTMovie movieWithURL:aURL error:&pErr];
if(mpMovie)
{
[mpMovie retain];
maURL = rURL;
bRet = true;
}
+ if( pErr )
+ {
+ OSL_TRACE( "NSMovie create failed with error %ld (%s)",
+ (long)[pErr code],
+ [[pErr localizedDescription] cString]
+ );
+ }
+ [pool release];
}
- [pool release];
-
return bRet;
}
@@ -159,10 +171,10 @@ void SAL_CALL Player::start( )
{
OSL_TRACE ("Player::start");
- if ( mbInitialized && mpMovie )
- {
+ if( mpMovie )
+ {
[mpMovie play];
- }
+ }
}
// ------------------------------------------------------------------------------
@@ -171,11 +183,10 @@ void SAL_CALL Player::stop( )
throw (uno::RuntimeException)
{
OSL_TRACE ("Player::stop");
- if ( mpMovie )
+ if( mpMovie )
{
- [mpMovie stop];
+ [mpMovie stop];
}
-
}
// ------------------------------------------------------------------------------
@@ -185,7 +196,7 @@ sal_Bool SAL_CALL Player::isPlaying()
{
bool bRet = false;
- if ( mbInitialized )
+ if ( mpMovie )
{
if ([mpMovie rate] != 0)
{
@@ -220,10 +231,10 @@ void SAL_CALL Player::setMediaTime( double fTime )
{
OSL_TRACE ("Player::setMediaTime");
- if ( mpMovie )
- {
- [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
- }
+ if ( mpMovie )
+ {
+ [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
+ }
}
// ------------------------------------------------------------------------------
@@ -244,7 +255,6 @@ double SAL_CALL Player::getMediaTime( )
stop();
}
-
return position;
}
@@ -256,7 +266,6 @@ void SAL_CALL Player::setStopTime( double fTime )
OSL_TRACE ("Player::setStopTime %f", fTime);
mnStopTime = fTime;
-
}
// ------------------------------------------------------------------------------
@@ -264,9 +273,7 @@ void SAL_CALL Player::setStopTime( double fTime )
double SAL_CALL Player::getStopTime( )
throw (uno::RuntimeException)
{
- double fRet = 0.0;
-
- fRet = mnStopTime;
+ double fRet = mnStopTime;
return fRet;
}
diff --git a/avmedia/source/quicktime/player.hxx b/avmedia/source/quicktime/player.hxx
index b7cab51005f4..c49ccd62915c 100644
--- a/avmedia/source/quicktime/player.hxx
+++ b/avmedia/source/quicktime/player.hxx
@@ -83,7 +83,7 @@ public:
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
- QTMovie* getMovie() { return mpMovie; }
+ QTMovie* getMovie();
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr;