summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-02-18 07:45:15 +0000
committerritsuka <[email protected]>2015-02-18 07:45:15 +0000
commitbe4ccff70f1cf7432d84dd285a8d8e398c93829a (patch)
tree7df7ce0c4c25673b53afe78890687c0318c5699c
parentda5949d942987af6b9a6fb17bd6573d9cb9a3e7c (diff)
MacGui: move HBOutputRedirect ivar to the .m file.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6922 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--macosx/HBOutputRedirect.h31
-rw-r--r--macosx/HBOutputRedirect.m47
2 files changed, 33 insertions, 45 deletions
diff --git a/macosx/HBOutputRedirect.h b/macosx/HBOutputRedirect.h
index 116463e60..f689b8795 100644
--- a/macosx/HBOutputRedirect.h
+++ b/macosx/HBOutputRedirect.h
@@ -5,7 +5,7 @@
* Interface of class HBOutputRedirect.
*/
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@protocol HBOutputRedirectListening <NSObject>
@@ -27,19 +27,6 @@
* level.
*/
@interface HBOutputRedirect : NSObject
-{
- /// Set that contains all registered listeners for this output.
- NSMutableSet *listeners;
-
- /// Selector that is called on listeners to forward the output.
- SEL forwardingSelector;
-
- /// Output stream (@c stdout or @c stderr) redirected by this object.
- FILE *stream;
-
- /// Pointer to old write function for the stream.
- int (*oldWriteFunc)(void *, const char *, int);
-}
+ (id)stdoutRedirect;
+ (id)stderrRedirect;
@@ -48,19 +35,3 @@
- (void)removeListener:(id <HBOutputRedirectListening>)aListener;
@end
-
-/* Here is another technique to redirect stderr, but it is done at lower level
- which also redirects NSLog() and other writes that are done directly to the
- file descriptor. This method is not used by HBOutputRedirect, but should
- be easy to implement if needed. Code is untested, but this is shows basic
- idea for future reference.
-
- // Create a pipe
- NSPipe *pipe = [[NSPipe alloc] init];
-
- // Connect stderr to the writing end of the pipe
- dup2([[pipe fileHandleForWriting] fileDescriptor], STDERR_FILENO);
-
- // Get reading end of the pipe, we can use this to read stderr
- NSFileHandle *fh = [pipe fileHandleForReading];
-*/
diff --git a/macosx/HBOutputRedirect.m b/macosx/HBOutputRedirect.m
index aa34b27d5..9856e840a 100644
--- a/macosx/HBOutputRedirect.m
+++ b/macosx/HBOutputRedirect.m
@@ -16,6 +16,24 @@ static HBOutputRedirect *g_stderrRedirect = nil;
static int stdoutwrite(void *inFD, const char *buffer, int size);
static int stderrwrite(void *inFD, const char *buffer, int size);
+@interface HBOutputRedirect ()
+{
+ /// Set that contains all registered listeners for this output.
+ NSMutableSet *listeners;
+
+ /// Selector that is called on listeners to forward the output.
+ SEL forwardingSelector;
+
+ /// Output stream (@c stdout or @c stderr) redirected by this object.
+ FILE *stream;
+
+ /// Pointer to old write function for the stream.
+ int (*oldWriteFunc)(void *, const char *, int);
+}
+
+@end
+
+
@interface HBOutputRedirect (Private)
- (id)initWithStream:(FILE *)aStream selector:(SEL)aSelector;
- (void)startRedirect;
@@ -28,25 +46,24 @@ static int stderrwrite(void *inFD, const char *buffer, int size);
*/
int stdoutwrite(void *inFD, const char *buffer, int size)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSData *data = [[NSData alloc] initWithBytes:buffer length:size];
- [g_stdoutRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO];
- [data release];
- [pool release];
- return size;
+ @autoreleasepool
+ {
+ NSData *data = [[NSData alloc] initWithBytes:buffer length:size];
+ [g_stdoutRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO];
+ [data release];
+ }
+ return size;
}
-/**
- * Function that replaces stderr->_write and forwards stderr to g_stderrRedirect.
- */
int stderrwrite(void *inFD, const char *buffer, int size)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSData *data = [[NSData alloc] initWithBytes:buffer length:size];
- [g_stderrRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO];
- [data release];
- [pool release];
- return size;
+ @autoreleasepool
+ {
+ NSData *data = [[NSData alloc] initWithBytes:buffer length:size];
+ [g_stderrRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO];
+ [data release];
+ }
+ return size;
}
@implementation HBOutputRedirect