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
commitbddb2ca95b03c27f41d95b5d46ad0c1bcf14a5bc (patch)
tree8742785b0711e68afeb553c62df35e84c439ab15 /avmedia
parent4d9f378e82dd5a49ec7b72df0494007b455fdcf9 (diff)
#i106261# avoid duplicate initialization
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/quicktime/player.cxx81
-rw-r--r--avmedia/source/quicktime/player.hxx2
2 files changed, 45 insertions, 38 deletions
diff --git a/avmedia/source/quicktime/player.cxx b/avmedia/source/quicktime/player.cxx
index a66c77e3f4..aa2d86d340 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,43 +109,57 @@ 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
-
+ // 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)
{
@@ -219,11 +230,11 @@ void SAL_CALL Player::setMediaTime( double fTime )
throw (uno::RuntimeException)
{
OSL_TRACE ("Player::setMediaTime");
-
- if ( mpMovie )
- {
- [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
- }
+
+ if ( mpMovie )
+ {
+ [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
+ }
}
// ------------------------------------------------------------------------------
@@ -243,7 +254,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;
}
@@ -277,7 +284,7 @@ void SAL_CALL Player::setRate( double fRate )
throw (uno::RuntimeException)
{
OSL_TRACE ("Player::setRate");
-
+
// Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
if ( mpMovie )
{
diff --git a/avmedia/source/quicktime/player.hxx b/avmedia/source/quicktime/player.hxx
index 6698381e23..ccc360e5ef 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;