Skip to content

Commit

Permalink
NDEBUG/assert fix + misc minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
James Morris committed Aug 6, 2012
1 parent a77ee27 commit be7c517
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 75 deletions.
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif (COMMAND CMAKE_POLICY)
project(Petri-Foo)

set(Petri-Foo_VERSION_MAJOR 1)
set(Petri-Foo_VERSION_MINOR 86)
set(Petri-Foo_VERSION_MINOR 87)
set(BINDIR "bin" CACHE STRING "Where to install binaries")
set(DATADIR "share/petri-foo" CACHE STRING "Where to install data files")
set(APPLICATIONS_DIR "share/applications" CACHE STRING "Where to install desktop files")
Expand All @@ -34,6 +34,11 @@ mark_as_advanced(CMAKE_INSTALL_PREFIX)
option (BuildForDebug "Include gdb debugging support" OFF)
option (GtkDeprecatedChecks "Check against use of API deprecated in GTK3" OFF)

if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/sandbox )
option (BuildSandbox "Build sandbox test code " OFF)
endif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/sandbox )


# DEBUG
set (BuildOptionsDebug "-O0 -ggdb" CACHE STRING "Debug build flags")

Expand All @@ -56,7 +61,13 @@ else (BuildForDebug)
endif (BuildForDebug)

if (GtkDeprecatedChecks)
add_definitions(-DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES)
add_definitions(
-DGDK_PIXBUF_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED
-DGDK_DISABLE_DEPRECATED
-DGSEAL_ENABLE
-DGTK_DISABLE_SINGLE_INCLUDES)
message (STATUS "Building with GTK_DISABLE_DEPRECATED...")
endif (GtkDeprecatedChecks)


Expand All @@ -75,7 +86,6 @@ endif (JACK_FOUND)
include (FindALSA)



# SNDFILE
pkg_check_modules (SNDFILE REQUIRED sndfile)
if (SNDFILE_FOUND)
Expand Down Expand Up @@ -160,12 +170,12 @@ ADD_SUBDIRECTORY( libphin )
ADD_SUBDIRECTORY( gui )


if (BuildForDebug)
if (BuildSandbox)
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/sandbox )
message( STATUS "Will build sandbox test target" )
ADD_SUBDIRECTORY( sandbox )
endif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/sandbox )
endif (BuildForDebug)
endif (BuildSandbox)

#ADD_SUBDIRECTORY( pixmaps )

Expand Down
32 changes: 32 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
2012-08-06 James Morris <james@jwm-art.net>

* patch_set_and_get.c, lfopar_from_id: found nasty side
effect where an lfo id was calculated from a modulation
source id from within an assert... eeek!

* gui/mod_section.[ch]: remove mod_section_set_list_*
these two functions were unused.

* midi.c: replace some debug with errmsg.

* patch_private/ move initialization of adsr parameters
from within patch_data.c to patch_voice.c

* make building of "sandbox test code" into an option
no longer dependant on debug build.


2012-08-05 James Morris <james@jwm-art.net>

* only get port data when auto-connect, plus
free data obtained.

* don't resample audio files when JACK is not
running (for debug/test).

* remove MODAL property from audio-settings
dialog.

* #define NDEBUG so assert are disabled when
building for release.

2012-08-02 James Morris <james@jwm-art.net>

* dish_file.c: call xmlFreeDoc on sucessful read.
Expand Down
4 changes: 4 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#cmakedefine DEBUG 1

#if !DEBUG
#define NDEBUG
#endif

#cmakedefine HAVE_MALLOC_H 1
#cmakedefine HAVE_JACK_SESSION_H 1
#cmakedefine HAVE_CAIRO_OPERATOR_HSL 1
Expand Down
2 changes: 1 addition & 1 deletion gui/audio-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void audio_settings_init (GtkWidget* parent)
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW (window), "Audio Settings");
gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(parent));
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
gtk_window_set_modal (GTK_WINDOW (window), FALSE);
g_signal_connect(GTK_WINDOW(window), "delete-event",
G_CALLBACK(cb_close), NULL);

Expand Down
1 change: 1 addition & 0 deletions gui/lfotab.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ static void lfo_tab_init(LfoTab* self)
ID_SELECTOR_V);

mod_src_free(lfo_ids);
lfo_ids = 0;

