2008-02-12 22:12:27 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
// AudioController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 8/7/05.
|
|
|
|
// Copyright 2005 Vincent Spader. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "AudioPlayer.h"
|
|
|
|
#import "BufferChain.h"
|
|
|
|
#import "OutputNode.h"
|
|
|
|
#import "Status.h"
|
2008-02-17 18:44:11 +00:00
|
|
|
#import "Helper.h"
|
2007-03-02 01:36:52 +00:00
|
|
|
#import "PluginController.h"
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
#import "Logging.h"
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
@implementation AudioPlayer
|
|
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
output = NULL;
|
2016-05-05 20:05:39 +00:00
|
|
|
bufferChain = nil;
|
2007-03-19 00:19:47 +00:00
|
|
|
outputLaunched = NO;
|
2009-02-28 19:11:22 +00:00
|
|
|
endOfInputReached = NO;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
chainQueue = [[NSMutableArray alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDelegate:(id)d
|
|
|
|
{
|
|
|
|
delegate = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)delegate {
|
|
|
|
return delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)play:(NSURL *)url
|
|
|
|
{
|
2013-10-13 02:16:47 +00:00
|
|
|
[self play:url withUserInfo:nil withRGInfo:nil startPaused:NO];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 09:30:04 +00:00
|
|
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi
|
2013-10-13 02:16:47 +00:00
|
|
|
{
|
|
|
|
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused
|
2007-02-24 20:36:27 +00:00
|
|
|
{
|
|
|
|
output = [[OutputNode alloc] initWithController:self previous:nil];
|
|
|
|
[output setup];
|
2008-02-13 01:50:39 +00:00
|
|
|
[output setVolume: volume];
|
2007-10-13 08:14:05 +00:00
|
|
|
@synchronized(chainQueue) {
|
2013-10-10 08:44:45 +00:00
|
|
|
for (id anObject in chainQueue)
|
2007-10-13 08:14:05 +00:00
|
|
|
{
|
|
|
|
[anObject setShouldContinue:NO];
|
|
|
|
}
|
|
|
|
[chainQueue removeAllObjects];
|
2009-02-28 19:11:22 +00:00
|
|
|
endOfInputReached = NO;
|
2007-10-13 08:14:05 +00:00
|
|
|
if (bufferChain)
|
|
|
|
{
|
|
|
|
[bufferChain setShouldContinue:NO];
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
bufferChain = nil;
|
2007-10-13 08:14:05 +00:00
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
2013-10-12 20:59:34 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
bufferChain = [[BufferChain alloc] initWithController:self];
|
2009-03-05 17:03:30 +00:00
|
|
|
[self notifyStreamChanged:userInfo];
|
|
|
|
|
2013-10-07 20:03:34 +00:00
|
|
|
while (![bufferChain open:url withOutputFormat:[output format] withRGInfo:rgi])
|
2007-02-24 20:36:27 +00:00
|
|
|
{
|
2007-05-22 23:15:07 +00:00
|
|
|
bufferChain = nil;
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[self requestNextStream: userInfo];
|
|
|
|
|
|
|
|
url = nextStream;
|
|
|
|
if (url == nil)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
userInfo = nextStreamUserInfo;
|
2013-10-02 09:30:04 +00:00
|
|
|
rgi = nextStreamRGInfo;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
[self notifyStreamChanged:userInfo];
|
|
|
|
|
|
|
|
bufferChain = [[BufferChain alloc] initWithController:self];
|
|
|
|
}
|
2013-10-12 20:59:34 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[bufferChain setUserInfo:userInfo];
|
|
|
|
|
|
|
|
[self setShouldContinue:YES];
|
|
|
|
|
2007-03-19 00:19:47 +00:00
|
|
|
outputLaunched = NO;
|
2013-10-13 02:16:47 +00:00
|
|
|
startedPaused = paused;
|
|
|
|
initialBufferFilled = NO;
|
2007-07-11 01:20:32 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[bufferChain launchThreads];
|
2013-10-13 02:16:47 +00:00
|
|
|
|
|
|
|
if (paused)
|
|
|
|
[self setPlaybackStatus:kCogStatusPaused waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stop
|
|
|
|
{
|
|
|
|
//Set shouldoContinue to NO on allll things
|
|
|
|
[self setShouldContinue:NO];
|
2008-02-22 03:46:04 +00:00
|
|
|
[self setPlaybackStatus:kCogStatusStopped waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)pause
|
|
|
|
{
|
|
|
|
[output pause];
|
|
|
|
|
2008-02-22 03:46:04 +00:00
|
|
|
[self setPlaybackStatus:kCogStatusPaused waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resume
|
|
|
|
{
|
2013-10-13 02:16:47 +00:00
|
|
|
if (startedPaused)
|
|
|
|
{
|
|
|
|
startedPaused = NO;
|
|
|
|
if (initialBufferFilled)
|
|
|
|
[self launchOutputThread];
|
|
|
|
}
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[output resume];
|
|
|
|
|
2008-02-22 03:46:04 +00:00
|
|
|
[self setPlaybackStatus:kCogStatusPlaying waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)seekToTime:(double)time
|
|
|
|
{
|
|
|
|
//Need to reset everything's buffers, and then seek?
|
|
|
|
/*HACK TO TEST HOW WELL THIS WOULD WORK*/
|
|
|
|
[output seek:time];
|
2007-05-26 22:13:11 +00:00
|
|
|
[bufferChain seek:time];
|
2007-02-24 20:36:27 +00:00
|
|
|
/*END HACK*/
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setVolume:(double)v
|
|
|
|
{
|
2008-02-13 01:50:39 +00:00
|
|
|
volume = v;
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[output setVolume:v];
|
|
|
|
}
|
|
|
|
|
2008-02-13 01:50:39 +00:00
|
|
|
- (double)volume
|
|
|
|
{
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
2008-02-12 22:12:27 +00:00
|
|
|
|
2007-10-11 11:31:36 +00:00
|
|
|
//This is called by the delegate DURING a requestNextStream request.
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)setNextStream:(NSURL *)url
|
|
|
|
{
|
2013-10-02 09:30:04 +00:00
|
|
|
[self setNextStream:url withUserInfo:nil withRGInfo:nil];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 09:30:04 +00:00
|
|
|
- (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi
|
2007-02-24 20:36:27 +00:00
|
|
|
{
|
|
|
|
nextStream = url;
|
|
|
|
|
|
|
|
nextStreamUserInfo = userInfo;
|
2013-10-02 09:30:04 +00:00
|
|
|
|
|
|
|
nextStreamRGInfo = rgi;
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 18:57:21 +00:00
|
|
|
// Called when the playlist changed before we actually started playing a requested stream. We will re-request.
|
|
|
|
- (void)resetNextStreams
|
|
|
|
{
|
|
|
|
@synchronized (chainQueue) {
|
2009-03-01 03:14:52 +00:00
|
|
|
for (id anObject in chainQueue) {
|
|
|
|
[anObject setShouldContinue:NO];
|
|
|
|
}
|
2009-02-28 18:57:21 +00:00
|
|
|
[chainQueue removeAllObjects];
|
2009-03-01 06:02:26 +00:00
|
|
|
|
2009-02-28 19:11:22 +00:00
|
|
|
if (endOfInputReached) {
|
2009-02-28 19:01:49 +00:00
|
|
|
[self endOfInputReached:bufferChain];
|
2009-03-01 06:02:26 +00:00
|
|
|
}
|
2009-02-28 19:01:49 +00:00
|
|
|
}
|
2009-02-28 18:57:21 +00:00
|
|
|
}
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)setShouldContinue:(BOOL)s
|
|
|
|
{
|
2007-10-13 08:25:44 +00:00
|
|
|
if (bufferChain)
|
|
|
|
[bufferChain setShouldContinue:s];
|
|
|
|
|
|
|
|
if (output)
|
|
|
|
[output setShouldContinue:s];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (double)amountPlayed
|
|
|
|
{
|
|
|
|
return [output amountPlayed];
|
|
|
|
}
|
|
|
|
|
2007-03-19 00:19:47 +00:00
|
|
|
- (void)launchOutputThread
|
|
|
|
{
|
2013-10-13 02:16:47 +00:00
|
|
|
initialBufferFilled = YES;
|
|
|
|
if (outputLaunched == NO && startedPaused == NO) {
|
2007-10-13 08:50:40 +00:00
|
|
|
[self setPlaybackStatus:kCogStatusPlaying];
|
2007-03-19 00:19:47 +00:00
|
|
|
[output launchThread];
|
2007-05-26 12:42:00 +00:00
|
|
|
outputLaunched = YES;
|
|
|
|
}
|
2007-03-19 00:19:47 +00:00
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
- (void)requestNextStream:(id)userInfo
|
|
|
|
{
|
2009-03-05 17:03:30 +00:00
|
|
|
[self sendDelegateMethod:@selector(audioPlayer:willEndStream:) withObject:userInfo waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)notifyStreamChanged:(id)userInfo
|
|
|
|
{
|
2013-10-02 09:30:04 +00:00
|
|
|
[self sendDelegateMethod:@selector(audioPlayer:didBeginStream:) withObject:userInfo waitUntilDone:YES];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 02:08:29 +00:00
|
|
|
- (void)addChainToQueue:(BufferChain *)newChain
|
|
|
|
{
|
|
|
|
[newChain setUserInfo: nextStreamUserInfo];
|
|
|
|
|
|
|
|
[newChain setShouldContinue:YES];
|
|
|
|
[newChain launchThreads];
|
|
|
|
|
|
|
|
[chainQueue insertObject:newChain atIndex:[chainQueue count]];
|
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2007-10-11 02:08:29 +00:00
|
|
|
- (BOOL)endOfInputReached:(BufferChain *)sender //Sender is a BufferChain
|
2007-02-24 20:36:27 +00:00
|
|
|
{
|
2007-10-20 03:24:27 +00:00
|
|
|
@synchronized (chainQueue) {
|
2013-10-12 20:52:58 +00:00
|
|
|
// No point in constructing new chain for the next playlist entry
|
|
|
|
// if there's already one at the head of chainQueue... r-r-right?
|
|
|
|
for (BufferChain *chain in chainQueue)
|
|
|
|
{
|
|
|
|
if ([chain isRunning])
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
2016-09-18 03:59:58 +00:00
|
|
|
|
|
|
|
if ([chainQueue count] >= 5)
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
2013-10-12 20:52:58 +00:00
|
|
|
|
2009-02-28 19:11:22 +00:00
|
|
|
BufferChain *newChain = nil;
|
|
|
|
|
|
|
|
nextStreamUserInfo = [sender userInfo];
|
|
|
|
|
2013-10-02 09:30:04 +00:00
|
|
|
nextStreamRGInfo = [sender rgInfo];
|
|
|
|
|
2009-02-28 19:11:22 +00:00
|
|
|
[self requestNextStream: nextStreamUserInfo];
|
2015-02-11 05:42:36 +00:00
|
|
|
|
|
|
|
if (!nextStream)
|
|
|
|
return YES;
|
|
|
|
|
2009-02-28 19:11:22 +00:00
|
|
|
newChain = [[BufferChain alloc] initWithController:self];
|
|
|
|
|
|
|
|
endOfInputReached = YES;
|
|
|
|
|
2007-10-20 03:24:27 +00:00
|
|
|
BufferChain *lastChain = [chainQueue lastObject];
|
|
|
|
if (lastChain == nil) {
|
|
|
|
lastChain = bufferChain;
|
2007-10-11 02:08:29 +00:00
|
|
|
}
|
2007-10-20 03:24:27 +00:00
|
|
|
|
|
|
|
if ([[nextStream scheme] isEqualToString:[[lastChain streamURL] scheme]]
|
|
|
|
&& [[nextStream host] isEqualToString:[[lastChain streamURL] host]]
|
|
|
|
&& [[nextStream path] isEqualToString:[[lastChain streamURL] path]])
|
2007-02-24 20:36:27 +00:00
|
|
|
{
|
2007-10-20 03:24:27 +00:00
|
|
|
if ([lastChain setTrack:nextStream]
|
2013-10-07 20:03:34 +00:00
|
|
|
&& [newChain openWithInput:[lastChain inputNode] withOutputFormat:[output format] withRGInfo:nextStreamRGInfo])
|
2007-10-20 03:24:27 +00:00
|
|
|
{
|
|
|
|
[newChain setStreamURL:nextStream];
|
|
|
|
[newChain setUserInfo:nextStreamUserInfo];
|
|
|
|
|
|
|
|
[self addChainToQueue:newChain];
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"TRACK SET!!! %@", newChain);
|
2007-10-20 03:24:27 +00:00
|
|
|
//Keep on-playin
|
2016-05-05 20:05:39 +00:00
|
|
|
newChain = nil;
|
2007-10-20 03:24:27 +00:00
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
2016-05-05 20:05:39 +00:00
|
|
|
|
|
|
|
lastChain = nil;
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2013-10-07 20:03:34 +00:00
|
|
|
while (![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo])
|
2007-10-20 03:24:27 +00:00
|
|
|
{
|
|
|
|
if (nextStream == nil)
|
|
|
|
{
|
2016-05-05 20:05:39 +00:00
|
|
|
newChain = nil;
|
2007-10-20 03:24:27 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
newChain = nil;
|
2007-10-20 03:24:27 +00:00
|
|
|
[self requestNextStream: nextStreamUserInfo];
|
2007-10-11 02:08:29 +00:00
|
|
|
|
2007-10-20 03:24:27 +00:00
|
|
|
newChain = [[BufferChain alloc] initWithController:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self addChainToQueue:newChain];
|
2016-05-05 20:05:39 +00:00
|
|
|
|
|
|
|
newChain = nil;
|
2013-10-12 20:52:58 +00:00
|
|
|
|
|
|
|
// I'm stupid and can't hold too much stuff in my head all at once, so writing it here.
|
|
|
|
//
|
|
|
|
// Once we get here:
|
|
|
|
// - buffer chain for previous stream finished reading
|
|
|
|
// - there are (probably) some bytes of the previous stream in the output buffer which haven't been played
|
|
|
|
// (by output node) yet
|
|
|
|
// - self.bufferChain == previous playlist entry's buffer chain
|
|
|
|
// - self.nextStream == next playlist entry's URL
|
|
|
|
// - self.nextStreamUserInfo == next playlist entry
|
|
|
|
// - head of chainQueue is the buffer chain for the next entry (which has launched its threads already)
|
2007-10-11 02:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)endOfInputPlayed
|
|
|
|
{
|
2013-10-12 20:52:58 +00:00
|
|
|
// Once we get here:
|
|
|
|
// - the buffer chain for the next playlist entry (started in endOfInputReached) have been working for some time
|
|
|
|
// already, so that there is some decoded and converted data to play
|
|
|
|
// - the buffer chain for the next entry is the first item in chainQueue
|
|
|
|
|
2007-10-20 03:24:27 +00:00
|
|
|
@synchronized(chainQueue) {
|
2009-03-01 06:02:26 +00:00
|
|
|
endOfInputReached = NO;
|
|
|
|
|
2007-10-20 03:24:27 +00:00
|
|
|
if ([chainQueue count] <= 0)
|
|
|
|
{
|
|
|
|
//End of playlist
|
|
|
|
[self stop];
|
|
|
|
|
|
|
|
bufferChain = nil;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
bufferChain = nil;
|
2013-10-12 20:52:58 +00:00
|
|
|
bufferChain = [chainQueue objectAtIndex:0];
|
|
|
|
|
|
|
|
[chainQueue removeObjectAtIndex:0];
|
2013-10-11 12:03:55 +00:00
|
|
|
DLog(@"New!!! %@ %@", bufferChain, [[bufferChain inputNode] decoder]);
|
2007-10-13 08:14:05 +00:00
|
|
|
}
|
2007-10-11 02:08:29 +00:00
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
[self notifyStreamChanged:[bufferChain userInfo]];
|
|
|
|
[output setEndOfStream:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj waitUntilDone:(BOOL)wait
|
|
|
|
{
|
|
|
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:selector]];
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation setTarget:delegate];
|
2007-02-24 20:36:27 +00:00
|
|
|
[invocation setSelector:selector];
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation setArgument:&self atIndex:2];
|
2007-02-24 20:36:27 +00:00
|
|
|
[invocation setArgument:&obj atIndex:3];
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation retainArguments];
|
2009-03-05 17:03:30 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:wait];
|
2009-03-05 17:03:30 +00:00
|
|
|
}
|
2007-02-24 20:36:27 +00:00
|
|
|
|
2009-03-05 17:03:30 +00:00
|
|
|
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj withObject:(id)obj2 waitUntilDone:(BOOL)wait
|
|
|
|
{
|
|
|
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:selector]];
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation setTarget:delegate];
|
|
|
|
[invocation setSelector:selector];
|
|
|
|
[invocation setArgument:&self atIndex:2];
|
2009-03-05 17:03:30 +00:00
|
|
|
[invocation setArgument:&obj atIndex:3];
|
|
|
|
[invocation setArgument:&obj2 atIndex:4];
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation retainArguments];
|
2009-03-05 17:03:30 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
[invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:wait];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-22 03:46:04 +00:00
|
|
|
- (void)setPlaybackStatus:(int)status waitUntilDone:(BOOL)wait
|
|
|
|
{
|
2009-03-05 17:03:30 +00:00
|
|
|
[self sendDelegateMethod:@selector(audioPlayer:didChangeStatus:userInfo:) withObject:[NSNumber numberWithInt:status] withObject:[bufferChain userInfo] waitUntilDone:wait];
|
2008-02-22 03:46:04 +00:00
|
|
|
}
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
- (void)setPlaybackStatus:(int)status
|
|
|
|
{
|
2008-02-22 03:46:04 +00:00
|
|
|
[self setPlaybackStatus:status waitUntilDone:NO];
|
2007-02-24 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BufferChain *)bufferChain
|
|
|
|
{
|
|
|
|
return bufferChain;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (OutputNode *) output
|
|
|
|
{
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2007-10-09 01:20:46 +00:00
|
|
|
+ (NSArray *)containerTypes
|
|
|
|
{
|
|
|
|
return [[[PluginController sharedPluginController] containers] allKeys];
|
|
|
|
}
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
+ (NSArray *)fileTypes
|
|
|
|
{
|
|
|
|
PluginController *pluginController = [PluginController sharedPluginController];
|
|
|
|
|
2007-10-09 01:20:46 +00:00
|
|
|
NSArray *containerTypes = [[pluginController containers] allKeys];
|
2007-10-14 18:12:15 +00:00
|
|
|
NSArray *decoderTypes = [[pluginController decodersByExtension] allKeys];
|
2007-02-24 20:36:27 +00:00
|
|
|
NSArray *metdataReaderTypes = [[pluginController metadataReaders] allKeys];
|
2007-10-14 18:12:15 +00:00
|
|
|
NSArray *propertiesReaderTypes = [[pluginController propertiesReadersByExtension] allKeys];
|
2007-02-24 20:36:27 +00:00
|
|
|
|
|
|
|
NSMutableSet *types = [NSMutableSet set];
|
|
|
|
|
2007-10-09 01:20:46 +00:00
|
|
|
[types addObjectsFromArray:containerTypes];
|
2007-02-24 20:36:27 +00:00
|
|
|
[types addObjectsFromArray:decoderTypes];
|
|
|
|
[types addObjectsFromArray:metdataReaderTypes];
|
|
|
|
[types addObjectsFromArray:propertiesReaderTypes];
|
|
|
|
|
|
|
|
return [types allObjects];
|
|
|
|
}
|
|
|
|
|
2007-03-09 01:16:06 +00:00
|
|
|
+ (NSArray *)schemes
|
|
|
|
{
|
|
|
|
PluginController *pluginController = [PluginController sharedPluginController];
|
|
|
|
|
|
|
|
return [[pluginController sources] allKeys];
|
|
|
|
}
|
|
|
|
|
2008-02-17 18:44:11 +00:00
|
|
|
- (double)volumeUp:(double)amount
|
|
|
|
{
|
|
|
|
double newVolume = linearToLogarithmic(logarithmicToLinear(volume + amount));
|
|
|
|
if (newVolume > MAX_VOLUME)
|
|
|
|
newVolume = MAX_VOLUME;
|
|
|
|
|
|
|
|
[self setVolume:newVolume];
|
|
|
|
|
|
|
|
// the playbackController needs to know the new volume, so it can update the
|
|
|
|
// volumeSlider accordingly.
|
|
|
|
return newVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (double)volumeDown:(double)amount
|
|
|
|
{
|
|
|
|
double newVolume;
|
|
|
|
if (amount > volume)
|
|
|
|
newVolume = 0.0;
|
|
|
|
else
|
|
|
|
newVolume = linearToLogarithmic(logarithmicToLinear(volume - amount));
|
|
|
|
|
|
|
|
[self setVolume:newVolume];
|
|
|
|
return newVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-24 20:36:27 +00:00
|
|
|
@end
|