[vlc-devel] commit: macosx/framework: Make sure remainingTime is KVO. (Pierre d' Herbemont )
git version control
git at videolan.org
Wed Dec 23 17:21:02 CET 2009
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Tue Dec 22 20:59:28 2009 +0100| [16350c64e3aeaf4bb10bb897dfd3634de55a0722] | committer: Pierre d'Herbemont
macosx/framework: Make sure remainingTime is KVO.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=16350c64e3aeaf4bb10bb897dfd3634de55a0722
---
.../framework/Headers/Public/VLCMediaPlayer.h | 1 +
projects/macosx/framework/Sources/VLCMediaPlayer.m | 11 +++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h b/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h
index efa8414..ca2af29 100644
--- a/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h
+++ b/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h
@@ -82,6 +82,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
void * instance; // Internal
VLCMedia * media; //< Current media being played
VLCTime * cachedTime; //< Cached time of the media being played
+ VLCTime * cachedRemainingTime; //< Cached remaining time of the media being played
VLCMediaPlayerState cachedState; //< Cached state of the media being played
float position; //< The position of the media being played
id drawable; //< The drawable associated to this media player
diff --git a/projects/macosx/framework/Sources/VLCMediaPlayer.m b/projects/macosx/framework/Sources/VLCMediaPlayer.m
index d94ef56..f48a727 100644
--- a/projects/macosx/framework/Sources/VLCMediaPlayer.m
+++ b/projects/macosx/framework/Sources/VLCMediaPlayer.m
@@ -223,6 +223,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
// Get rid of everything else
[media release];
[cachedTime release];
+ [cachedRemainingTime release];
[drawable release];
[super dealloc];
@@ -462,9 +463,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (VLCTime *)remainingTime
{
- double currentTime = [[cachedTime numberValue] doubleValue];
- double remaining = currentTime / position * (1 - position);
- return [VLCTime timeWithNumber:[NSNumber numberWithDouble:-remaining]];
+ return cachedRemainingTime;
}
- (int)fps
@@ -875,6 +874,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
delegate = nil;
media = nil;
cachedTime = [[VLCTime nullTime] retain];
+ cachedRemainingTime = [[VLCTime nullTime] retain];
position = 0.0f;
cachedState = VLCMediaPlayerStateStopped;
@@ -929,7 +929,10 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
[self willChangeValueForKey:@"remainingTime"];
[cachedTime release];
cachedTime = [[VLCTime timeWithNumber:newTime] retain];
-
+ [cachedRemainingTime release];
+ double currentTime = [[cachedTime numberValue] doubleValue];
+ double remaining = currentTime / position * (1 - position);
+ cachedRemainingTime = [[VLCTime timeWithNumber:[NSNumber numberWithDouble:-remaining]] retain];
[self didChangeValueForKey:@"remainingTime"];
[self didChangeValueForKey:@"time"];
}
More information about the vlc-devel
mailing list