gui_pack(selfbox, p->idsel);
gui_pack(selfbox, gui_hpad_new(GUI_SECSPACE));
Expand Down
23 changes: 0 additions & 23 deletions gui/mod_section.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,29 +409,6 @@ void mod_section_set_param(ModSection* self, PatchParamType param)
}


void mod_section_set_list_global(ModSection* self)
{
ModSectionPrivate* p = MOD_SECTION_GET_PRIVATE(self);
int i;

for (i = 0; i < MAX_MOD_SLOTS; ++i)
mod_src_combo_set_model(GTK_COMBO_BOX(p->mod_combo[i]),
MOD_SRC_GLOBALS);
}


void mod_section_set_list_all(ModSection* self)
{
ModSectionPrivate* p = MOD_SECTION_GET_PRIVATE(self);

int i;

for (i = 0; i < MAX_MOD_SLOTS; ++i)
mod_src_combo_set_model(GTK_COMBO_BOX(p->mod_combo[i]),
MOD_SRC_ALL);
}


GtkWidget* mod_section_new(void)
{
return (GtkWidget*)g_object_new(MOD_SECTION_TYPE, NULL);
Expand Down
2 changes: 0 additions & 2 deletions gui/mod_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ void mod_section_set_mod_only(ModSection*);
void mod_section_set_param(ModSection*, PatchParamType);

void mod_section_set_lfo_id(ModSection*, int lfo_id);
void mod_section_set_list_global(ModSection*);
void mod_section_set_list_all(ModSection*);

void mod_section_set_patch(ModSection*, int patch_id);

Expand Down
3 changes: 1 addition & 2 deletions gui/mod_src_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static void mod_src_create_models(void)
mod_src_list_global = gtk_list_store_new(N_COLUMNS,
G_TYPE_STRING,
G_TYPE_INT);

mod_src_ids = mod_src_get(MOD_SRC_ALL);

for (msp = mod_src_ids; msp->name; ++msp)
Expand Down Expand Up @@ -84,7 +83,7 @@ static void mod_src_create_models(void)
}


