From: Pierre d'Herbemont Date: Tue, 2 Feb 2010 00:42:00 +0000 (+0100) Subject: macosx/framework: VLCAudio now use a media_player. Cool. X-Git-Tag: 1.1.0-ff~560 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=53d2132c974e12f98ff6863ccae27decebb9120f;p=vlc macosx/framework: VLCAudio now use a media_player. Cool. --- diff --git a/projects/macosx/framework/Headers/Internal/VLCLibVLCBridging.h b/projects/macosx/framework/Headers/Internal/VLCLibVLCBridging.h index 3a815793d3..59efc7757b 100644 --- a/projects/macosx/framework/Headers/Internal/VLCLibVLCBridging.h +++ b/projects/macosx/framework/Headers/Internal/VLCLibVLCBridging.h @@ -147,10 +147,10 @@ extern void __catch_exception( void * e, const char * function, const char * fil @interface VLCAudio (VLCAudioBridging) /* Initializers */ /** - * Initializes a new object using the specified library instance. - * \return Newly created audio object using specified VLCLibrary instance. + * Initializes a new object using the specified mediaPlayer instance. + * \return Newly created audio object using specified VLCMediaPlayer instance. */ -- (id)initWithLibrary:(VLCLibrary *)library; +- (id)initWithMediaPlayer:(VLCMediaPlayer *)mediaPlayer; @end /** diff --git a/projects/macosx/framework/Headers/Public/VLCAudio.h b/projects/macosx/framework/Headers/Public/VLCAudio.h index 270caee5c7..a44bd387a6 100644 --- a/projects/macosx/framework/Headers/Public/VLCAudio.h +++ b/projects/macosx/framework/Headers/Public/VLCAudio.h @@ -28,14 +28,14 @@ */ extern NSString * VLCMediaPlayerVolumeChanged; -@class VLCLibrary; +@class VLCMediaPlayer; /** * TODO: Documentation VLCAudio */ -@interface VLCAudio : NSObject +@interface VLCAudio : NSObject { - VLCLibrary * library; //< Library to control audio for + void *instance; } /* Properties */ diff --git a/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h b/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h index bbe0cbd81a..e3669eac2a 100644 --- a/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h +++ b/projects/macosx/framework/Headers/Public/VLCMediaPlayer.h @@ -86,6 +86,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); 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 + VLCAudio *audio; } /* Initializers */ diff --git a/projects/macosx/framework/Sources/VLCAudio.m b/projects/macosx/framework/Sources/VLCAudio.m index b1483d2f74..1844e7ee3b 100644 --- a/projects/macosx/framework/Sources/VLCAudio.m +++ b/projects/macosx/framework/Sources/VLCAudio.m @@ -35,31 +35,45 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; /* libvlc event callback */ // TODO: Callbacks + @implementation VLCAudio +/** + * Use this method instead of instance directly as this one is type checked. + */ +- (libvlc_media_player_t *)instance +{ + return instance; +} - (id)init { return nil; } -- (id)initWithLibrary:(VLCLibrary *)aLibrary +- (id)initWithMediaPlayer:(VLCMediaPlayer *)mediaPlayer { - if (![library audio] && (self = [super init])) - { - library = aLibrary; - [library setAudio:self]; - } + self = [super init]; + if (!self) + return nil; + instance = [mediaPlayer libVLCMediaPlayer]; + libvlc_media_player_retain([self instance]); return self; } +- (void) dealloc +{ + libvlc_media_player_release([self instance]); + [super dealloc]; +} + - (void)setMute:(BOOL)value { - libvlc_audio_set_mute([library instance], value); + libvlc_audio_set_mute([self instance], value); } - (BOOL)isMuted { - return libvlc_audio_get_mute([library instance]); + return libvlc_audio_get_mute([self instance]); } - (void)setVolume:(NSUInteger)value @@ -68,7 +82,7 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; value = VOLUME_MIN; else if (value > VOLUME_MAX) value = VOLUME_MAX; - libvlc_audio_set_volume([library instance], value); + libvlc_audio_set_volume([self instance], value); } - (void)volumeUp @@ -93,6 +107,6 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; - (NSUInteger)volume { - return libvlc_audio_get_volume([library instance]); + return libvlc_audio_get_volume([self instance]); } @end diff --git a/projects/macosx/framework/Sources/VLCMediaPlayer.m b/projects/macosx/framework/Sources/VLCMediaPlayer.m index 2359600a22..05b641fa8f 100644 --- a/projects/macosx/framework/Sources/VLCMediaPlayer.m +++ b/projects/macosx/framework/Sources/VLCMediaPlayer.m @@ -225,6 +225,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s [cachedTime release]; [cachedRemainingTime release]; [drawable release]; + [audio release]; [super dealloc]; } @@ -262,7 +263,9 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s - (VLCAudio *)audio { - return [[VLCLibrary sharedLibrary] audio]; + if (!audio) + audio = [[VLCAudio alloc] initWithMediaPlayer:self]; + return audio; } #pragma mark -