Please pull this set of changes #2

Merged
merged 9 commits into from Feb 1, 2012
+440 −3,310
Split
View
@@ -128,6 +128,23 @@ if test "x$HAVE_LIBSNDFILE1" = xmaybe ; then
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)
@@ -590,7 +607,7 @@ if test "x$HAVE_VORBIS" != xyes ; then
fi
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_OGG" = xmaybe || test "x$HAVE_VORBIS" = xmaybe ; then
AC_MSG_RESULT([
@@ -631,7 +648,6 @@ m4/Makefile
include/Makefile
include/sweep/Makefile
src/Makefile
-src/tdb/Makefile
plugins/Makefile
plugins/echo/Makefile
plugins/normalise/Makefile
@@ -659,6 +675,7 @@ AC_MSG_RESULT([
** MPEG (MP3) loading: ...... $HAVE_MAD
** Speex support: ........... $HAVE_SPEEX
** Secret Rabbit Code: ...... $HAVE_LIBSAMPLERATE
+** libtdb for preferences: .. $HAVE_LIBTDB
** Translations: ............ $ALL_LINGUAS
**
** Installation directories:
@@ -27,11 +27,11 @@ gint
update_edit_progress (gpointer data);
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);
void
-schedule_operation (sw_sample * sample, char * description,
+schedule_operation (sw_sample * sample, const char * description,
sw_operation * operation, void * do_data);
void
View
@@ -1,7 +1,5 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = tdb
-
AM_CFLAGS = \
$(GTK_DISABLE_DEPRECATED) \
-DPACKAGE_DATA_DIR='@PACKAGE_DATA_DIR@' \
@@ -12,14 +10,12 @@ AM_CFLAGS = \
@GLIB_CFLAGS@ \
@GTHREADS_CFLAGS@ \
@ALSA_CFLAGS@ \
- @PULSEAUDIO_CFLAGS@
+ @PULSEAUDIO_CFLAGS@ \
+ @TDB_CFLAGS@
INCLUDES = \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/src/tdb
-
-TDB_LIBS = $(top_builddir)/src/tdb/libtdb.a
+ -I$(top_srcdir)/include
bin_PROGRAMS = sweep
@@ -40,7 +36,7 @@ sweep_SOURCES = \
edit.c edit.h \
file_dialogs.c file_dialogs.h \
file_sndfile.h \
- file_sndfile1.c \
+ file_sndfile.c \
file_mad.c \
file_speex.c \
file_vorbis.c \
@@ -74,7 +70,7 @@ sweep_SOURCES = \
view.c view.h \
view_pixmaps.h
-sweep_LDADD = $(TDB_LIBS) \
+sweep_LDADD = @TDB_LIBS@ \
@GTK_LIBS@ $(INTLLIBS) $(PTHREAD_LIBS) \
$(SNDFILE_LIBS) \
$(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(VORBISENC_LIBS) \
View
@@ -146,7 +146,7 @@ dup_channels (sw_sample * sample, int new_channels)
g_snprintf (buf, sizeof (buf), _("Duplicate from %d to %d channels"),
sample->sounddata->format->channels, new_channels);
}
-
+
schedule_operation (sample, buf, &dup_channels_op,
GINT_TO_POINTER(new_channels));
}
@@ -195,12 +195,9 @@ dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data)
sw_sample * sample = view->sample;
GtkWidget * dialog;
GtkWidget * main_vbox;
- /*GtkWidget * label;*/
GtkWidget * chooser;
GtkWidget * button, * ok_button;
- /*gchar * current;*/
-
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Duplicate channel"));
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
@@ -488,7 +485,7 @@ do_stereo_swap (sw_sample * sample, gpointer data)
remaining -= n;
run_total += n;
-
+
percent = run_total / ctotal;
sample_set_progress_percent (sample, percent);
}
@@ -630,7 +627,7 @@ change_channels (sw_sample * sample, int new_channels)
g_snprintf (buf, sizeof (buf), _("Convert from %d to %d channels"),
sample->sounddata->format->channels, new_channels);
-
+
schedule_operation (sample, buf, &change_channels_op,
GINT_TO_POINTER(new_channels));
}
@@ -674,7 +671,7 @@ channels_dialog_new_cb (GtkWidget * widget, gpointer data)
GtkWidget * chooser;
GtkWidget * button, * ok_button;
- gchar * current;
+ gchar current [128];
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: Add/Remove channels"));
@@ -683,7 +680,7 @@ channels_dialog_new_cb (GtkWidget * widget, gpointer data)
main_vbox = GTK_DIALOG(dialog)->vbox;
- current = g_strdup_printf (_("Currently: %d channels"),
+ snprintf (current, sizeof (current), _("Currently: %d channels"),
sample->sounddata->format->channels);
label = gtk_label_new (current);
gtk_box_pack_start (GTK_BOX(main_vbox), label, TRUE, TRUE, 8);
View
@@ -120,15 +120,15 @@ db_slider_value_changed_cb (GtkWidget * widget, gpointer data)
{
GtkWidget * slider = (GtkWidget *)data;
gfloat value, db_value;
- gchar * db_text;
+ gchar db_text [16];
value = db_slider_get_value (DB_SLIDER(slider));
db_value = VALUE_TO_DB (value);
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 {
- 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);
@@ -148,7 +148,7 @@ db_slider_build (GtkWidget * slider, gchar * title, gfloat value)
GtkObject * adj;
- gchar * range_text;
+ gchar range_text [128];
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER(slider), vbox);
@@ -182,7 +182,7 @@ db_slider_build (GtkWidget * slider, gchar * title, gfloat value)
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,
VALUE_TO_DB(DB_SLIDER(slider)->lower),
VALUE_TO_DB(DB_SLIDER(slider)->upper));
View
@@ -71,81 +71,78 @@ static sw_driver * dialog_driver = &_driver_null;
static char * prefs_driver_key = "driver";
-char *
+const char *
pcmio_get_default_main_dev (void)
{
+ static char name [128];
GList * names = NULL, * gl;
if (dialog_driver->get_names)
names = dialog_driver->get_names ();
if ((gl = names) != NULL) {
- return (char *)gl->data;
+ strncpy (name, gl->data, sizeof (name));
+ return name;
}
return "Default";
}
-char *
+const char *
pcmio_get_default_monitor_dev (void)
{
+ static char name [128];
GList * names = NULL, * gl;
if (dialog_driver->get_names)
names = dialog_driver->get_names ();
if ((gl = names) != NULL) {
if ((gl = gl->next) != NULL) {
- return (char *)gl->data;
+ strncpy (name, gl->data, sizeof (name));
+ return name;
}
}
return "Default";
}
-char *
+const char *
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;
}
-char *
+const char *
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;
}
gboolean
pcmio_get_use_monitor (void)
{
- int * use_monitor;
-
- use_monitor = prefs_get_int (USE_MONITOR_KEY);
-
- if (use_monitor == NULL) return DEFAULT_USE_MONITOR;
- else return (*use_monitor != 0);
+ return prefs_get_int (USE_MONITOR_KEY, DEFAULT_USE_MONITOR);
}
int
pcmio_get_log_frags (void)
{
- int * log_frags;
-
- log_frags = prefs_get_int (dialog_driver->log_frags_key);
- if (log_frags == NULL) return DEFAULT_LOG_FRAGS;
- else return (*log_frags);
+ return prefs_get_int (dialog_driver->log_frags_key, DEFAULT_LOG_FRAGS);
}
extern GtkStyle * style_bw;
@@ -322,7 +319,7 @@ static void
pcmio_devname_reset_cb (GtkWidget * widget, gpointer data)
{
GtkWidget * dialog = GTK_WIDGET (data);
- char * main_dev, * monitor_dev;
+ const char * main_dev, * monitor_dev;
main_dev = pcmio_get_main_dev ();
monitor_dev = pcmio_get_monitor_dev ();
@@ -339,7 +336,7 @@ static void
pcmio_devname_default_cb (GtkWidget * widget, gpointer data)
{
GtkWidget * dialog = GTK_WIDGET (data);
- char * name;
+ const char * name;
if ((name = pcmio_get_default_main_dev ()) != NULL) {
gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), name);
@@ -764,7 +761,7 @@ device_read (sw_handle * handle, sw_audio_t * buf, size_t count)
}
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
printf ("device_write: %d from %d\n", count, offset);
@@ -818,7 +815,7 @@ device_close (sw_handle * handle)
void
init_devices (void)
{
- const char * driver;
+ char driver [64];
int k = 0;
memset (driver_table, 0, sizeof (driver_table));
@@ -833,13 +830,13 @@ init_devices (void)
if (driver_solaris->name != NULL)
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. */
current_driver = driver_table [0];
/* Switch to driver from preferences if possible. */
- if (driver != NULL)
+ if (driver [0] != 0)
for (k = 0 ; driver_table [k] != NULL ; k++)
if (strcmp (driver, driver_table [k]->name) == 0)
current_driver = driver_table [k];
View
@@ -45,13 +45,13 @@ struct _sw_driver {
void (*setup) (sw_handle * handle, sw_format * format);
int (*wait) (sw_handle * handle);
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);
void (*reset) (sw_handle * handle);
void (*flush) (sw_handle * handle);
void (*drain) (sw_handle * handle);
void (*close) (sw_handle * handle);
-
+
char * primary_device_key;
char * monitor_device_key;
char * log_frags_key;
@@ -76,20 +76,20 @@ ssize_t
device_read (sw_handle * handle, sw_audio_t * buf, size_t count);
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
* used to monitor latency in OSS and Solaris etc. is different to that which
* ALSA uses, and different again from JACK and PortAudio.
- *
+ *
* Basically, when the device is written to, the driver is also told what the
* offset into the file is for that bit of sound.
- *
+ *
* 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
* 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.
- *
+ *
* However, this is all currently disabled, and going to change, as its not
* properly monitoring the latency of multiple files being played
* simultaneously; plus it may have to change with respect to ALSA and JACK and
Oops, something went wrong.