GtkWidget* mod_src_new_combo_with_cell()
GtkWidget* mod_src_new_combo_with_cell(void)
{
GtkWidget* combo;
GtkCellRenderer* cell;
Expand Down
2 changes: 1 addition & 1 deletion gui/mod_src_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum {



GtkWidget* mod_src_new_combo_with_cell();
GtkWidget* mod_src_new_combo_with_cell(void);

/* mod_src_new_pitch_adjustment
creates a phin slider button with semitones label within.
Expand Down
43 changes: 19 additions & 24 deletions libpetrifoo/jackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ static jack_port_t* rport;
static jack_port_t* midiport;


static jack_client_t* client;
static float* buffer;
static jack_client_t* client = 0;
static float* buffer = 0;
static int rate = 44100;
static int periodsize = 2048;
static int running = 0;
Expand Down Expand Up @@ -244,7 +244,6 @@ static void init(void)

static int start(void)
{
const char** ports;
const char* instancename = get_instance_name();
jack_status_t status;

Expand Down Expand Up @@ -279,7 +278,7 @@ static int start(void)

mixer_set_jack_client(jackdriver_get_client());

jack_set_process_callback (client, process, 0);
jack_set_process_callback(client, process, 0);

#if HAVE_JACK_SESSION_H
if (!disable_jacksession && jack_set_session_callback)
Expand All @@ -292,7 +291,7 @@ static int start(void)
}
#endif

jack_on_shutdown (client, shutdown, 0);
jack_on_shutdown(client, shutdown, 0);

lport = jack_port_register( client,
"out_left",
Expand Down Expand Up @@ -338,35 +337,31 @@ static int start(void)
return -1;
}

ports = jack_get_ports(client, NULL, NULL,
JackPortIsInput | JackPortIsPhysical);

if (autoconnect)
{
if (ports[0] != NULL)
const char** ports = jack_get_ports(client, NULL, NULL,
JackPortIsInput | JackPortIsPhysical);
if (ports)
{
if (jack_connect(client, jack_port_name(lport), ports[0]))
if (!ports[0]
|| jack_connect(client, jack_port_name(lport), ports[0]) != 0)
{
debug("JACK failed to connect left output port\n");
free(ports);
goto ac_full_fail;
}

if (ports[1] != NULL)
{
if (jack_connect(client, jack_port_name (rport), ports[1]))
{
debug("JACK failed to connect right output port\n");
}
}
else
if (!ports[1]
|| jack_connect(client, jack_port_name(rport), ports[1]) != 0)
{
debug("JACK failed to connect right output port\n");
printf("failed to auto-connect to stereo h/w ports\n");
}

free (ports);
free(ports);
}
else
{
debug("JACK failed to connect output ports\n");
ac_full_fail:
printf("failed to auto-connect to h/w ports\n");
}
}

Expand All @@ -386,10 +381,10 @@ static int stop(void)

if (running)
{
debug("JACK shutting down...\n");
debug("JACK deactivate...\n");
jack_deactivate (client);
debug("JACK close..\n");
jack_client_close (client);

debug("JACK stopped\n");

if (buffer != NULL)
Expand Down
4 changes: 2 additions & 2 deletions libpetrifoo/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int open_seq(snd_seq_t** handle)

if (snd_seq_open(handle, "default", SND_SEQ_OPEN_INPUT, 0) < 0)
{
debug ("Failed to open ALSA sequencer\n");
errmsg("Failed to open ALSA sequencer\n");
return MIDI_ERR_SEQ;
}

Expand All @@ -179,7 +179,7 @@ static int open_seq(snd_seq_t** handle)
SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0)
{
debug ("Failed to create ALSA sequencer port\n");
errmsg("Failed to create ALSA sequencer port\n");
return MIDI_ERR_PORT;
}

Expand Down
5 changes: 0 additions & 5 deletions libpetrifoo/patch_private/patch_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,7 @@ Patch* patch_new(void)

for (i = 0; i < PATCH_VOICE_COUNT; ++i)
{
int j;

p->voices[i] = patch_voice_new();

for (j = 0; j < VOICE_MAX_ENVS; ++j)
adsr_init(p->voices[i]->env[j]);
}

p->last_note = -1;
Expand Down
6 changes: 6 additions & 0 deletions libpetrifoo/patch_private/patch_voice.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ PatchVoice* patch_voice_new(void)
}

for (i = 0; i < VOICE_MAX_ENVS; i++)
{
pv->env[i] = adsr_new();
adsr_init(pv->env[i]);
}

for (i = 0; i < VOICE_MAX_LFOS; i++)
{
pv->lfo[i] = lfo_new();
lfo_init(pv->lfo[i]);
}

pv->fll = 0;
pv->fbl = 0;
Expand Down
6 changes: 4 additions & 2 deletions libpetrifoo/patch_set_and_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ static LFOParams* lfopar_from_id(int patch_id, int id, LFO** lfo)

if (id & MOD_SRC_VLFO)
{
assert ((id -= MOD_SRC_VLFO) < VOICE_MAX_LFOS);
id -= MOD_SRC_VLFO;
assert (id < VOICE_MAX_LFOS);
return &patches[patch_id]->vlfo_params[id];
}

assert((id -= MOD_SRC_GLFO) < PATCH_MAX_LFOS);
id -= MOD_SRC_GLFO;
assert(id < PATCH_MAX_LFOS);

if (lfo)
*lfo = patches[patch_id]->glfo[id];
Expand Down
2 changes: 1 addition & 1 deletion libpetrifoo/petri-foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
fprintf(stderr, __VA_ARGS__); \
}
#else
# define debug(...)
#define debug(...)
#endif


Expand Down
5 changes: 3 additions & 2 deletions libpetrifoo/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ int sample_load_file(Sample* sample, const char* name,
}

if (resample_sndfile)
{
if (sfinfo.samplerate != rate)
{ /* ignore resample if rate is invalid (ie rate == -1 when
JACK is not running, useful under debug conditions. */
if (rate > 0 && sfinfo.samplerate != rate)
{
float* tmp2 = resample(tmp, rate, &sfinfo);

Expand Down
3 changes: 1 addition & 2 deletions sandbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ add_definitions (

add_executable(test ${TEST_SOURCES})


target_link_Libraries(test petrifoo petrifui pthread phin )
target_link_Libraries( test petrifoo petrifui pthread phin )

Loading

0 comments on commit be7c517

Please sign in to comment.