"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/wav_frontend.c" between
xcdroast-1.18.tar.gz and xcdroast-1.19.tar.gz

About: X-CD-Roast is a graphical user interface (GUI) for the command-line cdrtools.

wav_frontend.c  (xcdroast-1.18):wav_frontend.c  (xcdroast-1.19)
skipping to change at line 72 skipping to change at line 72
extern GtkCList *play_clist; extern GtkCList *play_clist;
extern setup_data_t setupdata; extern setup_data_t setupdata;
extern GList *imagelist; extern GList *imagelist;
extern gchar sharedir[MAXLINE]; extern gchar sharedir[MAXLINE];
gint wav_in, wavplay_quit; gint wav_in, wavplay_quit;
GtkWidget *wav_quit_button; GtkWidget *wav_quit_button;
static GtkWidget *drawa, *timer_label, *wavplay_text; static GtkWidget *drawa, *timer_label, *wavplay_text;
static GtkWidget *playb, *stopb, *nextb; static GtkWidget *playb, *stopb, *nextb;
static gint playhdl, stophdl, nexthdl, prevhdl; static gint playhdl, stophdl, nexthdl, prevhdl, mixhdl;
static GdkPixmap *pixmap = NULL; static GdkPixmap *pixmap = NULL;
static gint wav_out; static gint wav_out;
static gint maxseconds; static gint maxseconds;
static gint curseconds; static gint curseconds;
static gint maxpixels; static gint maxpixels;
static gint ptimer; static gint ptimer;
static gint callback_tag; static gint callback_tag;
static gint error_flag; static gint error_flag;
static gchar playing_track[MAXLINE];
static gboolean inpause;
static void read_wav_exit(GPid pid, gint status, gpointer data);
static gboolean read_wav_out(GIOChannel *source, GIOCondition cond, gpointer dat a); static gboolean read_wav_out(GIOChannel *source, GIOCondition cond, gpointer dat a);
static gint draw_ticks (gpointer data); static gint draw_ticks (gpointer data);
/* /*
* updates the text-window * updates the text-window
*/ */
static void update_text(gchar *txt) { static void update_text(gchar *txt) {
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GtkTextIter start, end; GtkTextIter start, end;
skipping to change at line 161 skipping to change at line 164
update_text(tmp); update_text(tmp);
} }
/* /*
* loads a wav-file and starts playing * loads a wav-file and starts playing
*/ */
static void start_play(gchar *filename) { static void start_play(gchar *filename) {
gchar cmd[MAXLINE]; gchar cmd[MAXLINE];
gchar tmptmp[MAXLINE]; gchar tmptmp[MAXLINE];
GIOChannel *gio; GIOChannel *gio;
GPid pid;
/* already playing? */ /* already playing? */
if (wav_in != -1) { if (wav_in != -1) {
return; return;
} }
/* have we got an audiodevice? */ /* have we got an audiodevice? */
if (strcmp(setupdata.dsp_device,"") == 0) { if (strcmp(setupdata.dsp_device,"") == 0) {
update_text(_("Warning: No DSP-device configured.")); update_text(_("Warning: No Audio-device configured."));
return; return;
} }
strcpy(tmptmp,filename); strcpy(tmptmp,filename);
g_snprintf(cmd,MAXLINE,"%s/%s -g -d \"%s\" \"%s\" 2>&1", sharedir, WAVPLA Y, g_snprintf(cmd,MAXLINE,"%s/%s -g -d \"%s\" \"%s\" 2>&1", sharedir, WAVPLA Y,
setupdata.dsp_device, convert_escape(tmptmp)); setupdata.dsp_device, convert_escape(tmptmp));
dodebug(1, "spawning shell: %s\n",cmd); dodebug(1, "spawning shell: %s\n",cmd);
dolog(3, "Executing: %s\n", cmd); dolog(3, "Executing: %s\n", cmd);
/* start child and get new fds */ /* start child and get new fds */
full_dpl_pipe_shell(&wav_out,&wav_in,cmd); pid = (GPid)full_dpl_pipe_shell(&wav_out,&wav_in,cmd);
/* catch output of child */ /* catch output of child */
gio = g_io_channel_unix_new(wav_out); gio = g_io_channel_unix_new(wav_out);
g_io_channel_set_encoding(gio, NULL, NULL); g_io_channel_set_encoding(gio, NULL, NULL);
callback_tag = g_io_add_watch(gio, G_IO_IN | G_IO_HUP, callback_tag = g_io_add_watch(gio, G_IO_IN,
read_wav_out, NULL); read_wav_out, NULL);
/* check termination of child */
g_child_watch_add(pid, read_wav_exit, (gpointer)gio);
} }
/* /*
* ends the wavplay-process and cleans up * ends the wavplay-process and cleans up
*/ */
static void stop_play() { static void stop_play() {
if (wav_in == -1) { if (wav_in == -1) {
/* we are not playing right now */ /* we are not playing right now */
return; return;
skipping to change at line 370 skipping to change at line 377
/* get trackname from selection */ /* get trackname from selection */
get_sel_trackname(tmp); get_sel_trackname(tmp);
/* if nothing selected force select first row */ /* if nothing selected force select first row */
if (strcmp(tmp,"") == 0) { if (strcmp(tmp,"") == 0) {
gtk_clist_select_row(play_clist,0,0); gtk_clist_select_row(play_clist,0,0);
get_sel_trackname(tmp); get_sel_trackname(tmp);
} }
/* did we change the track selection? */
if (strcmp(tmp, playing_track) != 0) {
/* quit playing current track */
gtk_button_clicked(GTK_BUTTON(wav_quit_button));
/* now wait until we are really finished */
while (wav_in != -1) {
wait_and_process_events();
}
}
/* got a valid selection? start play it */ /* got a valid selection? start play it */
if (strcmp(tmp,"") != 0) { if (strcmp(tmp,"") != 0) {
strncpy(playing_track, tmp, MAXLINE);
start_play(tmp); start_play(tmp);
} }
/* pipes not yet set up */ /* pipes not yet set up */
if (wav_in == -1) { if (wav_in == -1) {
/* detoggle button */ /* detoggle button */
gtk_signal_handler_block(GTK_OBJECT(playb),playhdl); gtk_signal_handler_block(GTK_OBJECT(playb),playhdl);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playb),0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playb),0);
gtk_signal_handler_unblock(GTK_OBJECT(playb),playhdl); gtk_signal_handler_unblock(GTK_OBJECT(playb),playhdl);
return; return;
} }
/* draw text-info */ /* draw text-info */
trackinfo_text(tmp); trackinfo_text(tmp);
dodebug(8,"wavplay: sending command play\n"); dodebug(8,"wavplay: sending command play\n");
if (write(wav_in, "play\n", 5) != 5) { if (write(wav_in, "play\n", 5) != 5) {
g_warning("write error to pipe\n"); g_warning("write error to pipe\n");
} }
inpause = FALSE;
} }
static void dostop(GtkWidget *widget, gpointer data) { static void dostop(GtkWidget *widget, gpointer data) {
/* pipes not yet set up */ /* pipes not yet set up */
if (wav_in == -1) { if (wav_in == -1) {
/* detoggle button */ /* detoggle button */
gtk_signal_handler_block(GTK_OBJECT(stopb),stophdl); gtk_signal_handler_block(GTK_OBJECT(stopb),stophdl);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stopb),0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stopb),0);
gtk_signal_handler_unblock(GTK_OBJECT(stopb),stophdl); gtk_signal_handler_unblock(GTK_OBJECT(stopb),stophdl);
return; return;
} }
dodebug(8,"wavplay: sending command stop\n"); dodebug(8,"wavplay: sending command stop\n");
if (write(wav_in, "stop\n", 5) != 5) { if (write(wav_in, "stop\n", 5) != 5) {
g_warning("write error to pipe\n"); g_warning("write error to pipe\n");
} }
inpause = FALSE;
} }
static void dopause(GtkWidget *widget, gpointer data) { static void dopause(GtkWidget *widget, gpointer data) {
/* pipes not yet set up */ /* pipes not yet set up */
if (wav_in == -1) return; if (wav_in == -1) return;
/* already paused? Toggle play */
if (inpause) {
gtk_button_clicked(GTK_BUTTON(playb));
return;
}
dodebug(8,"wavplay: sending command pause\n"); dodebug(8,"wavplay: sending command pause\n");
if (write(wav_in, "pause\n", 6) != 6) { if (write(wav_in, "pause\n", 6) != 6) {
g_warning("write error to pipe\n"); g_warning("write error to pipe\n");
} }
inpause = TRUE;
} }
static void doquit(GtkWidget *widget, gpointer data) { static void doquit(GtkWidget *widget, gpointer data) {
/* pipes not yet set up */ /* pipes not yet set up */
if (wav_in == -1) return; if (wav_in == -1) return;
dodebug(8,"wavplay: sending command quit\n"); dodebug(8,"wavplay: sending command quit\n");
if (write(wav_in, "quit\n", 5) != 5) { if (write(wav_in, "quit\n", 5) != 5) {
g_warning("write error to pipe\n"); g_warning("write error to pipe\n");
skipping to change at line 581 skipping to change at line 609
update_rect.width = mx; update_rect.width = mx;
update_rect.height = my; update_rect.height = my;
/* this calls expose */ /* this calls expose */
gtk_widget_draw (dr, &update_rect); gtk_widget_draw (dr, &update_rect);
return(TRUE); return(TRUE);
} }
/* /*
* called when the wavplay child terminated
*/
static void read_wav_exit(GPid pid, gint status, gpointer data) {
dodebug(10, "wavplay terminated with status: %d\n", status);
/* cleanup */
g_io_channel_unref((GIOChannel *)data);
strcpy(playing_track, "");
gtk_label_set_text(GTK_LABEL(timer_label),"0:00");
close(wav_out);
close(wav_in);
stop_play();
}
/*
* called when new data from stdout of child is available * called when new data from stdout of child is available
*/ */
static gboolean read_wav_out(GIOChannel *source, GIOCondition cond, gpointer dat a) { static gboolean read_wav_out(GIOChannel *source, GIOCondition cond, gpointer dat a) {
gint n; gint n;
gchar line[MAXLINE]; gchar line[MAXLINE];
gchar cmd[MAXLINE]; gchar cmd[MAXLINE];
gchar tmp[MAXLINE]; gchar tmp[MAXLINE];
gint tsec; gint tsec;
gint ret;
if (cond == G_IO_HUP) {
g_io_channel_unref(source);
wait(&ret);
close(wav_out);
close(wav_in);
stop_play();
return (FALSE);
}
n = read(wav_out, line, MAXLINE); n = read(wav_out, line, MAXLINE);
if (n < 0) { if (n < 0) {
g_warning("read error from pipe\n"); g_warning("read error from pipe\n");
return (FALSE); return (FALSE);
} }
line[n] = '\0'; line[n] = '\0';
dodebug(10,"wavplay: %s", line); dodebug(10,"wavplay: %s", line);
/* warning found - device busy? */ /* warning found - device busy? */
if (strncmp(line,"\n**",3) == 0) { if (strncmp(line,"\n**",3) == 0) {
error_flag = 1; error_flag = 1;
update_text(_("Error accessing DSP-device.\nBusy by another progr am?")); update_text(_("Error accessing Audio-device.\nBusy by another pro gram?"));
return (TRUE); return (TRUE);
} }
strncpy(cmd,line,4); strncpy(cmd,line,4);
cmd[4] = '\0'; cmd[4] = '\0';
tsec = atoi(line+4); tsec = atoi(line+4);
if (strncmp(cmd,"secs",4) == 0) { if (strncmp(cmd,"secs",4) == 0) {
/* start marker found */ /* start marker found */
if (tsec == 0) { if (tsec == 0) {
skipping to change at line 842 skipping to change at line 877
gtk_table_attach_defaults(GTK_TABLE(tbl2),mix_xpm,14,15,0,1); gtk_table_attach_defaults(GTK_TABLE(tbl2),mix_xpm,14,15,0,1);
gtk_widget_show(mix_xpm); gtk_widget_show(mix_xpm);
adj = gtk_adjustment_new(0.0,0.0,101.0,1.0,1.0,1.0); adj = gtk_adjustment_new(0.0,0.0,101.0,1.0,1.0,1.0);
slider = gtk_hscale_new(GTK_ADJUSTMENT(adj)); slider = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos (GTK_SCALE(slider), GTK_POS_LEFT); gtk_scale_set_value_pos (GTK_SCALE(slider), GTK_POS_LEFT);
gtk_scale_set_digits(GTK_SCALE(slider),0); gtk_scale_set_digits(GTK_SCALE(slider),0);
gtk_scale_set_draw_value(GTK_SCALE(slider),FALSE); gtk_scale_set_draw_value(GTK_SCALE(slider),FALSE);
gtk_table_attach_defaults(GTK_TABLE(tbl2),slider,15,20,0,1); gtk_table_attach_defaults(GTK_TABLE(tbl2),slider,15,20,0,1);
gtk_widget_show(slider); gtk_widget_show(slider);
gtk_signal_connect(GTK_OBJECT(adj), "value_changed", mixhdl = gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
GTK_SIGNAL_FUNC(vol_changed), NULL); GTK_SIGNAL_FUNC(vol_changed), NULL);
define_tooltip(slider, _("Change the volume of playback.")); define_tooltip(slider, _("Change the volume of playback."));
gtk_signal_handler_block(GTK_OBJECT(adj), mixhdl);
gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), (gfloat) def_mix_val); gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), (gfloat) def_mix_val);
gtk_signal_handler_unblock(GTK_OBJECT(adj), mixhdl);
} }
/* /*
* draw the wav-control-panel * draw the wav-control-panel
*/ */
void wavplay_frontend(GtkWidget *widget) { void wavplay_frontend(GtkWidget *widget) {
GtkWidget *f1; GtkWidget *f1;
gint mixval; gint mixval;
maxseconds = 60; /* dummy value */ maxseconds = 60; /* dummy value */
maxpixels = 1; maxpixels = 1;
curseconds = 0; curseconds = 0;
wav_in = -1; wav_out = -1; wav_in = -1; wav_out = -1;
error_flag = 0; error_flag = 0;
wavplay_quit = 0; wavplay_quit = 0;
inpause = FALSE;
strcpy(playing_track, "");
f1 = gtk_frame_new(NULL); f1 = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN); gtk_frame_set_shadow_type(GTK_FRAME(f1),GTK_SHADOW_IN);
gtk_container_border_width(GTK_CONTAINER(f1),5); gtk_container_border_width(GTK_CONTAINER(f1),5);
gtk_box_pack_start(GTK_BOX(widget),f1,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(widget),f1,FALSE,FALSE,0);
mixval = query_mixer(); mixval = query_mixer();
wavmenu(f1,mixval); wavmenu(f1,mixval);
gtk_widget_show(f1); gtk_widget_show(f1);
 End of changes. 22 change blocks. 
17 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)