summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-01-31 17:12:11 +0000
committerritsuka <[email protected]>2015-01-31 17:12:11 +0000
commitc81e2df474f6181b19c20423e454c2f1067d12e5 (patch)
treece48f945796827b76de9d261247ca4c2130c32e1
parent32e65ab4d0c0dd32da51322aaa2b170fcf23113d (diff)
MacGui: add a HBAudioTrackDataSource protocol to simplify HBAudio interface.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6844 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--macosx/HBAudio.h11
-rw-r--r--macosx/HBAudio.m15
-rw-r--r--macosx/HBAudioTrack.h11
-rw-r--r--macosx/HBAudioTrack.m14
4 files changed, 30 insertions, 21 deletions
diff --git a/macosx/HBAudio.h b/macosx/HBAudio.h
index 3299c2130..4aceaf632 100644
--- a/macosx/HBAudio.h
+++ b/macosx/HBAudio.h
@@ -11,15 +11,14 @@
@class HBAudioTrack;
@class HBAudioDefaults;
+extern NSString *HBMixdownChangedNotification;
+
@interface HBAudio : NSObject <NSCoding, NSCopying, HBPresetCoding>
- (instancetype)initWithTitle:(HBTitle *)title;
-@property (nonatomic, readonly) NSDictionary *noneTrack;
-@property (nonatomic, readonly) NSArray *masterTrackArray; // the master list of audio tracks from the title
@property (nonatomic, readonly) NSMutableArray *tracks;
-
-@property (nonatomic, readwrite, retain) HBAudioDefaults *defaults;
+@property (nonatomic, readonly) HBAudioDefaults *defaults;
- (void)addAllTracks;
- (void)removeAll;
@@ -29,10 +28,6 @@
- (void)settingTrackToNone:(HBAudioTrack *)newNoneTrack;
- (void)switchingTrackFromNone:(HBAudioTrack *)noLongerNoneTrack;
-/**
- * For internal use
- */
-
- (void)containerChanged:(int)container;
@end
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index df09a85be..226defe9e 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -15,7 +15,12 @@
#include "hb.h"
-@interface HBAudio ()
+NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
+
+@interface HBAudio () <HBAudioTrackDataSource>
+
+@property (nonatomic, readonly) NSDictionary *noneTrack;
+@property (nonatomic, readonly) NSArray *masterTrackArray; // the master list of audio tracks from the title
@property (nonatomic, readwrite) int container; // initially is the default HB_MUX_MP4
@@ -101,7 +106,7 @@
{
BOOL fallenBack = NO;
HBAudioTrack *newAudio = [[HBAudioTrack alloc] init];
- [newAudio setController: self];
+ [newAudio setDataSource:self];
[self insertObject: newAudio inTracksAtIndex: [self countOfTracks]];
[newAudio setVideoContainerTag:@(self.container)];
[newAudio setTrackFromIndex: (int)trackIndex];
@@ -283,7 +288,7 @@
- (void)addNewAudioTrack
{
HBAudioTrack *newAudio = [[HBAudioTrack alloc] init];
- [newAudio setController: self];
+ [newAudio setDataSource:self];
[self insertObject: newAudio inTracksAtIndex: [self countOfTracks]];
[newAudio setVideoContainerTag:@(self.container)];
[newAudio setTrack: self.noneTrack];
@@ -368,7 +373,7 @@
if (idx < _tracks.count)
{
HBAudioTrack *trackCopy = [obj copy];
- trackCopy.controller = copy;
+ trackCopy.dataSource = copy;
[copy->_tracks addObject:[trackCopy autorelease]];
}
}];
@@ -406,7 +411,7 @@
for (HBAudioTrack *track in _tracks)
{
- track.controller = self;
+ track.dataSource = self;
}
decodeObject(_defaults);
diff --git a/macosx/HBAudioTrack.h b/macosx/HBAudioTrack.h
index f7dcc88fe..136f0729c 100644
--- a/macosx/HBAudioTrack.h
+++ b/macosx/HBAudioTrack.h
@@ -7,6 +7,7 @@
#import <Foundation/Foundation.h>
@class HBAudio;
+@protocol HBAudioTrackDataSource;
/**
* Audio track dicts keys.
@@ -39,7 +40,7 @@ extern NSString *keyAudioBitrate;
@property (nonatomic, retain) NSNumber *drc;
@property (nonatomic, retain) NSNumber *gain;
@property (nonatomic, retain) NSNumber *videoContainerTag;
-@property (nonatomic, assign) HBAudio *controller;
+@property (nonatomic, assign) id<HBAudioTrackDataSource> dataSource;
@property (nonatomic, retain) NSMutableArray *codecs;
@property (nonatomic, retain) NSMutableArray *mixdowns;
@@ -54,3 +55,11 @@ extern NSString *keyAudioBitrate;
- (void) setBitRateFromName: (NSString *) aValue;
@end
+
+@protocol HBAudioTrackDataSource <NSObject>
+- (NSDictionary *)noneTrack;
+- (NSArray *)masterTrackArray;
+
+- (void)settingTrackToNone:(HBAudioTrack *)newNoneTrack;
+- (void)switchingTrackFromNone:(HBAudioTrack *)noLongerNoneTrack;
+@end
diff --git a/macosx/HBAudioTrack.m b/macosx/HBAudioTrack.m
index 7b35411b4..047770fe1 100644
--- a/macosx/HBAudioTrack.m
+++ b/macosx/HBAudioTrack.m
@@ -363,13 +363,13 @@ static NSMutableArray *masterBitRateArray = nil;
{
self.sampleRate = self.sampleRates[0]; // default to Auto
}
- if ([self.controller.noneTrack isEqual: oldValue])
+ if ([self.dataSource.noneTrack isEqual: oldValue])
{
- [self.controller switchingTrackFromNone: self];
+ [self.dataSource switchingTrackFromNone: self];
}
- if ([self.controller.noneTrack isEqual: self.track])
+ if ([self.dataSource.noneTrack isEqual: self.track])
{
- [self.controller settingTrackToNone: self];
+ [self.dataSource settingTrackToNone: self];
}
}
[oldValue release];
@@ -388,7 +388,7 @@ static NSMutableArray *masterBitRateArray = nil;
[_mixdown autorelease];
_mixdown = [mixdown retain];
[self updateBitRates: YES];
- [[NSNotificationCenter defaultCenter] postNotificationName: HBMixdownChangedNotification object: self];
+ [[NSNotificationCenter defaultCenter] postNotificationName: HBMixdownChangedNotification object: self.dataSource];
}
- (void)setSampleRate:(NSDictionary *)sampleRate
@@ -404,7 +404,7 @@ static NSMutableArray *masterBitRateArray = nil;
- (void) setTrackFromIndex: (int) aValue
{
- self.track = [self.controller.masterTrackArray dictionaryWithObject: @(aValue)
+ self.track = [self.dataSource.masterTrackArray dictionaryWithObject: @(aValue)
matchingKey: keyAudioTrackIndex];
}
@@ -485,7 +485,7 @@ static NSMutableArray *masterBitRateArray = nil;
- (BOOL) enabled
{
- return (nil != self.track) ? (![self.track isEqual: self.controller.noneTrack]) : NO;
+ return (nil != self.track) ? (![self.track isEqual: self.dataSource.noneTrack]) : NO;
}
- (BOOL) mixdownEnabled