Commit 178441ed authored by Monty Montgomery's avatar Monty Montgomery

Implement pipeline reset
Abstract playback pause and halt
connect |<< control


git-svn-id: https://svn.xiph.org/trunk/postfish@5476 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent d4973c31
......@@ -75,7 +75,7 @@ void input_Bcursor_set(off_t c){
pthread_mutex_unlock(&master_mutex);
}
off_t input_time_to_cursor(char *t){
off_t input_time_to_cursor(const char *t){
char temp[14];
char *c;
......@@ -392,10 +392,10 @@ static void push_input_feedback(double *peak,double *rms, off_t cursor){
pthread_mutex_unlock(&master_mutex);
}
int pull_input_feedback(double *peak,double *rms,off_t *cursor,int *n){
int pull_input_feedback(double *peak,double *rms,off_t *cursor,int *nn){
input_feedback *f;
int i,j;
*n=input_ch+2;
int i,j,n=input_ch+2;
if(nn)*nn=n;
pthread_mutex_lock(&master_mutex);
if(feedback_list_tail){
......@@ -410,9 +410,12 @@ int pull_input_feedback(double *peak,double *rms,off_t *cursor,int *n){
}
pthread_mutex_unlock(&master_mutex);
memcpy(rms,f->rms,sizeof(*rms)* *n);
memcpy(peak,f->peak,sizeof(*peak)* *n);
*cursor=f->cursor;
if(rms)
memcpy(rms,f->rms,sizeof(*rms)*n);
if(peak)
memcpy(peak,f->peak,sizeof(*peak)*n);
if(cursor)
*cursor=f->cursor;
pthread_mutex_lock(&master_mutex);
f->next=feedback_pool;
......@@ -553,5 +556,10 @@ time_linkage *input_read(void){
return &out;
}
void input_reset(void){
while(pull_input_feedback(NULL,NULL,NULL,NULL));
return;
}
extern void input_Acursor_set(off_t c);
extern void input_Bcursor_set(off_t c);
extern off_t input_time_to_cursor(char *t);
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 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);
......@@ -30,6 +30,7 @@
#include "postfish.h"
#include "mainpanel.h"
#include "input.h"
#include "output.h"
pthread_mutex_t master_mutex=PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
......@@ -69,14 +70,7 @@ int main(int argc, char **argv){
input_seek(0);
mainpanel_go(argc,argv,input_ch);
playback_exit=1;
while(1){
if(playback_active){
sched_yield();
}else
break;
}
output_halt_playback();
//save_settings(configfd);
if(configfd>=0)close(configfd);
......
......@@ -51,6 +51,8 @@ typedef struct {
GtkWidget *channelshow[10]; /* support only up to 8 + mid/side */
GtkWidget *cue;
GtkWidget *entry_a;
GtkWidget *entry_b;
/* ui state */
int fishframe;
......@@ -59,6 +61,18 @@ typedef struct {
} postfish_mainpanel;
static void action_zero(GtkWidget *widget,postfish_mainpanel *p){
const char *time=gtk_entry_get_text(GTK_ENTRY(p->entry_a));
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_play(GtkWidget *widget,postfish_mainpanel *p){
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){
if(!playback_active){
......@@ -68,16 +82,7 @@ static void action_play(GtkWidget *widget,postfish_mainpanel *p){
pthread_create(&playback_thread_id,NULL,&playback_thread,NULL);
}
}else{
if(playback_active){
playback_exit=1;
sched_yield();
while(1){
if(playback_active){
sched_yield();
}else
break;
}
}
output_pause_playback();
}
}
......@@ -603,6 +608,8 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
0,0);
g_signal_connect (G_OBJECT (panel->deckactive[0]), "clicked",
G_CALLBACK (action_zero), panel);
g_signal_connect (G_OBJECT (panel->deckactive[3]), "clicked",
G_CALLBACK (action_play), panel);
......@@ -613,14 +620,15 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
{
GtkWidget *cuebox=gtk_hbox_new(0,0);
GtkWidget *cuelabel=gtk_label_new("cue:");
GtkWidget *entry_a=gtk_entry_new();
GtkWidget *entry_b=gtk_entry_new();
GtkWidget *framea=gtk_vseparator_new();
GtkWidget *frameb=gtk_vseparator_new();
GtkWidget *panelb=gtk_check_button_new_with_mnemonic("c_ue list");
panel->entry_a=gtk_entry_new();
panel->entry_b=gtk_entry_new();
panel->cue=readout_new(" : :00.00");
......@@ -630,19 +638,19 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
panel->cue_reset[1]=gtk_button_new_with_label("[B]");
gtk_entry_set_width_chars(GTK_ENTRY(entry_a),13);
gtk_entry_set_width_chars(GTK_ENTRY(entry_b),13);
gtk_entry_set_text(GTK_ENTRY(entry_a)," : :00.00");
gtk_entry_set_text(GTK_ENTRY(entry_b)," : :00.00");
gtk_entry_set_width_chars(GTK_ENTRY(panel->entry_a),13);
gtk_entry_set_width_chars(GTK_ENTRY(panel->entry_b),13);
gtk_entry_set_text(GTK_ENTRY(panel->entry_a)," : :00.00");
gtk_entry_set_text(GTK_ENTRY(panel->entry_b)," : :00.00");
g_signal_connect (G_OBJECT (entry_a), "key-press-event",
g_signal_connect (G_OBJECT (panel->entry_a), "key-press-event",
G_CALLBACK (timeevent_keybinding), panel->toplevel);
g_signal_connect (G_OBJECT (entry_b), "key-press-event",
g_signal_connect (G_OBJECT (panel->entry_b), "key-press-event",
G_CALLBACK (timeevent_keybinding), panel->toplevel);
g_signal_connect_after(G_OBJECT (entry_a), "grab_focus",
g_signal_connect_after(G_OBJECT (panel->entry_a), "grab_focus",
G_CALLBACK (timeevent_unselect), NULL);
g_signal_connect_after(G_OBJECT (entry_b), "grab_focus",
g_signal_connect_after(G_OBJECT (panel->entry_b), "grab_focus",
G_CALLBACK (timeevent_unselect), NULL);
g_signal_connect (G_OBJECT (panel->cue_set[1]), "clicked",
......@@ -663,13 +671,13 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
gtk_box_pack_start(GTK_BOX(cuebox),framea,1,1,3);
gtk_box_pack_start(GTK_BOX(cuebox),panel->cue_set[0],0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),entry_a,0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),panel->entry_a,0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),panel->cue_reset[0],0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),frameb,1,1,3);
gtk_box_pack_start(GTK_BOX(cuebox),panel->cue_set[1],0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),entry_b,0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),panel->entry_b,0,0,0);
gtk_box_pack_start(GTK_BOX(cuebox),panel->cue_reset[1],0,0,0);
}
......@@ -700,13 +708,7 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
}
static gboolean async_event_handle(GIOChannel *channel,
GIOCondition condition,
gpointer data){
postfish_mainpanel *panel=data;
int i;
char buf[1];
read(eventpipe[0],buf,1);
static gboolean feedback_process(postfish_mainpanel *panel){
/* first order of business: release the play button if playback is
no longer in progress */
......@@ -723,6 +725,7 @@ static gboolean async_event_handle(GIOChannel *channel,
double *peak=alloca(sizeof(*peak)*(input_ch+2));
if(pull_input_feedback(peak,rms,&time_cursor,&n)){
char buffer[14];
int i;
for(i=0;i<n;i++){
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->channelshow[i]))){
peak[i]=todB(peak[i]);
......@@ -755,6 +758,17 @@ static gboolean async_event_handle(GIOChannel *channel,
}
}
}
static gboolean async_event_handle(GIOChannel *channel,
GIOCondition condition,
gpointer data){
postfish_mainpanel *panel=data;
int i;
char buf[1];
read(eventpipe[0],buf,1);
feedback_process(panel);
return TRUE;
}
......
......@@ -407,3 +407,11 @@ void multibar_set(Multibar *m,double *lo, double *hi, int n){
widget->allocation.height);
}
void multibar_reset(Multibar *m){
m->peak=-400;
m->peakdelta=0;
m->peakdelay=0;
m->clipdelay=0;
multibar_set(m,NULL,NULL,0);
}
......@@ -65,6 +65,7 @@ GtkWidget* multibar_new (int n, char **labels, double *levels,
int flags);
void multibar_clear (Multibar *m);
void multibar_set (Multibar *m,double *lo,double *hi, int n);
void multibar_reset (Multibar *m);
G_END_DECLS
......
......@@ -78,10 +78,10 @@ static void push_output_feedback(double *peak,double *rms){
pthread_mutex_unlock(&master_mutex);
}
int pull_output_feedback(double *peak,double *rms,int *n){
int pull_output_feedback(double *peak,double *rms,int *nn){
output_feedback *f;
int i,j;
*n=input_ch+2;
int i,j,n=input_ch+2;
if(nn)*nn=n;
pthread_mutex_lock(&master_mutex);
if(feedback_list_tail){
......@@ -96,8 +96,10 @@ int pull_output_feedback(double *peak,double *rms,int *n){
}
pthread_mutex_unlock(&master_mutex);
memcpy(rms,f->rms,sizeof(*rms)* *n);
memcpy(peak,f->peak,sizeof(*peak)* *n);
if(rms)
memcpy(rms,f->rms,sizeof(*rms)*n);
if(peak)
memcpy(peak,f->peak,sizeof(*peak)*n);
pthread_mutex_lock(&master_mutex);
f->next=feedback_pool;
......@@ -325,3 +327,31 @@ void *playback_thread(void *dummy){
return(NULL);
}
void output_pause_playback(void){
if(playback_active){
playback_exit=1;
while(1){
if(playback_active){
sched_yield();
}else
break;
}
}
}
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 */
}
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);
#define VERSION "$Id: version.h,v 1.11 2003/10/16 22:11:12 xiphmont Exp $ "
/* DO NOT EDIT: Automated versioning hack [Thu Oct 16 18:10:11 EDT 2003] */
#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] */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment