[xiph-cvs] cvs commit: snatch libsnatch.c snatch.pl x11.c
Monty
xiphmont at xiph.org
Sat Nov 10 00:41:37 PST 2001
xiphmont 01/11/10 00:41:37
Modified: . libsnatch.c snatch.pl x11.c
Log:
need to fill in a handful of write() calls and have the perl robor
watch for a few more stderr possibilities.
Monty
Revision Changes Path
1.12 +95 -32 snatch/libsnatch.c
Index: libsnatch.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/libsnatch.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- libsnatch.c 2001/11/10 07:21:42 1.11
+++ libsnatch.c 2001/11/10 08:41:36 1.12
@@ -63,6 +63,7 @@
static int (*xlib_xshmputimage)(Display *,Drawable,GC,XImage *,int,int,int,int,
unsigned int,unsigned int,Bool);
+static int (*xlib_xresizewindow)(Display *,Window,unsigned int,unsigned int);
static Display *Xdisplay;
@@ -93,6 +94,9 @@
static int outfile_fd=-1;
+static void CloseOutputFile();
+static void OpenOutputFile();
+
#include "x11.c" /* yeah, ugly, but I don't want to leak symbols.
Oh and I'm lazy. */
@@ -194,6 +198,8 @@
if(ret==1)
FakeKeySym(sym,mod,rpplay_window);
}
+ CloseOutputFile(); /* it will only happen on Robot commands that would
+ be starting a new file */
break;
case 'U':
case 'P':
@@ -286,6 +292,7 @@
xlib_xchangeproperty=get_me_symbol("XChangeProperty");
xlib_xputimage=get_me_symbol("XPutImage");
xlib_xshmputimage=get_me_symbol("XShmPutImage");
+ xlib_xresizewindow=get_me_symbol("XResizeWindow");
/* output path? */
outpath=nstrdup(getenv("SNATCH_OUTPUT_PATH"));
@@ -508,17 +515,22 @@
if(debug)
fprintf(stderr,
" ...: RealPlayer closed audio playback fd %d\n",fd);
+ CloseOutputFile();
}
return(ret);
}
ssize_t write(int fd, const void *buf,size_t count){
- int ret;
if(fd==audio_fd){
- // ret=((*libc_write)(fd,buf,count));
- //return(ret);
+ if(count>0){
+ if(outfile_fd<0)OpenOutputFile();
+ if(outfile_fd>=0){ /* always be careful */
+
+
+ }
+ }
if(fake_audiop)return(count);
}
@@ -570,6 +582,7 @@
fprintf(stderr,
" ...: Audio output sampling rate set to %dHz.\n",
audio_rate);
+ CloseOutputFile();
break;
case SNDCTL_DSP_CHANNELS:
audio_channels=*(int *)arg;
@@ -577,6 +590,7 @@
fprintf(stderr,
" ...: Audio output set to %d channels.\n",
audio_channels);
+ CloseOutputFile();
break;
case SNDCTL_DSP_SETFMT:
audio_format=*(int *)arg;
@@ -584,6 +598,7 @@
fprintf(stderr,
" ...: Audio output format set to %s.\n",
formatname(audio_format));
+ CloseOutputFile();
break;
case SNDCTL_DSP_GETOSPACE:
if(fake_audiop){
@@ -597,17 +612,18 @@
fprintf(stderr," ...: Audio output buffer size requested; faking 64k\n");
ret=0;
}
+ CloseOutputFile();
break;
case SNDCTL_DSP_GETODELAY: /* Must reject the ODELAY if we're not going to track
audio bytes and timing! */
if(fake_audiop){
- int foo=*(int *)arg;
if(debug)
fprintf(stderr,
" ...: Rejecting SNDCTL_DSP_GETODELAY ioctl()\n");
*(int *)arg=0;
ret=-1;
}
+ CloseOutputFile();
break;
}
@@ -625,41 +641,88 @@
pthread_mutex_unlock(&event_mutex);
}
-#if 0
static void OpenOutputFile(){
- if(strcmp(outpath,"-")){
- outfile_fd=STDOUT_FILENO;
- }else{
- struct stat buf;
- int ret=stat(outpath,&buf);
- if(ret){
- fprintf("**ERROR: Could not stat requested output path!\n"
- " %s: %s\n\n",outpath,strerror(errno));
- outfile_fd=-2;
+ if(outfile_fd!=2){
+ if(!strcmp(outpath,"-")){
+ outfile_fd=STDOUT_FILENO;
+ if(debug)fprintf(stderr," ...: Capturing to stdout\n");
}else{
- if(S_ISDIR(buf.st_mode)){
- /* construct a new filename */
- struct tm *now;
- char buf2[256];
- char buf1[256];
- now=localtime(time(NULL));
- strftime(buf1,256,"%Y%m%d_%H:%M:%S",now);
- //if(
- //sprintf(buf2,"%s_%s%dHz_%dx%d.snatch",buf1,
-
- /****** XXXXX */
-
+ struct stat buf;
+ int ret=stat(outpath,&buf);
+ if(ret){
+ fprintf(stderr,"**ERROR: Could not stat requested output path!\n"
+ " %s: %s\n\n",outpath,strerror(errno));
+ outfile_fd=-2;
}else{
- outfile_fd=(*libc_open)(outpath,O_RDWR|O_CREAT|O_APPEND,0770);
- if(outfile_fd<0){
- fprintf("**ERROR: Could not stat requested output path!\n"
- " %s: %s\n\n",outpath,strerror(errno));
- outfile_fd=-2;
+ if(S_ISDIR(buf.st_mode)){
+ /* construct a new filename */
+ struct tm *now;
+ char buf2[256];
+ char buf1[256];
+ time_t nows;
+ nows=time(NULL);
+ now=localtime(&nows);
+ strftime(buf1,256,"%Y%m%d_%H:%M:%S",now);
+ if(videocount){
+ if(audio_channels){
+ sprintf(buf2,"%s_%s%dHz_%dx%d_AV.snatch",
+ buf1,
+ (audio_channels==1?"mono":"stereo"),
+ audio_rate,
+ video_width,
+ video_height);
+ }else{
+ sprintf(buf2,"%s_%dx%d_V.snatch",
+ buf1,
+ video_width,
+ video_height);
+ }
+ }else{
+ sprintf(buf2,"%s_%s%dHz_A.snatch",
+ buf1,
+ (audio_channels==1?"mono":"stereo"),
+ audio_rate);
+ }
+
+ outfile_fd=(*libc_open)(buf2,O_RDWR|O_CREAT|O_APPEND,0770);
+ if(outfile_fd<0){
+ fprintf(stderr,"**ERROR: Could not stat requested output path!\n"
+ " %s: %s\n\n",buf2,strerror(errno));
+ outfile_fd=-2;
+ }else
+ if(debug)fprintf(stderr," ...: Capturing to file %s\n",buf2);
+
+ }else{
+ outfile_fd=(*libc_open)(outpath,O_RDWR|O_CREAT|O_APPEND,0770);
+ if(outfile_fd<0){
+ fprintf(stderr,"**ERROR: Could not stat requested output path!\n"
+ " %s: %s\n\n",outpath,strerror(errno));
+ outfile_fd=-2;
+ }else{
+ if(debug)fprintf(stderr," ...: Capturing to file %s\n",outpath);
+ }
}
}
}
}
}
+static void CloseOutputFile(){
+ if(outfile_fd>=0){
+ videocount=0;
+ audio_channels=0;
+ audio_rate=0;
+
+ if(debug)fprintf(stderr," ...: Capture stopped.\n");
+ if(outfile_fd!=STDOUT_FILENO)
+ (*libc_close)(outfile_fd);
+ outfile_fd=-1;
+ }
+}
+
+
+
+
+
+
-#endif
1.19 +1 -1 snatch/snatch.pl
Index: snatch.pl
===================================================================
RCS file: /usr/local/cvsroot/snatch/snatch.pl,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- snatch.pl 2001/11/10 06:50:43 1.18
+++ snatch.pl 2001/11/10 08:41:36 1.19
@@ -1210,9 +1210,9 @@
place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se');
$timerw_quit->configure(-command=>[sub{
+ $timerw->destroy();
undef $listbox;
undef $timerw;
- $timerw->destroy();
$window_timerbar->configure(state=>'normal');
$window_timerbar->configure(relief=>'raised');
}]);
1.14 +40 -2 snatch/x11.c
Index: x11.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/x11.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- x11.c 2001/11/10 06:50:43 1.13
+++ x11.c 2001/11/10 08:41:36 1.14
@@ -53,8 +53,8 @@
static void queue_task(void (*f)(void));
static void initialize();
+static int videocount=0;
-
static void XGetGeometryRoot(unsigned long id,int *root_x,int *root_y){
int x=0;
int y=0;
@@ -377,7 +377,7 @@
logo_y=-1;
}
if(bitmask & CWWidth){
- rpplay_width=values->width;
+ rpplay_width=values->width;
logo_y=-1;
}
}
@@ -385,15 +385,36 @@
if(id==rpvideo_window){
if(bitmask & CWHeight){
video_height=values->height;
+ CloseOutputFile();
}
if(bitmask & CWWidth){
video_width=values->width;
+ CloseOutputFile();
}
}
return(ret);
}
+int XResizeWindow(Display *display,Window id,unsigned int width,unsigned int height){
+
+ int ret=(*xlib_xresizewindow)(display, id, width, height);
+
+ if(id==rpplay_window){
+ rpplay_height=height;
+ rpplay_width=width;
+ logo_y=-1;
+ }
+
+ if(id==rpvideo_window){
+ video_height=height;
+ video_width=width;
+ CloseOutputFile();
+ }
+
+ return(ret);
+}
+
int XChangeProperty(Display *display,Window id,Atom property,Atom type,int format,int mode,
const unsigned char *data,int n){
@@ -495,7 +516,15 @@
int ret;
if(snatch_active==1 && id==rpvideo_window){
+ videocount++;
+ if(videocount>5 && outfile_fd<0)OpenOutputFile();
+ if(outfile_fd>=0){
+
+
+
+
+ }
}
/* Subvert the Real sign on logo; paste the Snatch logo in.
@@ -631,7 +660,15 @@
if(snatch_active==1 && id==rpvideo_window){
+ videocount++;
+ if(videocount>5 && outfile_fd<0)OpenOutputFile();
+ if(outfile_fd>=0){
+
+
+
+
+ }
}
return(ret);
@@ -639,6 +676,7 @@
int XCloseDisplay(Display *d){
int ret=(*xlib_xclose)(d);
+ CloseOutputFile();
if(debug)fprintf(stderr," ...: X display closed; goodbye.\n\n");
return(ret);
}
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list