Skip to content

Commit

Permalink
Merge pull request #2 from erikd/master
Browse files Browse the repository at this point in the history
Please pull this set of changes
  • Loading branch information
kfish committed Feb 1, 2012
2 parents 3e530ab + 9ab4109 commit 27a78f3
Show file tree
Hide file tree
Showing 35 changed files with 440 additions and 3,310 deletions.
21 changes: 19 additions & 2 deletions configure.ac
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ if test "x$HAVE_LIBSNDFILE1" = xmaybe ; then
fi fi
fi fi


dnl
dnl Detect tdb (Tiny Database library)
dnl

PKG_CHECK_MODULES(TDB, tdb >= 1.2.0,
HAVE_LIBTDB="yes", HAVE_LIBTDB="no")

if test "x$HAVE_LIBTDB" = xyes ; then
AC_DEFINE([HAVE_LIBTDB], [], [Define if we have tdb.])
AC_SUBST(TDB_CFLAGS)
AC_SUBST(TDB_LIBS)
else
sweep_config_ok="no"
fi



AC_CHECK_SIZEOF(off_t,1) AC_CHECK_SIZEOF(off_t,1)




Expand Down Expand Up @@ -590,7 +607,7 @@ if test "x$HAVE_VORBIS" != xyes ; then
fi fi


