Commit db4a6b82 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework: Fix tabs.

parent 3b44ce0d
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
+ (id)sharedManager; + (id)sharedManager;
- (void)callOnMainThreadDelegateOfObject:(id)aTarget - (void)callOnMainThreadDelegateOfObject:(id)aTarget
withDelegateMethod:(SEL)aSelector withDelegateMethod:(SEL)aSelector
withNotificationName:(NSString *)aNotificationName; withNotificationName:(NSString *)aNotificationName;
- (void)callOnMainThreadObject:(id)aTarget - (void)callOnMainThreadObject:(id)aTarget
withMethod:(SEL)aSelector withMethod:(SEL)aSelector
withArgumentAsObject:(id)arg; withArgumentAsObject:(id)arg;
@end @end
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
// TODO: Documentation // TODO: Documentation
@interface VLCLibrary : NSObject @interface VLCLibrary : NSObject
{ {
void *instance; void *instance;
VLCAudio *audio; VLCAudio *audio;
} }
/* Factories */ /* Factories */
......
...@@ -36,7 +36,7 @@ extern NSString *VLCMediaPlayerVolumeChanged; ...@@ -36,7 +36,7 @@ extern NSString *VLCMediaPlayerVolumeChanged;
// TODO: Documentation // TODO: Documentation
@interface VLCAudio : NSObject @interface VLCAudio : NSObject
{ {
VLCLibrary *library; //< Library to control audio for VLCLibrary *library; //< Library to control audio for
} }
/* Initializers */ /* Initializers */
......
...@@ -30,32 +30,32 @@ ...@@ -30,32 +30,32 @@
/** /**
* Standard dictionary keys for retreiving meta data. * Standard dictionary keys for retreiving meta data.
*/ */
extern NSString *VLCMetaInformationTitle; /* NSString */ extern NSString *VLCMetaInformationTitle; /* NSString */
extern NSString *VLCMetaInformationArtist; /* NSString */ extern NSString *VLCMetaInformationArtist; /* NSString */
extern NSString *VLCMetaInformationTitle; /* NSString */ extern NSString *VLCMetaInformationTitle; /* NSString */
extern NSString *VLCMetaInformationArtist; /* NSString */ extern NSString *VLCMetaInformationArtist; /* NSString */
extern NSString *VLCMetaInformationGenre; /* NSString */ extern NSString *VLCMetaInformationGenre; /* NSString */
extern NSString *VLCMetaInformationCopyright; /* NSString */ extern NSString *VLCMetaInformationCopyright; /* NSString */
extern NSString *VLCMetaInformationAlbum; /* NSString */ extern NSString *VLCMetaInformationAlbum; /* NSString */
extern NSString *VLCMetaInformationTrackNumber; /* NSString */ extern NSString *VLCMetaInformationTrackNumber; /* NSString */
extern NSString *VLCMetaInformationDescription; /* NSString */ extern NSString *VLCMetaInformationDescription; /* NSString */
extern NSString *VLCMetaInformationRating; /* NSString */ extern NSString *VLCMetaInformationRating; /* NSString */
extern NSString *VLCMetaInformationDate; /* NSString */ extern NSString *VLCMetaInformationDate; /* NSString */
extern NSString *VLCMetaInformationSetting; /* NSString */ extern NSString *VLCMetaInformationSetting; /* NSString */
extern NSString *VLCMetaInformationURL; /* NSString */ extern NSString *VLCMetaInformationURL; /* NSString */
extern NSString *VLCMetaInformationLanguage; /* NSString */ extern NSString *VLCMetaInformationLanguage; /* NSString */
extern NSString *VLCMetaInformationNowPlaying; /* NSString */ extern NSString *VLCMetaInformationNowPlaying; /* NSString */
extern NSString *VLCMetaInformationPublisher; /* NSString */ extern NSString *VLCMetaInformationPublisher; /* NSString */
extern NSString *VLCMetaInformationEncodedBy; /* NSString */ extern NSString *VLCMetaInformationEncodedBy; /* NSString */
extern NSString *VLCMetaInformationArtworkURL; /* NSString */ extern NSString *VLCMetaInformationArtworkURL; /* NSString */
extern NSString *VLCMetaInformationArtwork; /* NSImage */ extern NSString *VLCMetaInformationArtwork; /* NSImage */
extern NSString *VLCMetaInformationTrackID; /* NSString */ extern NSString *VLCMetaInformationTrackID; /* NSString */
/* Notification Messages */ /* Notification Messages */
/** /**
* Available notification messages. * Available notification messages.
*/ */
extern NSString *VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed extern NSString *VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed
// Forward declarations, supresses compiler error messages // Forward declarations, supresses compiler error messages
@class VLCMediaList; @class VLCMediaList;
...@@ -103,13 +103,13 @@ extern NSString *VLCMediaMetaChanged; //< Notification message for when the med ...@@ -103,13 +103,13 @@ extern NSString *VLCMediaMetaChanged; //< Notification message for when the med
*/ */
@interface VLCMedia : NSObject @interface VLCMedia : NSObject
{ {
void *p_md; //< Internal media descriptor instance void *p_md; //< Internal media descriptor instance
NSString *url; //< URL for this media resource NSString *url; //< URL for this media resource
VLCMediaList *subitems; //< Sub list of items VLCMediaList *subitems; //< Sub list of items
VLCTime *length; //< Duration of the media VLCTime *length; //< Duration of the media
NSMutableDictionary *metaDictionary; //< Meta data storage NSMutableDictionary *metaDictionary; //< Meta data storage
id delegate; //< Delegate object id delegate; //< Delegate object
BOOL preparsed; //< Value used to determine of the file has been preparsed BOOL preparsed; //< Value used to determine of the file has been preparsed
} }
/* Object Factories */ /* Object Factories */
......
...@@ -42,8 +42,8 @@ extern NSString *VLCMediaListItemDeleted; ...@@ -42,8 +42,8 @@ extern NSString *VLCMediaListItemDeleted;
// TODO: Documentation // TODO: Documentation
@interface VLCMediaList : NSObject @interface VLCMediaList : NSObject
{ {
void *p_mlist; //< Internal instance of media list void *p_mlist; //< Internal instance of media list
id delegate; //< Delegate object id delegate; //< Delegate object
} }
/* Properties */ /* Properties */
...@@ -61,8 +61,8 @@ extern NSString *VLCMediaListItemDeleted; ...@@ -61,8 +61,8 @@ extern NSString *VLCMediaListItemDeleted;
- (int)indexOfMedia:(VLCMedia *)media; - (int)indexOfMedia:(VLCMedia *)media;
- (int)count; - (int)count;
- (NSArray *)sublists; // I don't see why this would be useful - (NSArray *)sublists; // I don't see why this would be useful
//- (VLCMediaList *)flatPlaylist; // nore this one //- (VLCMediaList *)flatPlaylist; // nore this one
//- (VLCMedia *)providerMedia; // I have no clue what this does //- (VLCMedia *)providerMedia; // I have no clue what this does
@end @end
\ No newline at end of file
...@@ -32,13 +32,13 @@ extern NSString *VLCMediaPlayerStateChanged; ...@@ -32,13 +32,13 @@ extern NSString *VLCMediaPlayerStateChanged;
// TODO: Documentation // TODO: Documentation
typedef enum VLCMediaPlayerState typedef enum VLCMediaPlayerState
{ {
VLCMediaPlayerStateStopped, //< Player has stopped VLCMediaPlayerStateStopped, //< Player has stopped
VLCMediaPlayerStateOpening, //< Stream is opening VLCMediaPlayerStateOpening, //< Stream is opening
VLCMediaPlayerStateBuffering, //< Stream is buffering VLCMediaPlayerStateBuffering, //< Stream is buffering
VLCMediaPlayerStateEnded, //< Stream has ended VLCMediaPlayerStateEnded, //< Stream has ended
VLCMediaPlayerStateError, //< Player has generated an error VLCMediaPlayerStateError, //< Player has generated an error
VLCMediaPlayerStatePlaying, //< Stream is playing VLCMediaPlayerStatePlaying, //< Stream is playing
VLCMediaPlayerStatePaused //< Stream is paused VLCMediaPlayerStatePaused //< Stream is paused
} VLCMediaPlayerState; } VLCMediaPlayerState;
extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state); extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state);
...@@ -57,11 +57,11 @@ extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -57,11 +57,11 @@ extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state);
// TODO: Should we use medialist_player or our own flavor of media player? // TODO: Should we use medialist_player or our own flavor of media player?
@interface VLCMediaPlayer : NSObject @interface VLCMediaPlayer : NSObject
{ {
id delegate; //< Object delegate id delegate; //< Object delegate
VLCVideoView *videoView;//< NSView instance where media is rendered to VLCVideoView *videoView;//< NSView instance where media is rendered to
void *instance; // Internal void *instance; // Internal
VLCMedia *media; //< Current media being played VLCMedia *media; //< Current media being played
} }
/* Initializers */ /* Initializers */
...@@ -177,5 +177,5 @@ extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -177,5 +177,5 @@ extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state);
* \see VLCMediaState * \see VLCMediaState
*/ */
- (VLCMediaPlayerState)state; - (VLCMediaPlayerState)state;
@end @end
...@@ -52,12 +52,12 @@ extern NSString *VLCVideoViewLeftFullScreen; ...@@ -52,12 +52,12 @@ extern NSString *VLCVideoViewLeftFullScreen;
@interface VLCVideoView : NSView <VLCOpenGLVoutEmbedding> @interface VLCVideoView : NSView <VLCOpenGLVoutEmbedding>
{ {
id delegate; id delegate;
NSColor *backColor; NSColor *backColor;
BOOL stretchesVideo; BOOL stretchesVideo;
// TODO: Allow for view to report transparency to do some cool effects // TODO: Allow for view to report transparency to do some cool effects
// with the video? // with the video?
} }
- (void)setDelegate:(id)value; - (void)setDelegate:(id)value;
......
This diff is collapsed.
...@@ -35,50 +35,50 @@ NSString *VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; ...@@ -35,50 +35,50 @@ NSString *VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
- (id)init - (id)init
{ {
return nil; return nil;
} }
- (id)initWithLibrary:(VLCLibrary *)aLibrary - (id)initWithLibrary:(VLCLibrary *)aLibrary
{ {
if (![library audio] && (self = [super init])) if (![library audio] && (self = [super init]))
{ {
library = aLibrary; library = aLibrary;
[library setAudio:self]; [library setAudio:self];
} }
return self; return self;
} }
- (void)setMute:(BOOL)value - (void)setMute:(BOOL)value
{ {
libvlc_audio_set_mute([library instance], value, NULL); libvlc_audio_set_mute([library instance], value, NULL);
} }
- (BOOL)isMuted - (BOOL)isMuted
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
BOOL result = libvlc_audio_get_mute([library instance], &ex); BOOL result = libvlc_audio_get_mute([library instance], &ex);
quit_on_exception(&ex); quit_on_exception(&ex);
return result; return result;
} }
- (void)setVolume:(int)value - (void)setVolume:(int)value
{ {
if (value < 0) if (value < 0)
value = 0; value = 0;
else if (value > 200) else if (value > 200)
value = 200; value = 200;
libvlc_audio_set_volume([library instance], value, NULL); libvlc_audio_set_volume([library instance], value, NULL);
} }
- (int)volume - (int)volume
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
int result = libvlc_audio_get_volume([library instance], &ex); int result = libvlc_audio_get_volume([library instance], &ex);
quit_on_exception(&ex); quit_on_exception(&ex);
return result; return result;
} }
@end @end
\ No newline at end of file
...@@ -71,9 +71,9 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -71,9 +71,9 @@ static void * EventDispatcherMainLoop(void * user_data)
/* Wait until we have something on the queue */ /* 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] ); pthread_cond_wait( [self signalData], [self queueLock] );
} }
message = (struct message *)[(NSData *)[[self messageQueue] lastObject] bytes]; message = (struct message *)[(NSData *)[[self messageQueue] lastObject] bytes];
/* Don't send the same notification twice */ /* Don't send the same notification twice */
...@@ -84,7 +84,7 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -84,7 +84,7 @@ static void * EventDispatcherMainLoop(void * user_data)
message_newer = (struct message *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes]; message_newer = (struct message *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes];
if( message_newer->type != VLCNotification ) if( message_newer->type != VLCNotification )
continue; continue;
if( message_newer->target == message->target && message_newer->target == message->target && [message_newer->u.name isEqualToString:message->u.name] ) if( message_newer->target == message->target && message_newer->target == message->target && [message_newer->u.name isEqualToString:message->u.name] )
{ {
[message_newer->target release]; [message_newer->target release];
...@@ -110,7 +110,7 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -110,7 +110,7 @@ static void * EventDispatcherMainLoop(void * user_data)
[pool release]; [pool release];
}; };
return nil; return nil;
} }
@implementation VLCEventManager @implementation VLCEventManager
...@@ -143,7 +143,7 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -143,7 +143,7 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_kill( dispatcherThread, SIGKILL ); pthread_kill( dispatcherThread, SIGKILL );
pthread_join( dispatcherThread, NULL ); pthread_join( dispatcherThread, NULL );
[messageQueue release]; [messageQueue release];
[super dealloc]; [super dealloc];
} }
...@@ -151,14 +151,14 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -151,14 +151,14 @@ static void * EventDispatcherMainLoop(void * user_data)
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
struct message message = struct message message =
{ {
[aTarget retain], [aTarget retain],
aSelector, aSelector,
[aNotificationName retain], [aNotificationName retain],
VLCNotification VLCNotification
}; };
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
pthread_cond_signal( [self signalData] ); pthread_cond_signal( [self signalData] );
...@@ -172,18 +172,18 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -172,18 +172,18 @@ static void * EventDispatcherMainLoop(void * user_data)
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
struct message message = struct message message =
{ {
[aTarget retain], [aTarget retain],
aSelector, aSelector,
[arg retain], [arg retain],
VLCObjectMethodWithObjectArg VLCObjectMethodWithObjectArg
}; };
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
pthread_cond_signal( [self signalData] ); pthread_cond_signal( [self signalData] );
pthread_mutex_unlock( [self queueLock] ); pthread_mutex_unlock( [self queueLock] );
[pool release]; [pool release];
} }
@end @end
......
...@@ -32,110 +32,110 @@ static VLCLibrary *sharedLibrary = nil; ...@@ -32,110 +32,110 @@ static VLCLibrary *sharedLibrary = nil;
// TODO: Change from a terminal error to raising an exception? // TODO: Change from a terminal error to raising an exception?
void __quit_on_exception( void * e, const char * function, const char * file, int line_number ) void __quit_on_exception( void * e, const char * function, const char * file, int line_number )
{ {
libvlc_exception_t *ex = (libvlc_exception_t *)e; libvlc_exception_t *ex = (libvlc_exception_t *)e;
if (libvlc_exception_raised( ex )) if (libvlc_exception_raised( ex ))
{ {
/* XXX: localization */ /* XXX: localization */
NSRunCriticalAlertPanel( @"Error", [NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)", NSRunCriticalAlertPanel( @"Error", [NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)",
libvlc_exception_get_message(ex), file, line_number, function], @"Quit", nil, nil ); libvlc_exception_get_message(ex), file, line_number, function], @"Quit", nil, nil );
exit( ex->i_code ); exit( ex->i_code );
} }
} }
static void *DestroySharedLibraryAtExit() static void *DestroySharedLibraryAtExit()
{ {
// Destroy the shared library // Destroy the shared library
if (sharedLibrary) if (sharedLibrary)
[sharedLibrary release]; [sharedLibrary release];
sharedLibrary = nil; sharedLibrary = nil;
return nil; return nil;
} }
@implementation VLCLibrary @implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary + (VLCLibrary *)sharedLibrary
{ {
if (!sharedLibrary) if (!sharedLibrary)
{ {
// Initialize a shared instance // Initialize a shared instance
[[self alloc] init]; [[self alloc] init];
// Register a function to gracefully destroy the shared library on exit. // Register a function to gracefully destroy the shared library on exit.
atexit((void*)DestroySharedLibraryAtExit); atexit((void*)DestroySharedLibraryAtExit);
} }
return sharedLibrary; return sharedLibrary;
} }
+ (void *)sharedInstance + (void *)sharedInstance
{ {
return [[self sharedLibrary] instance]; return [[self sharedLibrary] instance];
} }
- (id)init - (id)init
{ {
if (self = [super init]) if (self = [super init])
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
// Figure out the frameworks path // Figure out the frameworks path
char *applicationPath = strdup([[NSString stringWithFormat:@"%@/Versions/Current/VLC", char *applicationPath = strdup([[NSString stringWithFormat:@"%@/Versions/Current/VLC",
[[NSBundle bundleForClass:[VLCLibrary class]] bundlePath]] UTF8String]); [[NSBundle bundleForClass:[VLCLibrary class]] bundlePath]] UTF8String]);
// TODO: Raise error if there is no memory available // TODO: Raise error if there is no memory available
char *lib_vlc_params[] = { char *lib_vlc_params[] = {
applicationPath, "-I", "dummy", "-vvvv", applicationPath, "-I", "dummy", "-vvvv",
"--opengl-provider", "minimal_macosx", "--opengl-provider", "minimal_macosx",
"--no-video-title-show", NULL "--no-video-title-show", NULL
}; };
instance = (void *)libvlc_new(7, lib_vlc_params, &ex); instance = (void *)libvlc_new(7, lib_vlc_params, &ex);
quit_on_exception( &ex ); quit_on_exception( &ex );
if (!sharedLibrary) if (!sharedLibrary)
sharedLibrary = [[self retain] autorelease]; sharedLibrary = [[self retain] autorelease];
// Assignment unneeded, as the audio unit will do it for us // Assignment unneeded, as the audio unit will do it for us
/*audio = */ [[VLCAudio alloc] initWithLibrary:self]; /*audio = */ [[VLCAudio alloc] initWithLibrary:self];
// free allocated resources // free allocated resources
free(applicationPath); free(applicationPath);
} }
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
// TODO: libvlc core locks up or has segfaults while shutting down, the // TODO: libvlc core locks up or has segfaults while shutting down, the
// following code allows for the framework to be removed without crashing // following code allows for the framework to be removed without crashing
// the host application. // the host application.
@try @try
{ {
if (instance) if (instance)
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_destroy(instance, &ex); libvlc_destroy(instance, &ex);
} }
} }
@finally @finally
{ {
instance = nil; instance = nil;
[audio release]; [audio release];
[super dealloc]; [super dealloc];
} }
} }
- (void *)instance - (void *)instance
{ {
return instance; return instance;
} }
- (VLCAudio *)audio - (VLCAudio *)audio
{ {
return audio; return audio;
} }
@end @end
...@@ -144,8 +144,8 @@ static void *DestroySharedLibraryAtExit() ...@@ -144,8 +144,8 @@ static void *DestroySharedLibraryAtExit()
- (void)setAudio:(VLCAudio *)value - (void)setAudio:(VLCAudio *)value
{ {
if (!audio) if (!audio)
audio = value; audio = value;
} }
@end @end
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
/* Notification Messages */ /* Notification Messages */
NSString *VLCMediaListItemAdded = @"VLCMediaListItemAdded"; NSString *VLCMediaListItemAdded = @"VLCMediaListItemAdded";
NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted"; NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted";
// TODO: Documentation // TODO: Documentation
@interface VLCMediaList (Private) @interface VLCMediaList (Private)
...@@ -49,26 +49,26 @@ NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted"; ...@@ -49,26 +49,26 @@ NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted";
static void HandleMediaListItemAdded(const libvlc_event_t *event, void *user_data) static void HandleMediaListItemAdded(const libvlc_event_t *event, void *user_data)
{ {
id self = user_data; id self = user_data;
// Check to see if the last item added is this item we're trying to introduce // Check to see if the last item added is this item we're trying to introduce
// If no, then add the item to the local list, otherwise, the item has already // If no, then add the item to the local list, otherwise, the item has already
// been added // been added
[[VLCEventManager sharedManager] callOnMainThreadObject:self [[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemAdded:) withMethod:@selector(mediaListItemAdded:)
withArgumentAsObject:[NSArray arrayWithObjects:[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item], withArgumentAsObject:[NSArray arrayWithObjects:[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item],
[NSNumber numberWithInt:event->u.media_list_item_added.index], nil]]; [NSNumber numberWithInt:event->u.media_list_item_added.index], nil]];
} }
static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data) static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data)
{ {
id self = user_data; id self = user_data;
// Check to see if the last item deleted is this item we're trying delete now. // Check to see if the last item deleted is this item we're trying delete now.
// If no, then delete the item from the local list, otherwise, the item has already // If no, then delete the item from the local list, otherwise, the item has already
// been deleted // been deleted
[[VLCEventManager sharedManager] callOnMainThreadObject:self [[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemRemoved:) withMethod:@selector(mediaListItemRemoved:)
withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]]; withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]];
} }
@implementation VLCMediaList @implementation VLCMediaList
...@@ -77,14 +77,14 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -77,14 +77,14 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
{ {
if (self = [super init]) if (self = [super init])
{ {
// Create a new libvlc media list instance // Create a new libvlc media list instance
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
p_mlist = libvlc_media_list_new([VLCLibrary sharedInstance], &p_e); p_mlist = libvlc_media_list_new([VLCLibrary sharedInstance], &p_e);
quit_on_exception(&p_e); quit_on_exception(&p_e);
// Initialize internals to defaults // Initialize internals to defaults
delegate = nil; delegate = nil;
[self initInternalMediaList]; [self initInternalMediaList];
} }
return self; return self;
...@@ -109,20 +109,20 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -109,20 +109,20 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (void)dealloc - (void)dealloc
{ {
// Release allocated memory // Release allocated memory
libvlc_media_list_release(p_mlist); libvlc_media_list_release(p_mlist);
[super dealloc]; [super dealloc];
} }
- (void)setDelegate:(id)value - (void)setDelegate:(id)value
{ {
delegate = value; delegate = value;
} }
- (id)delegate - (id)delegate
{ {
return delegate; return delegate;
} }
- (void)lock - (void)lock
...@@ -137,16 +137,16 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -137,16 +137,16 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (int)addMedia:(VLCMedia *)media - (int)addMedia:(VLCMedia *)media
{ {
int index = [self count]; int index = [self count];
[self insertMedia:media atIndex:index]; [self insertMedia:media atIndex:index];
return index; return index;
} }
- (void)insertMedia:(VLCMedia *)media atIndex: (int)index - (void)insertMedia:(VLCMedia *)media atIndex: (int)index
{ {
[media retain]; [media retain];
// Add it to the libvlc's medialist // Add it to the libvlc's medialist
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init( &p_e ); libvlc_exception_init( &p_e );
libvlc_media_list_insert_media_descriptor(p_mlist, [media libVLCMediaDescriptor], index, &p_e); libvlc_media_list_insert_media_descriptor(p_mlist, [media libVLCMediaDescriptor], index, &p_e);
...@@ -155,9 +155,9 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -155,9 +155,9 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (void)removeMediaAtIndex:(int)index - (void)removeMediaAtIndex:(int)index
{ {
[[self mediaAtIndex:index] release]; [[self mediaAtIndex:index] release];
// Remove it from the libvlc's medialist // Remove it from the libvlc's medialist
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
libvlc_media_list_remove_index(p_mlist, index, &p_e); libvlc_media_list_remove_index(p_mlist, index, &p_e);
...@@ -166,34 +166,34 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -166,34 +166,34 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (VLCMedia *)mediaAtIndex:(int)index - (VLCMedia *)mediaAtIndex:(int)index
{ {
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
libvlc_media_descriptor_t *p_md = libvlc_media_list_item_at_index(p_mlist, index, &p_e); libvlc_media_descriptor_t *p_md = libvlc_media_list_item_at_index(p_mlist, index, &p_e);
quit_on_exception(&p_e); quit_on_exception(&p_e);
// Returns local object for media descriptor, searchs for user data first. If not found it creates a // Returns local object for media descriptor, searchs for user data first. If not found it creates a
// new cocoa object representation of the media descriptor. // new cocoa object representation of the media descriptor.
return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md]; return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md];
} }
- (int)count - (int)count
{ {
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
int result = libvlc_media_list_count(p_mlist, &p_e); int result = libvlc_media_list_count(p_mlist, &p_e);
quit_on_exception(&p_e); quit_on_exception(&p_e);
return result; return result;
} }
- (int)indexOfMedia:(VLCMedia *)media - (int)indexOfMedia:(VLCMedia *)media
{ {
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
int result = libvlc_media_list_index_of_item(p_mlist, [media libVLCMediaDescriptor], &p_e); int result = libvlc_media_list_index_of_item(p_mlist, [media libVLCMediaDescriptor], &p_e);
quit_on_exception(&p_e); quit_on_exception(&p_e);
return result; return result;
} }
- (NSArray *)sublists - (NSArray *)sublists
...@@ -277,7 +277,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -277,7 +277,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (void)initInternalMediaList - (void)initInternalMediaList
{ {
// Add event callbacks // Add event callbacks
[self lock]; [self lock];
libvlc_exception_t p_e; libvlc_exception_t p_e;
libvlc_exception_init(&p_e); libvlc_exception_init(&p_e);
...@@ -286,40 +286,40 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use ...@@ -286,40 +286,40 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
libvlc_event_attach(p_em, libvlc_MediaListItemAdded, HandleMediaListItemAdded, self, &p_e); libvlc_event_attach(p_em, libvlc_MediaListItemAdded, HandleMediaListItemAdded, self, &p_e);
libvlc_event_attach(p_em, libvlc_MediaListItemDeleted, HandleMediaListItemDeleted, self, &p_e); libvlc_event_attach(p_em, libvlc_MediaListItemDeleted, HandleMediaListItemDeleted, self, &p_e);
[self unlock]; [self unlock];
quit_on_exception( &p_e ); quit_on_exception( &p_e );
} }
- (void)mediaListItemAdded:(NSArray *)args - (void)mediaListItemAdded:(NSArray *)args
{ {
VLCMedia *media = [args objectAtIndex:0]; VLCMedia *media = [args objectAtIndex:0];
NSNumber *index = [args objectAtIndex:1]; NSNumber *index = [args objectAtIndex:1];
// Post the notification // Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemAdded [[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemAdded
object:self object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys: userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
media, @"media", media, @"media",
index, @"index", index, @"index",
nil]]; nil]];
// Let the delegate know that the item was added // Let the delegate know that the item was added
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaAdded:atIndex:)]) if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaAdded:atIndex:)])
[delegate mediaList:self mediaAdded:media atIndex:[index intValue]]; [delegate mediaList:self mediaAdded:media atIndex:[index intValue]];
} }
- (void)mediaListItemRemoved:(NSNumber *)index - (void)mediaListItemRemoved:(NSNumber *)index
{ {
// Post the notification // Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemDeleted [[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemDeleted
object:self object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys: userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
index, @"index", index, @"index",
nil]]; nil]];
// Let the delegate know that the item is being removed // Let the delegate know that the item is being removed
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)]) if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)])
[delegate mediaList:self mediaRemovedAtIndex:index]; [delegate mediaList:self mediaRemovedAtIndex:index];
} }
@end @end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment