[xiph-cvs] cvs commit: postfish input.c input.h mainpanel.c multibar.c output.c output.h postfish.h version.h

Monty xiphmont at xiph.org
Thu Oct 16 23:28:16 PDT 2003



xiphmont    03/10/17 02:28:16

  Modified:    .        input.c input.h mainpanel.c multibar.c output.c
                        output.h postfish.h version.h
  Log:
  Enable most seeking deck buttons
  Rework seek async behavior; things have to work both during playback and
    when not playing back while not getting feedback stages out of sync
  Multibar overrange fixes.

Revision  Changes    Path
1.9       +13 -3     postfish/input.c

Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/input.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- input.c	16 Oct 2003 23:10:16 -0000	1.8
+++ input.c	17 Oct 2003 06:28:15 -0000	1.9
@@ -319,7 +319,7 @@
   return 0;
 }
 
-int input_seek(off_t pos){
+off_t input_seek(off_t pos){
   int i;
 
   if(pos<0)pos=0;
@@ -338,8 +338,9 @@
              SEEK_SET);
       pthread_mutex_lock(&master_mutex);
       cursor=pos;
+      playback_seeking=1;
       pthread_mutex_unlock(&master_mutex);
-      return 0;
+      return cursor;
     }
   }
   i--;
@@ -350,8 +351,17 @@
          SEEK_SET);
   pthread_mutex_lock(&master_mutex);
   cursor=pos;
+      playback_seeking=1;
   pthread_mutex_unlock(&master_mutex);
-  return(0);
+  return cursor;
+}
+
+int input_time_seek_rel(double s){
+  int ret;
+  pthread_mutex_lock(&master_mutex);
+  ret=input_seek(cursor+input_rate*inbytes*input_ch*s);
+  pthread_mutex_unlock(&master_mutex);
+  return ret;
 }
 
 static input_feedback *new_input_feedback(void){

<p><p>1.5       +2 -1      postfish/input.h

Index: input.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/input.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- input.h	16 Oct 2003 23:10:16 -0000	1.4
+++ input.h	17 Oct 2003 06:28:15 -0000	1.5
@@ -3,8 +3,9 @@
 extern off_t input_time_to_cursor(const char *t);
 extern void input_cursor_to_time(off_t cursor,char *t);
 extern void time_fix(char *buffer);
-extern int input_seek(off_t pos);
+extern off_t input_seek(off_t pos);
 extern time_linkage *input_read(void);
 extern int input_load(int n,char *list[]);
 extern int pull_input_feedback(double *peak,double *rms,off_t *cursor,int *n);
 extern void input_reset(void);
+extern int input_time_seek_rel(double s);

<p><p>1.16      +42 -6     postfish/mainpanel.c

Index: mainpanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/mainpanel.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- mainpanel.c	16 Oct 2003 23:10:16 -0000	1.15
+++ mainpanel.c	17 Oct 2003 06:28:15 -0000	1.16
@@ -66,13 +66,40 @@
   off_t cursor=input_time_to_cursor(time);
 
   output_halt_playback();
-  
   input_seek(cursor);
   readout_set(READOUT(p->cue),(char *)time);
   multibar_reset(MULTIBAR(p->inbar));
   multibar_reset(MULTIBAR(p->outbar));
 }
 