if test "x$HAVE_GLIB" = xmaybe || test "x$HAVE_GTK" = xmaybe || if test "x$HAVE_GLIB" = xmaybe || test "x$HAVE_GTK" = xmaybe ||
test "x$HAVE_LIBSNDFILE1" = xmaybe || test "x$HAVE_TDB" = xmaybe || test "x$HAVE_LIBSNDFILE1" = xmaybe || test "x$HAVE_LIBTDB" = xmaybe ||
test "x$HAVE_GTHREADS" = xmaybe || test "x$HAVE_ALSA" = xmaybe || test "x$HAVE_GTHREADS" = xmaybe || test "x$HAVE_ALSA" = xmaybe ||
test "x$HAVE_OGG" = xmaybe || test "x$HAVE_VORBIS" = xmaybe ; then test "x$HAVE_OGG" = xmaybe || test "x$HAVE_VORBIS" = xmaybe ; then
AC_MSG_RESULT([ AC_MSG_RESULT([
Expand Down Expand Up @@ -631,7 +648,6 @@ m4/Makefile
include/Makefile include/Makefile
include/sweep/Makefile include/sweep/Makefile
src/Makefile src/Makefile
src/tdb/Makefile
plugins/Makefile plugins/Makefile
plugins/echo/Makefile plugins/echo/Makefile
plugins/normalise/Makefile plugins/normalise/Makefile
Expand Down Expand Up @@ -659,6 +675,7 @@ AC_MSG_RESULT([
** MPEG (MP3) loading: ...... $HAVE_MAD ** MPEG (MP3) loading: ...... $HAVE_MAD
** Speex support: ........... $HAVE_SPEEX ** Speex support: ........... $HAVE_SPEEX
** Secret Rabbit Code: ...... $HAVE_LIBSAMPLERATE ** Secret Rabbit Code: ...... $HAVE_LIBSAMPLERATE
** libtdb for preferences: .. $HAVE_LIBTDB
** Translations: ............ $ALL_LINGUAS ** Translations: ............ $ALL_LINGUAS
** **
** Installation directories: ** Installation directories:
Expand Down
4 changes: 2 additions & 2 deletions include/sweep/sweep_undo.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ gint
update_edit_progress (gpointer data); update_edit_progress (gpointer data);


sw_op_instance * sw_op_instance *
sw_op_instance_new (sw_sample * sample, char * description, sw_op_instance_new (sw_sample * sample, const char * description,
sw_operation * operation); sw_operation * operation);


void void
schedule_operation (sw_sample * sample, char * description, schedule_operation (sw_sample * sample, const char * description,
sw_operation * operation, void * do_data); sw_operation * operation, void * do_data);


void void
Expand Down
14 changes: 5 additions & 9 deletions src/Makefile.am
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,5 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in


SUBDIRS = tdb

AM_CFLAGS = \ AM_CFLAGS = \
$(GTK_DISABLE_DEPRECATED) \ $(GTK_DISABLE_DEPRECATED) \
-DPACKAGE_DATA_DIR='@PACKAGE_DATA_DIR@' \ -DPACKAGE_DATA_DIR='@PACKAGE_DATA_DIR@' \
Expand All @@ -12,14 +10,12 @@ AM_CFLAGS = \
@GLIB_CFLAGS@ \ @GLIB_CFLAGS@ \
@GTHREADS_CFLAGS@ \ @GTHREADS_CFLAGS@ \
@ALSA_CFLAGS@ \ @ALSA_CFLAGS@ \
@PULSEAUDIO_CFLAGS@ @PULSEAUDIO_CFLAGS@ \
@TDB_CFLAGS@


INCLUDES = \ INCLUDES = \
-I$(top_srcdir)/intl \ -I$(top_srcdir)/intl \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include
-I$(top_srcdir)/src/tdb

TDB_LIBS = $(top_builddir)/src/tdb/libtdb.a


bin_PROGRAMS = sweep bin_PROGRAMS = sweep


Expand All @@ -40,7 +36,7 @@ sweep_SOURCES = \
edit.c edit.h \ edit.c edit.h \
file_dialogs.c file_dialogs.h \ file_dialogs.c file_dialogs.h \
file_sndfile.h \ file_sndfile.h \
file_sndfile1.c \ file_sndfile.c \
file_mad.c \ file_mad.c \
file_speex.c \ file_speex.c \
file_vorbis.c \ file_vorbis.c \
Expand Down Expand Up @@ -74,7 +70,7 @@ sweep_SOURCES = \
view.c view.h \ view.c view.h \
view_pixmaps.h view_pixmaps.h


sweep_LDADD = $(TDB_LIBS) \ sweep_LDADD = @TDB_LIBS@ \
@GTK_LIBS@ $(INTLLIBS) $(PTHREAD_LIBS) \ @GTK_LIBS@ $(INTLLIBS) $(PTHREAD_LIBS) \
$(SNDFILE_LIBS) \ $(SNDFILE_LIBS) \
$(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(VORBISENC_LIBS) \ $(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(VORBISENC_LIBS) \
Expand Down
13 changes: 5 additions & 8 deletions src/channelops.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ dup_channels (sw_sample * sample, int new_channels)
g_snprintf (buf, sizeof (buf), _("Duplicate from %d to %d channels"), g_snprintf (buf, sizeof (buf), _("Duplicate from %d to %d channels"),
sample->sounddata->format->channels, new_channels); sample->sounddata->format->channels, new_channels);
} }

schedule_operation (sample, buf, &dup_channels_op, schedule_operation (sample, buf, &dup_channels_op,
GINT_TO_POINTER(new_channels)); GINT_TO_POINTER(new_channels));
} }
Expand Down Expand Up @@ -195,12 +195,9 @@ dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data)
sw_sample * sample = view->sample; sw_sample * sample = view->sample;
GtkWidget * dialog; GtkWidget * dialog;
GtkWidget * main_vbox; GtkWidget * main_vbox;
/*GtkWidget * label;*/
GtkWidget * chooser; GtkWidget * chooser;
GtkWidget * button, * ok_button; GtkWidget * button, * ok_button;


/*gchar * current;*/

dialog = gtk_dialog_new (); dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Duplicate channel")); gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Duplicate channel"));
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
Expand Down Expand Up @@ -488,7 +485,7 @@ do_stereo_swap (sw_sample * sample, gpointer data)


remaining -= n; remaining -= n;
run_total += n; run_total += n;

percent = run_total / ctotal; percent = run_total / ctotal;
sample_set_progress_percent (sample, percent); sample_set_progress_percent (sample, percent);
} }
Expand Down Expand Up @@ -630,7 +627,7 @@ change_channels (sw_sample * sample, int new_channels)


g_snprintf (buf, sizeof (buf), _("Convert from %d to %d channels"), g_snprintf (buf, sizeof (buf), _("Convert from %d to %d channels"),
sample->sounddata->format->channels, new_channels); sample->sounddata->format->channels, new_channels);

