[xiph-commits] r18784 - trunk/postfish
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Thu Jan 24 16:56:47 PST 2013
Author: xiphmont
Date: 2013-01-24 16:56:47 -0800 (Thu, 24 Jan 2013)
New Revision: 18784
Modified:
trunk/postfish/main.c
trunk/postfish/output.c
trunk/postfish/version.h
Log:
Two fixes to batch mode:
Don't write update requests to the UI pipe when there is no UI; it will fill and block. In fact, don't open the UI pipe at all.
Don't install a SIGINT handler for batch mode, since the ^C handling was depending on the gtk mainloop
Modified: trunk/postfish/main.c
===================================================================
--- trunk/postfish/main.c 2013-01-22 10:31:03 UTC (rev 18783)
+++ trunk/postfish/main.c 2013-01-25 00:56:47 UTC (rev 18784)
@@ -48,7 +48,7 @@
#include "config.h"
#include "mainpanel.h"
-int eventpipe[2];
+int eventpipe[2]={-1,-1};
sig_atomic_t main_looping;
char *configfile="postfish-staterc";
char *version;
@@ -70,19 +70,20 @@
"-- monty at xiph.org, Postfish revision %s\n\n",sig,version);
configfile="postfish-staterc-crashsave";
- save_state();
-
- if(main_looping){
- main_looping=0;
- gtk_main_quit();
+ if(!batch){
+ save_state();
+
+ if(main_looping){
+ main_looping=0;
+ gtk_main_quit();
+ }
+ ao_shutdown();
}
- ao_shutdown();
exit(0);
-
}
/* otherwise inform the UI thread that we've requested shutdown */
- write(eventpipe[1],"\001",1);
+ if(eventpipe[1]!=-1) write(eventpipe[1],"\001",1);
}
@@ -364,7 +365,7 @@
/* easiest way to inform gtk of changes and not deal with locking
issues around the UI */
- if(pipe(eventpipe)){
+ if(!batch && pipe(eventpipe)){
fprintf(stderr,"Unable to open event pipe:\n"
" %s\n",strerror(errno));
ao_shutdown();
@@ -375,7 +376,8 @@
main_looping=0;
- signal(SIGINT,clean_exit);
+ if(!batch)
+ signal(SIGINT,clean_exit);
signal(SIGSEGV,clean_exit);
if(batch){
Modified: trunk/postfish/output.c
===================================================================
--- trunk/postfish/output.c 2013-01-22 10:31:03 UTC (rev 18783)
+++ trunk/postfish/output.c 2013-01-25 00:56:47 UTC (rev 18784)
@@ -67,13 +67,15 @@
}
void pipeline_reset(){
- int flags=fcntl(eventpipe[0],F_GETFL);
- char buf[1];
- /* drain the event pipe */
- if(fcntl(eventpipe[0],F_SETFL,O_NONBLOCK))
- fprintf(stderr,"Unable to set O_NONBLOCK on event pipe.\n");
- while(read(eventpipe[0],buf,1)>0);
- fcntl(eventpipe[0],F_SETFL,flags);
+ if(eventpipe[0]>-1){
+ int flags=fcntl(eventpipe[0],F_GETFL);
+ char buf[1];
+ /* drain the event pipe */
+ if(fcntl(eventpipe[0],F_SETFL,O_NONBLOCK))
+ fprintf(stderr,"Unable to set O_NONBLOCK on event pipe.\n");
+ while(read(eventpipe[0],buf,1)>0);
+ fcntl(eventpipe[0],F_SETFL,flags);
+ }
input_reset(); /* clear any persistent lapping state */
declip_reset(); /* clear any persistent lapping state */
@@ -1070,26 +1072,28 @@
}
/* feedback */
- memset(rms,0,sizeof(*rms)*OUTPUT_CHANNELS);
- memset(peak,0,sizeof(*peak)*OUTPUT_CHANNELS);
-
- for(j=0;j<OUTPUT_CHANNELS;j++){
- if(!mute_channel_muted(link->active,j))
- for(i=0;i<link->samples;i++){
- float dval=link->data[j][i];
- dval*=dval;
- if(dval>peak[j])peak[j]=dval;
- rms[j]+= dval;
- }
- }
+ if(eventpipe[1]>-1){
+ memset(rms,0,sizeof(*rms)*OUTPUT_CHANNELS);
+ memset(peak,0,sizeof(*peak)*OUTPUT_CHANNELS);
- for(j=0;j<OUTPUT_CHANNELS;j++)
- rms[j]/=link->samples;
+ for(j=0;j<OUTPUT_CHANNELS;j++){
+ if(!mute_channel_muted(link->active,j))
+ for(i=0;i<link->samples;i++){
+ float dval=link->data[j][i];
+ dval*=dval;
+ if(dval>peak[j])peak[j]=dval;
+ rms[j]+= dval;
+ }
+ }
- /* inform Lord Vader his shuttle is ready */
- push_output_feedback(peak,rms);
-
- write(eventpipe[1],"",1);
+ for(j=0;j<OUTPUT_CHANNELS;j++)
+ rms[j]/=link->samples;
+
+ /* inform Lord Vader his shuttle is ready */
+ push_output_feedback(peak,rms);
+
+ write(eventpipe[1],"",1);
+ }
}
}
@@ -1113,7 +1117,7 @@
playback_exit=0;
if(audiobuf)free(audiobuf);
- write(eventpipe[1],"",1);
+ if(eventpipe[i]>-1) write(eventpipe[1],"",1);
return(NULL);
}
Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h 2013-01-22 10:31:03 UTC (rev 18783)
+++ trunk/postfish/version.h 2013-01-25 00:56:47 UTC (rev 18784)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Tue Jan 22 05:15:23 EST 2013] */
+/* DO NOT EDIT: Automated versioning hack [Thu Jan 24 18:55:29 EST 2013] */
More information about the commits
mailing list