annotate audio/private/pipeout.m @ 61:eff6bddf82e3
tip
Finally implemented perceptual brightness thing.
author |
samer |
date |
Sun, 11 Oct 2015 10:20:42 +0100 |
parents |
fb17caaf9153 |
children |
|
rev |
line source |
samer@43
|
1 % pipeout - start shell command and return stream for writing to its standard input
|
samer@43
|
2 % pipeout ::
|
samer@43
|
3 % text ~'bash shell command',
|
samer@43
|
4 % bool ~'quiet operation flag'
|
samer@43
|
5 % -> java.io.OutputStream ~ 'connected to stdout of command',
|
samer@43
|
6 % (void -> action void) ~'call this to clean up afterwards'.
|
samer@43
|
7 %
|
samer@43
|
8 % If quiet flag is not supplied, it defaults to false.
|
samer@43
|
9 function [str,cleanup]=pipeout(cmd,q)
|
samer@43
|
10 if nargin<2, q=false; end
|
samer@43
|
11 if ~q, fprintf('Starting sub-process: %s\n',cmd); end
|
samer@43
|
12
|
samer@50
|
13 cs=feature('DefaultCharacterSet');
|
samer@43
|
14 process=java.lang.Runtime.getRuntime().exec('bash');
|
samer@43
|
15 writer=java.io.OutputStreamWriter(process.getOutputStream(),cs);
|
samer@43
|
16 writer.write(cmd); writer.close();
|
samer@43
|
17
|
samer@0
|
18 str=process.getOutputStream();
|
samer@0
|
19 cleanup=@dispose;
|
samer@0
|
20
|
samer@0
|
21 function dispose
|
samer@43
|
22 if ~q, fprintf('Killing subprocess...\n'); end
|
samer@0
|
23 process.destroy();
|
samer@0
|
24 end
|
samer@0
|
25 end
|