+static void action_bb(GtkWidget *widget,postfish_mainpanel *p){
+  off_t cursor=input_time_seek_rel(-60);
+  char time[14];
+  input_cursor_to_time(cursor,time);
+  readout_set(READOUT(p->cue),(char *)time);
+}
+
+static void action_b(GtkWidget *widget,postfish_mainpanel *p){
+  off_t cursor=input_time_seek_rel(-5);
+  char time[14];
+  input_cursor_to_time(cursor,time);
+  readout_set(READOUT(p->cue),(char *)time);
+}
+
+static void action_f(GtkWidget *widget,postfish_mainpanel *p){
+  off_t cursor=input_time_seek_rel(5);
+  char time[14];
+  input_cursor_to_time(cursor,time);
+  readout_set(READOUT(p->cue),(char *)time);
+}
+
+static void action_ff(GtkWidget *widget,postfish_mainpanel *p){
+  off_t cursor=input_time_seek_rel(60);
+  char time[14];
+  input_cursor_to_time(cursor,time);
+  readout_set(READOUT(p->cue),(char *)time);
+}
+
 static void action_play(GtkWidget *widget,postfish_mainpanel *p){
   if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){
     if(!playback_active){
@@ -82,11 +109,11 @@
       pthread_create(&playback_thread_id,NULL,&playback_thread,NULL);
     }
   }else{
-    output_pause_playback();
+    output_halt_playback();
   }
 }
 
-static void action_b(GtkWidget *widget,postfish_mainpanel *p){
+static void action_entryb(GtkWidget *widget,postfish_mainpanel *p){
   if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
     loop_active=1;
   else
@@ -610,8 +637,16 @@
 
       g_signal_connect (G_OBJECT (panel->deckactive[0]), "clicked",
                         G_CALLBACK (action_zero), panel);
+      g_signal_connect (G_OBJECT (panel->deckactive[1]), "clicked",
+			G_CALLBACK (action_bb), panel);
+      g_signal_connect (G_OBJECT (panel->deckactive[2]), "clicked",
+			G_CALLBACK (action_b), panel);
       g_signal_connect (G_OBJECT (panel->deckactive[3]), "clicked",
                         G_CALLBACK (action_play), panel);
+      g_signal_connect (G_OBJECT (panel->deckactive[4]), "clicked",
+			G_CALLBACK (action_f), panel);
+      g_signal_connect (G_OBJECT (panel->deckactive[5]), "clicked",
+			G_CALLBACK (action_ff), panel);
 
 
     }
@@ -654,7 +689,7 @@
                         G_CALLBACK (timeevent_unselect), NULL);
 
       g_signal_connect (G_OBJECT (panel->cue_set[1]), "clicked",
-			G_CALLBACK (action_b), panel);
+			G_CALLBACK (action_entryb), panel);
 
 
       gtk_widget_set_name(panel->cue_reset[0],"reseta");
@@ -717,8 +752,9 @@
     if(!playback_active)
       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel->deckactive[3]),0);
 
-  /* second order of business; update the input meter if data is available */
-  {
+  /* second order of business; update the input meter if data is
+     available and not dirtied by a seek */
+  if(!playback_seeking){
     off_t   time_cursor;
     int     n;
     double *rms=alloca(sizeof(*rms)*(input_ch+2));

<p><p>1.10      +7 -3      postfish/multibar.c

Index: multibar.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- multibar.c	16 Oct 2003 23:10:16 -0000	1.9
+++ multibar.c	17 Oct 2003 06:28:15 -0000	1.10
@@ -100,6 +100,8 @@
             double del=(lowvals[i]-m->levels[j])/(m->levels[j+1]-m->levels[j]);
             pixlo[i]=(j+del)/m->labels*widget->allocation.width;
             break;
+	  }else if(j==m->labels){
+	    pixlo[i]=widget->allocation.width+1;
           }
         }else
           break;
@@ -111,6 +113,8 @@
             double del=(highvals[i]-m->levels[j])/(m->levels[j+1]-m->levels[j]);
             pixhi[i]=(j+del)/m->labels*widget->allocation.width;
             break;
+	  }else if(j==m->labels){
+	    pixhi[i]=widget->allocation.width+1;
           }
         }else
           break;
