Commit 23c70ac8 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: Sync the extension's input to their MediaPlayer's input.

parent 716537eb
...@@ -18,4 +18,5 @@ ...@@ -18,4 +18,5 @@
- (NSString *)name; - (NSString *)name;
- (NSString *)title; - (NSString *)title;
@end @end
...@@ -9,9 +9,12 @@ ...@@ -9,9 +9,12 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class VLCExtension; @class VLCExtension;
@class VLCMediaPlayer;
@interface VLCExtensionsManager : NSObject { @interface VLCExtensionsManager : NSObject {
void *instance; void *instance;
NSMutableArray *_extensions;
VLCMediaPlayer *_player;
} }
+ (VLCExtensionsManager *)sharedManager; + (VLCExtensionsManager *)sharedManager;
- (NSArray *)extensions; - (NSArray *)extensions;
......
...@@ -39,5 +39,4 @@ ...@@ -39,5 +39,4 @@
return [NSString stringWithUTF8String:_instance->psz_title]; return [NSString stringWithUTF8String:_instance->psz_title];
} }
@end @end
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "VLCLibrary.h" #import "VLCLibrary.h"
#import "VLCLibVLCBridging.h" #import "VLCLibVLCBridging.h"
#import <vlc_extensions.h> #import <vlc_extensions.h>
#import <vlc_input.h>
#define _instance ((extensions_manager_t *)instance) #define _instance ((extensions_manager_t *)instance)
...@@ -34,6 +35,9 @@ static VLCExtensionsManager *sharedManager = nil; ...@@ -34,6 +35,9 @@ static VLCExtensionsManager *sharedManager = nil;
module_unneed(_instance, _instance->p_module); module_unneed(_instance, _instance->p_module);
vlc_object_release(_instance); vlc_object_release(_instance);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_extensions release];
[super dealloc]; [super dealloc];
} }
...@@ -56,21 +60,21 @@ static VLCExtensionsManager *sharedManager = nil; ...@@ -56,21 +60,21 @@ static VLCExtensionsManager *sharedManager = nil;
vlc_object_release(libvlc); vlc_object_release(libvlc);
} }
NSMutableArray *array = [NSMutableArray array]; if (_extensions)
return _extensions;
_extensions = [[NSMutableArray alloc] init];
extension_t *ext; extension_t *ext;
FOREACH_ARRAY(ext, _instance->extensions) FOREACH_ARRAY(ext, _instance->extensions)
VLCExtension *extension = [[VLCExtension alloc] initWithInstance:ext]; VLCExtension *extension = [[VLCExtension alloc] initWithInstance:ext];
[array addObject:extension]; [_extensions addObject:extension];
[extension release]; [extension release];
FOREACH_END() FOREACH_END()
return array; return _extensions;
} }
- (void)runExtension:(VLCExtension *)extension - (void)runExtension:(VLCExtension *)extension
{ {
extension_t *ext = [extension instance]; extension_t *ext = [extension instance];
NSLog(@"extension_TriggerOnly = %d", extension_TriggerOnly(_instance, ext));
NSLog(@"extension_IsActivated = %d", extension_IsActivated(_instance, ext));
if(extension_TriggerOnly(_instance, ext)) if(extension_TriggerOnly(_instance, ext))
extension_Trigger(_instance, ext); extension_Trigger(_instance, ext);
...@@ -80,4 +84,30 @@ static VLCExtensionsManager *sharedManager = nil; ...@@ -80,4 +84,30 @@ static VLCExtensionsManager *sharedManager = nil;
extension_Activate(_instance, ext); extension_Activate(_instance, ext);
} }
} }
- (void)mediaPlayerLikelyChangedInput
{
input_thread_t *input = _player ? libvlc_media_player_get_input_thread([_player libVLCMediaPlayer]) : NULL;
for(VLCExtension *extension in _extensions)
extension_SetInput(_instance, [extension instance], input);
if (input)
vlc_object_release(input);
}
- (void)setMediaPlayer:(VLCMediaPlayer *)player
{
if (_player == player)
return;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center removeObserver:self name:VLCMediaPlayerStateChanged object:_player];
[_player release];
_player = [player retain];
[self mediaPlayerLikelyChangedInput];
if (player)
[center addObserver:self selector:@selector(mediaPlayerLikelyChangedInput) name:VLCMediaPlayerStateChanged object:_player];
}
@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