]> git.sesse.net Git - vlc/blobdiff - projects/macosx/framework/Sources/VLCAudio.m
macosx/framework: VLCAudio now use a media_player. Cool.
[vlc] / projects / macosx / framework / Sources / VLCAudio.m
index b1483d2f7425a64718d66b730f0cfb64fdba568d..1844e7ee3b8d41a3e67a2d582e3fd9e1829a4608 100644 (file)
@@ -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