@@ -237,12 +241,14 @@
     /* peak follower */
     {
       int x=-10;
-      for(j=0;j<=m->labels;j++)
+      for(j=0;j<=m->labels+1;j++)
         if(m->peak>=m->levels[j]){
           if(m->peak<=m->levels[j+1]){
             double del=(m->peak-m->levels[j])/(m->levels[j+1]-m->levels[j]);
             x=(j+del)/m->labels*widget->allocation.width;
             break;
+	  }else if (j==m->labels){
+	    x=widget->allocation.width+1;
           }
         }else
           break;
@@ -348,8 +354,6 @@
 
 static void multibar_init (Multibar *m){
   m->layout=0;
-  m->peak=-200;
-
   m->peakdelay=0;
   m->clipdelay=0;
   m->peak=-400;

<p><p>1.9       +26 -16    postfish/output.c

Index: output.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/output.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- output.c	16 Oct 2003 23:10:16 -0000	1.8
+++ output.c	17 Oct 2003 06:28:15 -0000	1.9
@@ -29,6 +29,26 @@
 
 sig_atomic_t playback_active=0;
 sig_atomic_t playback_exit=0;
+sig_atomic_t playback_seeking=0;
+
+void output_reset(void){
+  /* empty feedback queues */
+  while(pull_output_feedback(NULL,NULL,NULL));
+  return;
+}
+
+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);
+
+  input_reset();  /* clear any persistent lapping state */
+  output_reset(); /* clear any persistent lapping state */
+}
 
 typedef struct output_feedback{
   double *rms;
@@ -211,6 +231,11 @@
   double *peak=alloca(sizeof(*peak)*(input_ch+2));
 
   while(1){
+    if(playback_seeking){
+      pipeline_reset();
+      playback_seeking=0;
+    }
+
     if(playback_exit)break;
 
     /* get data */
@@ -327,7 +352,7 @@
   return(NULL);
 }
 
-void output_pause_playback(void){
+void output_halt_playback(void){
   if(playback_active){
     playback_exit=1;
     
@@ -340,18 +365,3 @@
   }
 }
 
-void output_reset(void){
-  /* empty feedback queues */
-  while(pull_output_feedback(NULL,NULL,NULL));
-  return;
-}
-
-/* safe to call from UI only because we wait for playback to halt and
-   it can't be restarted until we return */
-void output_halt_playback(void){
-  output_pause_playback();
-  input_reset();  /* clear any persistent lapping state */
-  output_reset(); /* clear any persistent lapping state */
-
-}
-

<p><p>1.3       +1 -1      postfish/output.h

Index: output.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/output.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- output.h	16 Oct 2003 23:10:16 -0000	1.2
+++ output.h	17 Oct 2003 06:28:15 -0000	1.3
@@ -1,5 +1,5 @@
 extern int pull_output_feedback(double *peak,double *rms,int *n);
 extern void *playback_thread(void *dummy);
-extern void output_pause_playback(void);
 extern void output_halt_playback(void);
 extern void output_reset(void);
+extern void playback_request_seek(off_t cursor);

<p><p>1.6       +1 -0      postfish/postfish.h

Index: postfish.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/postfish.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- postfish.h	16 Oct 2003 22:03:36 -0000	1.5
+++ postfish.h	17 Oct 2003 06:28:15 -0000	1.6
@@ -65,6 +65,7 @@
 extern sig_atomic_t loop_active;
 extern sig_atomic_t playback_active;
 extern sig_atomic_t playback_exit;
+extern sig_atomic_t playback_seeking;
 extern sig_atomic_t master_att;
 extern int outfileno;
 extern int seekable;

<p><p>1.13      +2 -2      postfish/version.h

Index: version.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/version.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- version.h	16 Oct 2003 23:10:16 -0000	1.12
+++ version.h	17 Oct 2003 06:28:15 -0000	1.13
@@ -1,2 +1,2 @@
-#define VERSION "$Id: version.h,v 1.12 2003/10/16 23:10:16 xiphmont Exp $ "
-/* DO NOT EDIT: Automated versioning hack [Thu Oct 16 19:09:25 EDT 2003] */
+#define VERSION "$Id: version.h,v 1.13 2003/10/17 06:28:15 xiphmont Exp $ "
+/* DO NOT EDIT: Automated versioning hack [Fri Oct 17 02:21:29 EDT 2003] */

<p><p>--- >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