schedule_operation (sample, buf, &change_channels_op, schedule_operation (sample, buf, &change_channels_op,
GINT_TO_POINTER(new_channels)); GINT_TO_POINTER(new_channels));
} }
Expand Down Expand Up @@ -674,7 +671,7 @@ channels_dialog_new_cb (GtkWidget * widget, gpointer data)
GtkWidget * chooser; GtkWidget * chooser;
GtkWidget * button, * ok_button; GtkWidget * button, * ok_button;


gchar * current; gchar current [128];


dialog = gtk_dialog_new (); dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Add/Remove channels")); gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Add/Remove channels"));
Expand All @@ -683,7 +680,7 @@ channels_dialog_new_cb (GtkWidget * widget, gpointer data)


main_vbox = GTK_DIALOG(dialog)->vbox; main_vbox = GTK_DIALOG(dialog)->vbox;


current = g_strdup_printf (_("Currently: %d channels"), snprintf (current, sizeof (current), _("Currently: %d channels"),
sample->sounddata->format->channels); sample->sounddata->format->channels);
label = gtk_label_new (current); label = gtk_label_new (current);
gtk_box_pack_start (GTK_BOX(main_vbox), label, TRUE, TRUE, 8); gtk_box_pack_start (GTK_BOX(main_vbox), label, TRUE, TRUE, 8);
Expand Down
10 changes: 5 additions & 5 deletions src/db_slider.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ db_slider_value_changed_cb (GtkWidget * widget, gpointer data)
{ {
GtkWidget * slider = (GtkWidget *)data; GtkWidget * slider = (GtkWidget *)data;
gfloat value, db_value; gfloat value, db_value;
gchar * db_text; gchar db_text [16];


value = db_slider_get_value (DB_SLIDER(slider)); value = db_slider_get_value (DB_SLIDER(slider));
db_value = VALUE_TO_DB (value); db_value = VALUE_TO_DB (value);


if (db_value > -10.0) { if (db_value > -10.0) {
db_text = g_strdup_printf ("%1.1f dB", db_value); snprintf (db_text, sizeof (db_text), "%1.1f dB", db_value);
} else { } else {
db_text = g_strdup_printf ("%2.0f dB", db_value); snprintf (db_text, sizeof (db_text), "%2.0f dB", db_value);
} }


gtk_label_set_text (GTK_LABEL(DB_SLIDER(slider)->db_label), db_text); gtk_label_set_text (GTK_LABEL(DB_SLIDER(slider)->db_label), db_text);
Expand All @@ -148,7 +148,7 @@ db_slider_build (GtkWidget * slider, gchar * title, gfloat value)


GtkObject * adj; GtkObject * adj;


gchar * range_text; gchar range_text [128];


vbox = gtk_vbox_new (FALSE, 0); vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER(slider), vbox); gtk_container_add (GTK_CONTAINER(slider), vbox);
Expand Down Expand Up @@ -182,7 +182,7 @@ db_slider_build (GtkWidget * slider, gchar * title, gfloat value)


db_slider_value_changed_cb (NULL, slider); db_slider_value_changed_cb (NULL, slider);


range_text = g_strdup_printf ("%s\n[%2.0f to %2.0f dB]", snprintf (range_text, sizeof (range_text), "%s\n[%2.0f to %2.0f dB]",
title, title,
VALUE_TO_DB(DB_SLIDER(slider)->lower), VALUE_TO_DB(DB_SLIDER(slider)->lower),
VALUE_TO_DB(DB_SLIDER(slider)->upper)); VALUE_TO_DB(DB_SLIDER(slider)->upper));
Expand Down
55 changes: 26 additions & 29 deletions src/driver.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,81 +71,78 @@ static sw_driver * dialog_driver = &_driver_null;


static char * prefs_driver_key = "driver"; static char * prefs_driver_key = "driver";


char * const char *
pcmio_get_default_main_dev (void) pcmio_get_default_main_dev (void)
{ {
static char name [128];
GList * names = NULL, * gl; GList * names = NULL, * gl;


if (dialog_driver->get_names) if (dialog_driver->get_names)
names = dialog_driver->get_names (); names = dialog_driver->get_names ();


if ((gl = names) != NULL) { if ((gl = names) != NULL) {
return (char *)gl->data; strncpy (name, gl->data, sizeof (name));
return name;
} }


return "Default"; return "Default";
} }


char * const char *
pcmio_get_default_monitor_dev (void) pcmio_get_default_monitor_dev (void)
{ {
static char name [128];
GList * names = NULL, * gl; GList * names = NULL, * gl;


if (dialog_driver->get_names) if (dialog_driver->get_names)
names = dialog_driver->get_names (); names = dialog_driver->get_names ();


if ((gl = names) != NULL) { if ((gl = names) != NULL) {
if ((gl = gl->next) != NULL) { if ((gl = gl->next) != NULL) {
return (char *)gl->data; strncpy (name, gl->data, sizeof (name));
return name;
} }
} }


return "Default"; return "Default";
} }


char * const char *
pcmio_get_main_dev (void) pcmio_get_main_dev (void)
{ {
char * main_dev; static char main_dev [128];


main_dev = prefs_get_string (dialog_driver->primary_device_key); prefs_get_string (dialog_driver->primary_device_key, main_dev, sizeof (main_dev), "");


if (main_dev == NULL) return pcmio_get_default_main_dev(); if (main_dev [0] == 0)
return pcmio_get_default_main_dev();


return main_dev; return main_dev;
} }


char * const char *
pcmio_get_monitor_dev (void) pcmio_get_monitor_dev (void)
{ {
char * monitor_dev; static char monitor_dev [128];


monitor_dev = prefs_get_string (dialog_driver->monitor_device_key); prefs_get_string (dialog_driver->monitor_device_key, monitor_dev, sizeof (monitor_dev), "");


if (monitor_dev == NULL) return pcmio_get_default_monitor_dev (); if (monitor_dev [0] == 0)
return pcmio_get_default_monitor_dev ();


return monitor_dev; return monitor_dev;
} }


gboolean gboolean
pcmio_get_use_monitor (void) pcmio_get_use_monitor (void)
{ {
int * use_monitor; return prefs_get_int (USE_MONITOR_KEY, DEFAULT_USE_MONITOR);

use_monitor = prefs_get_int (USE_MONITOR_KEY);

if (use_monitor == NULL) return DEFAULT_USE_MONITOR;
else return (*use_monitor != 0);
} }


int int
pcmio_get_log_frags (void) pcmio_get_log_frags (void)
{ {
int * log_frags; return prefs_get_int (dialog_driver->log_frags_key, DEFAULT_LOG_FRAGS);

log_frags = prefs_get_int (dialog_driver->log_frags_key);
if (log_frags == NULL) return DEFAULT_LOG_FRAGS;
else return (*log_frags);
} }


extern GtkStyle * style_bw; extern GtkStyle * style_bw;
Expand Down Expand Up @@ -322,7 +319,7 @@ static void
pcmio_devname_reset_cb (GtkWidget * widget, gpointer data) pcmio_devname_reset_cb (GtkWidget * widget, gpointer data)
{ {
GtkWidget * dialog = GTK_WIDGET (data); GtkWidget * dialog = GTK_WIDGET (data);
char * main_dev, * monitor_dev; const char * main_dev, * monitor_dev;


main_dev = pcmio_get_main_dev (); main_dev = pcmio_get_main_dev ();
monitor_dev = pcmio_get_monitor_dev (); monitor_dev = pcmio_get_monitor_dev ();
Expand All @@ -339,7 +336,7 @@ static void
pcmio_devname_default_cb (GtkWidget * widget, gpointer data) pcmio_devname_default_cb (GtkWidget * widget, gpointer data)
{ {
GtkWidget * dialog = GTK_WIDGET (data); GtkWidget * dialog = GTK_WIDGET (data);
char * name; const char * name;


if ((name = pcmio_get_default_main_dev ()) != NULL) { if ((name = pcmio_get_default_main_dev ()) != NULL) {
gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), name); gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), name);
Expand Down Expand Up @@ -764,7 +761,7 @@ device_read (sw_handle * handle, sw_audio_t * buf, size_t count)
} }


ssize_t ssize_t
device_write (sw_handle * handle, sw_audio_t * buf, size_t count) device_write (sw_handle * handle, const sw_audio_t * buf, size_t count)
{ {
#ifdef DEBUG #ifdef DEBUG
printf ("device_write: %d from %d\n", count, offset); printf ("device_write: %d from %d\n", count, offset);
Expand Down Expand Up @@ -818,7 +815,7 @@ device_close (sw_handle * handle)
void void
init_devices (void) init_devices (void)
{ {
const char * driver; char driver [64];
int k = 0; int k = 0;


memset (driver_table, 0, sizeof (driver_table)); memset (driver_table, 0, sizeof (driver_table));
Expand All @@ -833,13 +830,13 @@ init_devices (void)
if (driver_solaris->name != NULL) if (driver_solaris->name != NULL)
driver_table [k++] = driver_solaris; driver_table [k++] = driver_solaris;


driver = prefs_get_string (prefs_driver_key); prefs_get_string (prefs_driver_key, driver, sizeof (driver), "");


/* Set a default in case preferences driver doesn't exist. */ /* Set a default in case preferences driver doesn't exist. */
current_driver = driver_table [0]; current_driver = driver_table [0];


/* Switch to driver from preferences if possible. */ /* Switch to driver from preferences if possible. */
if (driver != NULL) if (driver [0] != 0)
for (k = 0 ; driver_table [k] != NULL ; k++) for (k = 0 ; driver_table [k] != NULL ; k++)
if (strcmp (driver, driver_table [k]->name) == 0) if (strcmp (driver, driver_table [k]->name) == 0)
current_driver = driver_table [k]; current_driver = driver_table [k];
Expand Down
12 changes: 6 additions & 6 deletions src/driver.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ struct _sw_driver {
void (*setup) (sw_handle * handle, sw_format * format); void (*setup) (sw_handle * handle, sw_format * format);
int (*wait) (sw_handle * handle); int (*wait) (sw_handle * handle);
ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count); ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count);
ssize_t (*write) (sw_handle * handle, sw_audio_t * buf, size_t count); ssize_t (*write) (sw_handle * handle, const sw_audio_t * buf, size_t count);
sw_framecount_t (*offset) (sw_handle * handle); sw_framecount_t (*offset) (sw_handle * handle);
void (*reset) (sw_handle * handle); void (*reset) (sw_handle * handle);
void (*flush) (sw_handle * handle); void (*flush) (sw_handle * handle);
void (*drain) (sw_handle * handle); void (*drain) (sw_handle * handle);
void (*close) (sw_handle * handle); void (*close) (sw_handle * handle);

char * primary_device_key; char * primary_device_key;
char * monitor_device_key; char * monitor_device_key;
char * log_frags_key; char * log_frags_key;
Expand All @@ -76,20 +76,20 @@ ssize_t
device_read (sw_handle * handle, sw_audio_t * buf, size_t count); device_read (sw_handle * handle, sw_audio_t * buf, size_t count);


ssize_t ssize_t
device_write (sw_handle * handle, sw_audio_t * buf, size_t count); device_write (sw_handle * handle, const sw_audio_t * buf, size_t count);


/* As far as I'm aware the method /* As far as I'm aware the method
* used to monitor latency in OSS and Solaris etc. is different to that which * used to monitor latency in OSS and Solaris etc. is different to that which
* ALSA uses, and different again from JACK and PortAudio. * ALSA uses, and different again from JACK and PortAudio.
* *
* Basically, when the device is written to, the driver is also told what the * Basically, when the device is written to, the driver is also told what the
* offset into the file is for that bit of sound. * offset into the file is for that bit of sound.
* *
* Then, when the GUI thread goes to draw the cursor, it asks the driver * Then, when the GUI thread goes to draw the cursor, it asks the driver
* what the offset of the sound that's currently coming out of the speaker is * what the offset of the sound that's currently coming out of the speaker is
* and draws it there (which may be a little behind or ahead of where the * and draws it there (which may be a little behind or ahead of where the
* user is scrubbing) -- hence the sound and the vision are kept in sync. * user is scrubbing) -- hence the sound and the vision are kept in sync.
* *
* However, this is all currently disabled, and going to change, as its not * However, this is all currently disabled, and going to change, as its not
* properly monitoring the latency of multiple files being played * properly monitoring the latency of multiple files being played
* simultaneously; plus it may have to change with respect to ALSA and JACK and * simultaneously; plus it may have to change with respect to ALSA and JACK and
Expand Down
Loading

0 comments on commit 27a78f3

Please sign in to comment.