Commit fc8801dd authored by Felix Paul Kühne's avatar Felix Paul Kühne

Sources: unify and modernize coding style

parent fa7f356a
......@@ -70,12 +70,10 @@ static void * EventDispatcherMainLoop(void * user_data)
{
VLCEventManager * self = user_data;
for(;;)
{
for (;;) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
message_t * message, * message_newer = NULL;
NSData * dataMessage;
NSInteger i;
/* Sleep a bit not to flood the interface */
usleep(300);
......@@ -84,12 +82,10 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_mutex_lock([self queueLock]);
/* Wait until we have something on the queue */
while( [[self messageQueue] count] <= 0)
{
while ([[self messageQueue] count] <= 0)
pthread_cond_wait([self signalData], [self queueLock]);
}
//if( [[self messageQueue] count] % 100 == 0 || [[self messageQueue] count] < 100 )
//if ([[self messageQueue] count] % 100 == 0 || [[self messageQueue] count] < 100)
// NSLog(@"[EVENT_MANAGER] On the stack we have %d elements", [[self messageQueue] count]);
/* Get the first object off the queue. */
......@@ -98,34 +94,26 @@ static void * EventDispatcherMainLoop(void * user_data)
message = (message_t *)[dataMessage bytes];
/* Remove duplicate notifications. */
if( message->type == VLCNotification )
{
for( i = [[self messageQueue] count]-1; i >= 0; i-- )
{
if (message->type == VLCNotification) {
for (NSInteger i = [[self messageQueue] count]-1; i >= 0; i-- ) {
message_newer = (message_t *)[(NSData *)[[self messageQueue] objectAtIndex:i] bytes];
if( message_newer->type == VLCNotification &&
if (message_newer->type == VLCNotification &&
message_newer->target == message->target &&
[message_newer->u.name isEqualToString:message->u.name] )
{
[message_newer->u.name isEqualToString:message->u.name]) {
[message_newer->u.name release];
[[self messageQueue] removeObjectAtIndex:i];
}
}
}
else if( message->type == VLCObjectMethodWithArrayArg )
{
} else if (message->type == VLCObjectMethodWithArrayArg) {
NSMutableArray * newArg = nil;
/* Collapse messages that takes array arg by sending one bigger array */
for(i = [[self messageQueue] count] - 1; i >= 0; i--)
{
for (NSInteger i = [[self messageQueue] count] - 1; i >= 0; i--) {
message_newer = (message_t *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes];
if (message_newer->type == VLCObjectMethodWithArrayArg &&
message_newer->target == message->target &&
message_newer->sel == message->sel)
{
if (!newArg)
{
message_newer->sel == message->sel) {
if (!newArg) {
newArg = [NSMutableArray arrayWithArray:message->u.object];
[message->u.object release];
}
......@@ -138,7 +126,7 @@ static void * EventDispatcherMainLoop(void * user_data)
* This could be particulary problematic when the same object receive two related events
* (for instance Added and Removed).
* Ignore for now only if target is the same */
else if( message_newer->target == message->target )
else if (message_newer->target == message->target)
break;
}
......@@ -150,8 +138,7 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_mutex_unlock([self queueLock]);
if( message->type == VLCNotification )
if (message->type == VLCNotification)
[self performSelectorOnMainThread:@selector(callDelegateOfObjectAndSendNotificationWithArgs:)
withObject:dataMessage
waitUntilDone: NO];
......@@ -184,10 +171,8 @@ static void * EventDispatcherMainLoop(void * user_data)
- (id)init
{
if(self = [super init])
{
if(![NSThread isMultiThreaded])
{
if (self = [super init]) {
if (![NSThread isMultiThreaded]) {
[NSThread detachNewThreadSelector:@selector(dummy) toTarget:self withObject:nil];
NSAssert([NSThread isMultiThreaded], @"Can't put Cocoa in multithreaded mode");
}
......@@ -225,15 +210,12 @@ static void * EventDispatcherMainLoop(void * user_data)
VLCNotification
};
if( [NSThread isMainThread] )
{
if ([NSThread isMainThread]) {
NSData *nsd_message = [NSData dataWithBytes:&message length:sizeof(message_t)];
[self addMessageToHandleOnMainThread:nsd_message];
[self callDelegateOfObjectAndSendNotificationWithArgs:[nsd_message retain] /* released in the call */];
[nsd_message autorelease];
}
else
{
} else {
pthread_mutex_lock([self queueLock]);
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(message_t)] atIndex:0];
pthread_cond_signal([self signalData]);
......@@ -273,9 +255,8 @@ static void * EventDispatcherMainLoop(void * user_data)
for (int i = [queue count] - 1; i >= 0; i--) {
NSData *data = [queue objectAtIndex:i];
message_t *message = (message_t *)[data bytes];
if (message->target == target) {
if (message->target == target)
[queue removeObjectAtIndex:i];
}
}
// Remove all pending messages
......@@ -284,10 +265,8 @@ static void * EventDispatcherMainLoop(void * user_data)
NSData *data = [messages objectAtIndex:i];
message_t *message = (message_t *)[data bytes];
if (message->target == target) {
if (message->target == target)
[messages removeObjectAtIndex:i];
}
}
[pendingMessagesLock unlock];
......@@ -322,9 +301,8 @@ static void * EventDispatcherMainLoop(void * user_data)
message_t * message = (message_t *)[data bytes];
// Check that we were not cancelled, ie, target was released
if ([self markMessageHandledOnMainThreadIfExists:data]) {
if ([self markMessageHandledOnMainThreadIfExists:data])
[self callDelegateOfObject:message->target withDelegateMethod:message->sel withNotificationName:message->u.name];
}
[message->u.name release];
[data release];
......
......@@ -41,8 +41,7 @@ static VLCLibrary * sharedLibrary = nil;
@implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary
{
if (!sharedLibrary)
{
if (!sharedLibrary) {
/* Initialize a shared instance */
sharedLibrary = [[self alloc] init];
}
......@@ -51,8 +50,7 @@ static VLCLibrary * sharedLibrary = nil;
- (id)init
{
if (self = [super init])
{
if (self = [super init]) {
NSArray *vlcParams;
#if TARGET_OS_IPHONE
vlcParams = [NSArray arrayWithObjects:@"--play-and-pause", @"--no-color", @"--no-video-title-show", @"--verbose=2", @"--avcodec-fast", @"--avcodec-skiploopfilter=all", @"--vout=vout_ios", @"--aout=audioqueue", nil];
......@@ -103,10 +101,10 @@ static VLCLibrary * sharedLibrary = nil;
- (void)dealloc
{
if( instance )
libvlc_release( instance );
if (instance)
libvlc_release(instance);
if( self == sharedLibrary )
if (self == sharedLibrary)
sharedLibrary = nil;
instance = nil;
......
......@@ -111,9 +111,8 @@ static inline VLCMediaState LibVLCStateToMediaState( libvlc_state_t state )
*/
static void HandleMediaMetaChanged(const libvlc_event_t * event, void * self)
{
if( event->u.media_meta_changed.meta_type == libvlc_meta_Publisher ||
event->u.media_meta_changed.meta_type == libvlc_meta_NowPlaying )
{
if (event->u.media_meta_changed.meta_type == libvlc_meta_Publisher ||
event->u.media_meta_changed.meta_type == libvlc_meta_NowPlaying) {
/* Skip those meta. We don't really care about them for now.
* And they occure a lot */
return;
......@@ -192,8 +191,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (id)initWithURL:(NSURL *)anURL
{
if (self = [super init])
{
if (self = [super init]) {
p_md = libvlc_media_new_location([VLCLibrary sharedInstance],
[[anURL absoluteString] UTF8String]);
......@@ -211,8 +209,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (id)initAsNodeWithName:(NSString *)aName
{
if (self = [super init])
{
if (self = [super init]) {
p_md = libvlc_media_new_as_node([VLCLibrary sharedInstance],
[aName UTF8String]);
......@@ -270,12 +267,10 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (VLCTime *)length
{
if (!length)
{
if (!length) {
// Try figuring out what the length is
long long duration = libvlc_media_get_duration( p_md );
if (duration > -1)
{
if (duration > -1) {
length = [[VLCTime timeWithNumber:[NSNumber numberWithLongLong:duration]] retain];
return [[length retain] autorelease];
}
......@@ -288,16 +283,13 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
{
static const long long thread_sleep = 10000;
if (!length)
{
if (!length) {
// Force parsing of this item.
[self parseIfNeeded];
// wait until we are preparsed
while (!length && !libvlc_media_is_parsed(p_md) && [aDate timeIntervalSinceNow] > 0)
{
usleep( thread_sleep );
}
// So we're done waiting, but sometimes we trap the fact that the parsing
// was done before the length gets assigned, so lets go ahead and assign
......@@ -321,10 +313,8 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (void)addOptions:(NSDictionary*)options
{
if (p_md)
{
for (NSString * key in [options allKeys])
{
if (p_md) {
for (NSString * key in [options allKeys]) {
if ([options objectForKey:key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, [options objectForKey:key]] UTF8String]);
else
......@@ -335,7 +325,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (NSDictionary*) stats
{
if(!p_md)
if (!p_md)
return NULL;
NSMutableDictionary *d = [NSMutableDictionary dictionary];
......@@ -482,9 +472,8 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (id)initWithLibVLCMediaDescriptor:(void *)md
{
if (self = [super init])
{
libvlc_media_retain( md );
if (self = [super init]) {
libvlc_media_retain(md);
p_md = md;
metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
......@@ -501,11 +490,10 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
+ (id)mediaWithMedia:(VLCMedia *)media andLibVLCOptions:(NSDictionary *)options
{
libvlc_media_t * p_md;
p_md = libvlc_media_duplicate( [media libVLCMediaDescriptor] );
p_md = libvlc_media_duplicate([media libVLCMediaDescriptor]);
for( NSString * key in [options allKeys] )
{
if ( [options objectForKey:key] != [NSNull null] )
for (NSString * key in [options allKeys]) {
if ([options objectForKey:key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, [options objectForKey:key]] UTF8String]);
else
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
......@@ -525,8 +513,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
{
static NSDictionary * stringToMetaDictionary = nil;
// TODO: Thread safe-ize
if( !stringToMetaDictionary )
{
if (!stringToMetaDictionary) {
#define VLCStringToMeta( name ) [NSNumber numberWithInt: libvlc_meta_##name], VLCMetaInformation##name
stringToMetaDictionary =
[[NSDictionary dictionaryWithObjectsAndKeys:
......@@ -581,11 +568,11 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
char * p_url = libvlc_media_get_mrl( p_md );
url = [[NSURL URLWithString:[NSString stringWithUTF8String:p_url]] retain];
if( !url ) /* Attempt to interpret as a file path then */
if (!url) /* Attempt to interpret as a file path then */
url = [[NSURL fileURLWithPath:[NSString stringWithUTF8String:p_url]] retain];
free( p_url );
free(p_url);
libvlc_media_set_user_data( p_md, (void*)self );
libvlc_media_set_user_data(p_md, (void*)self);
libvlc_event_manager_t * p_em = libvlc_media_event_manager( p_md );
libvlc_event_attach(p_em, libvlc_MediaMetaChanged, HandleMediaMetaChanged, self);
......@@ -598,8 +585,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
if (!p_mlist)
subitems = nil;
else
{
else {
subitems = [[VLCMediaList mediaListWithLibVLCMediaList:p_mlist] retain];
libvlc_media_list_release( p_mlist );
}
......@@ -615,11 +601,9 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
NSString * oldValue = [metaDictionary valueForKey:metaType];
free(psz_value);
if ( newValue != oldValue && !(oldValue && newValue && [oldValue compare:newValue] == NSOrderedSame) )
{
if (newValue != oldValue && !(oldValue && newValue && [oldValue compare:newValue] == NSOrderedSame)) {
// Only fetch the art if needed. (ie, create the NSImage, if it was requested before)
if (isArtFetched && [metaType isEqualToString:VLCMetaInformationArtworkURL])
{
if (isArtFetched && [metaType isEqualToString:VLCMetaInformationArtworkURL]) {
[NSThread detachNewThreadSelector:@selector(fetchMetaInformationForArtWorkWithURL:)
toTarget:self
withObject:newValue];
......@@ -635,8 +619,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSImage * art = nil;
if( anURL )
{
if (anURL) {
// Go ahead and load up the art work
NSURL * artUrl = [NSURL URLWithString:[anURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
// Don't attempt to fetch artwork from remote. Core will do that alone
......@@ -652,8 +635,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)setArtwork:(NSImage *)art
{
if (!art)
{
if (!art) {
[metaDictionary removeObjectForKey:@"artwork"];
return;
}
......@@ -675,7 +657,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)subItemAdded
{
if( subitems )
if (subitems)
return; /* Nothing to do */
libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md );
......@@ -698,9 +680,8 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
if (!delegate || !isParsed)
return;
if ([delegate respondsToSelector:@selector(mediaDidFinishParsing:)]) {
if ([delegate respondsToSelector:@selector(mediaDidFinishParsing:)])
[delegate mediaDidFinishParsing:self];
}
}
- (void)setStateAsNumber:(NSNumber *)newStateAsNumber
......@@ -718,8 +699,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
[self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
}
if (!isArtURLFetched)
{
if (!isArtURLFetched) {
isArtURLFetched = YES;
/* Force isArtURLFetched, that will trigger artwork download eventually
* And all the other meta will be added through the libvlc event system */
......@@ -732,22 +712,16 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (id)valueForKeyPath:(NSString *)keyPath
{
if( !isArtFetched && [keyPath isEqualToString:@"metaDictionary.artwork"])
{
if (!isArtFetched && [keyPath isEqualToString:@"metaDictionary.artwork"]) {
isArtFetched = YES;
/* Force the retrieval of the artwork now that someone asked for it */
[self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationArtworkURL];
}
else if( !areOthersMetaFetched && [keyPath hasPrefix:@"metaDictionary."])
{
} else if (!areOthersMetaFetched && [keyPath hasPrefix:@"metaDictionary."]) {
areOthersMetaFetched = YES;
/* Force VLCMetaInformationTitle, that will trigger preparsing
* And all the other meta will be added through the libvlc event system */
[self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
}
else if( !isArtURLFetched && [keyPath hasPrefix:@"metaDictionary.artworkURL"])
{
} else if (!isArtURLFetched && [keyPath hasPrefix:@"metaDictionary.artworkURL"]) {
isArtURLFetched = YES;
/* Force isArtURLFetched, that will trigger artwork download eventually
* And all the other meta will be added through the libvlc event system */
......
......@@ -71,8 +71,7 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
@implementation VLCMediaDiscoverer
+ (NSArray *)availableMediaDiscoverer
{
if( !availableMediaDiscoverer )
{
if (!availableMediaDiscoverer) {
availableMediaDiscoverer = [[NSArray arrayWithObjects:
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"upnp"] autorelease],
......@@ -84,8 +83,7 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
- (id)initWithName:(NSString *)aServiceName
{
if (self = [super init])
{
if (self = [super init]) {
localizedName = nil;
discoveredMedia = nil;
mdis = libvlc_media_discoverer_new_from_name([VLCLibrary sharedInstance],
......@@ -115,7 +113,7 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
- (VLCMediaList *) discoveredMedia
{
if( discoveredMedia )
if (discoveredMedia)
return discoveredMedia;
libvlc_media_list_t * p_mlist = libvlc_media_discoverer_media_list( mdis );
......@@ -128,12 +126,11 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
- (NSString *)localizedName
{
if ( localizedName )
if (localizedName)
return localizedName;
char * name = libvlc_media_discoverer_localized_name( mdis );
if (name)
{
if (name) {
localizedName = [[NSString stringWithUTF8String:name] retain];
free( name );
}
......
......@@ -74,8 +74,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
@implementation VLCMediaList
- (id)init
{
if (self = [super init])
{
if (self = [super init]) {
// Create a new libvlc media list instance
p_mlist = libvlc_media_list_new([VLCLibrary sharedInstance]);
......@@ -104,9 +103,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (NSString *)description
{
NSMutableString * content = [NSMutableString string];
int i;
for( i = 0; i < [self count]; i++)
{
for (NSInteger i = 0; i < [self count]; i++) {
[content appendFormat:@"%@\n", [self mediaAtIndex: i]];
}
return [NSString stringWithFormat:@"<%@ %p> {\n%@}", [self class], self, content];
......@@ -199,16 +196,14 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (id)initWithLibVLCMediaList:(void *)p_new_mlist;
{
if( self = [super init] )
{
if (self = [super init]) {
p_mlist = p_new_mlist;
libvlc_media_list_retain( p_mlist );
libvlc_media_list_lock( p_mlist );
cachedMedia = [[NSMutableArray alloc] initWithCapacity:libvlc_media_list_count(p_mlist)];
NSUInteger i, count = libvlc_media_list_count(p_mlist);
for( i = 0; i < count; i++ )
{
NSUInteger count = libvlc_media_list_count(p_mlist);
for (NSUInteger i = 0; i < count; i++) {
libvlc_media_t * p_md = libvlc_media_list_item_at_index(p_mlist, i);
[cachedMedia addObject:[VLCMedia mediaWithLibVLCMediaDescriptor:p_md]];
libvlc_media_release(p_md);
......@@ -242,12 +237,11 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
NSRange range = NSMakeRange(start, end-start);
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"media"];
for( NSDictionary * args in arrayOfArgs )
{
for (NSDictionary * args in arrayOfArgs) {
NSInteger index = [[args objectForKey:@"index"] intValue];
VLCMedia * media = [args objectForKey:@"media"];
/* Sanity check */
if( index && index > [cachedMedia count] )
if (index && index > [cachedMedia count])
index = [cachedMedia count];
[cachedMedia insertObject:media atIndex:index];
}
......
......@@ -100,20 +100,19 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
{
VLCMediaPlayerState newState;
if( event->type == libvlc_MediaPlayerPlaying )
if (event->type == libvlc_MediaPlayerPlaying)
newState = VLCMediaPlayerStatePlaying;
else if( event->type == libvlc_MediaPlayerPaused )
else if (event->type == libvlc_MediaPlayerPaused)
newState = VLCMediaPlayerStatePaused;
else if( event->type == libvlc_MediaPlayerEndReached )
else if (event->type == libvlc_MediaPlayerEndReached)
newState = VLCMediaPlayerStateStopped;
else if( event->type == libvlc_MediaPlayerEncounteredError )
else if (event->type == libvlc_MediaPlayerEncounteredError)
newState = VLCMediaPlayerStateError;
else if( event->type == libvlc_MediaPlayerBuffering )
else if (event->type == libvlc_MediaPlayerBuffering)
newState = VLCMediaPlayerStateBuffering;
else if( event->type == libvlc_MediaPlayerOpening )
else if (event->type == libvlc_MediaPlayerOpening)
newState = VLCMediaPlayerStateOpening;
else
{
else {
NSLog(@"%s: Unknown event", __FUNCTION__);
return;
}
......@@ -164,8 +163,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
static NSDictionary * dict = nil;
NSSet * superKeyPaths;
if( !dict )
{
if (!dict) {
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"state"], @"playing",
[NSSet setWithObjects:@"state", @"media", nil], @"seekable",
......@@ -173,8 +171,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
[NSSet setWithObjects:@"state", @"media", nil], @"description",
nil] retain];
}
if( (superKeyPaths = [super keyPathsForValuesAffectingValueForKey: key]) )
{
if ((superKeyPaths = [super keyPathsForValuesAffectingValueForKey: key])) {
NSMutableSet * ret = [NSMutableSet setWithSet:[dict objectForKey: key]];
[ret unionSet:superKeyPaths];
return ret;
......@@ -296,9 +293,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
libvlc_track_description_t *tracks = libvlc_video_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
NSUInteger i;
for (i = 0; i < count ; i++)
{
for (NSUInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
}
......@@ -369,12 +364,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)setVideoAspectRatio:(char *)value
{
libvlc_video_set_aspect_ratio( instance, value );
libvlc_video_set_aspect_ratio(instance, value);
}
- (char *)videoAspectRatio
{
char * result = libvlc_video_get_aspect_ratio( instance );
char * result = libvlc_video_get_aspect_ratio(instance);
return result;
}
......@@ -485,9 +480,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description(instance, title);
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < count ; i++)
{
for (NSInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String:tracks->psz_name]];
tracks = tracks->p_next;
}
......@@ -522,9 +515,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
libvlc_track_description_t *tracks = libvlc_video_get_title_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < [self countOfTitles] ; i++)
{
for (NSInteger i = 0; i < [self countOfTitles] ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
}
......@@ -557,9 +548,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
libvlc_track_description_t *tracks = libvlc_audio_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
NSUInteger i;
for (i = 0; i < count ; i++)
{
for (NSUInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
}
......@@ -593,8 +582,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)setMedia:(VLCMedia *)value
{
if (media != value)
{
if (media != value) {
if (media && [media compare:value] == NSOrderedSame)
return;
......@@ -621,8 +609,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)pause
{
if( [NSThread isMainThread] )
{
if ([NSThread isMainThread]) {
/* Hack because we create a dead lock here, when the vout is stopped
* and tries to recontact us on the main thread */
/* FIXME: to do this properly we need to do some locking. We may want
......@@ -668,8 +655,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)jumpBackward:(NSInteger)interval
{
if( [self isSeekable] )
{
if ([self isSeekable]) {
interval = interval * 1000;
[self setTime: [VLCTime timeWithInt: ([[self time] intValue] - interval)]];
}
......@@ -677,8 +663,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)jumpForward:(NSInteger)interval
{
if( [self isSeekable] )
{
if ([self isSeekable]) {
interval = interval * 1000;
[self setTime: [VLCTime timeWithInt: ([[self time] intValue] + interval)]];
}
......@@ -786,8 +771,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
@implementation VLCMediaPlayer (Private)
- (id)initWithDrawable:(id)aDrawable
{
if (self = [super init])
{
if (self = [super init]) {
delegate = nil;
media = nil;
cachedTime = [[VLCTime nullTime] retain];
......
......@@ -214,9 +214,7 @@ void display(void *opaque, void *picture)
// Arbitrary choice to work around broken files.
libvlc_media_player_get_length(_mp) > 1000 &&
_numberOfReceivedFrames < 10)
{
return;
}
NSAssert(_data, @"We have no data");
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
......
......@@ -47,8 +47,7 @@
/* Initializers */
- (id)initWithNumber:(NSNumber *)aNumber
{
if (self = [super init])
{
if (self = [super init]) {
if (aNumber)
value = [aNumber copy];
else
......@@ -59,8 +58,7 @@
- (id)initWithInt:(int)aInt
{
if (self = [super init])
{
if (self = [super init]) {
if (aInt)
value = [[NSNumber numberWithInt: aInt] retain];
else
......@@ -94,11 +92,10 @@
- (NSString *)stringValue
{
if (value)
{
if (value) {
long long duration = [value longLongValue] / 1000;
long long positiveDuration = llabs(duration);
if( positiveDuration > 3600 )
if (positiveDuration > 3600)
return [NSString stringWithFormat:@"%s%01ld:%02ld:%02ld",
duration < 0 ? "-" : "",
(long) (positiveDuration / 3600),
......@@ -109,9 +106,7 @@
duration < 0 ? "-" : "",
(long)((positiveDuration / 60) % 60),
(long) (positiveDuration % 60)];
}
else
{
} else {
// Return a string that represents an undefined time.
return @"--:--";
}
......@@ -119,8 +114,7 @@
- (NSString *)verboseStringValue
{
if (value)
{
if (value) {
long long duration = [value longLongValue] / 1000;
long long positiveDuration = llabs(duration);
long hours = positiveDuration / 3600;
......@@ -135,9 +129,7 @@
return [NSString stringWithFormat:@"%ld minutes %ld seconds%s", mins, seconds, remaining];
else
return [NSString stringWithFormat:@"%ld seconds%s", seconds, remaining];