Skip to content

Commit

Permalink
fix some tracing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-auger committed Aug 19, 2017
1 parent 4481af8 commit 951ecbe
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 104 deletions.
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for loopidity 0.14.007.
# Generated by GNU Autoconf 2.69 for loopidity 0.14.008.
#
# Report bugs to <https://github.com/bill-auger/loopidity/issues>.
#
Expand Down Expand Up @@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='loopidity'
PACKAGE_TARNAME='loopidity'
PACKAGE_VERSION='0.14.007'
PACKAGE_STRING='loopidity 0.14.007'
PACKAGE_VERSION='0.14.008'
PACKAGE_STRING='loopidity 0.14.008'
PACKAGE_BUGREPORT='https://github.com/bill-auger/loopidity/issues'
PACKAGE_URL=''

Expand Down Expand Up @@ -1308,7 +1308,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures loopidity 0.14.007 to adapt to many kinds of systems.
\`configure' configures loopidity 0.14.008 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1379,7 +1379,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of loopidity 0.14.007:";;
short | recursive ) echo "Configuration of loopidity 0.14.008:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1489,7 +1489,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
loopidity configure 0.14.007
loopidity configure 0.14.008
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1950,7 +1950,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by loopidity $as_me 0.14.007, which was
It was created by loopidity $as_me 0.14.008, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -2814,7 +2814,7 @@ fi

# Define the identity of the package.
PACKAGE='loopidity'
VERSION='0.14.007'
VERSION='0.14.008'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -9130,7 +9130,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by loopidity $as_me 0.14.007, which was
This file was extended by loopidity $as_me 0.14.008, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -9187,7 +9187,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
loopidity config.status 0.14.007
loopidity config.status 0.14.008
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([loopidity], [0.14.007], [https://github.com/bill-auger/loopidity/issues])
AC_INIT([loopidity], [0.14.008], [https://github.com/bill-auger/loopidity/issues])
AC_CONFIG_SRCDIR([src/loopidity.cpp])
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
AC_CONFIG_FILES([Makefile])
Expand Down
10 changes: 7 additions & 3 deletions src/constants/controller_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
#define JACK_INPUT4_PORT_NAME "in4"
#define JACK_OUTPUT1_PORT_NAME "outL"
#define JACK_OUTPUT2_PORT_NAME "outR"
#define LOOPIDITY_REINIT_MSG "ERROR: Loopidity::Main() and Loopidity::Init() should be called only once"
#define N_SCENES_ERR_MSG "ERROR: N_SCENES out of range - quitting"
#define INVALID_METADATA_MSG "ERROR: Scene metadata state insane"
#define LOOPIDITY_INIT_FAIL_MSG "ERROR: Could not initialize Loopidity"
#define JACK_INIT_FAIL_MSG "ERROR: Could not initialize JACK"
//#define FREEMEM_FAIL_MSG "ERROR: Could not determine available memory - quitting"
#define INSUFFICIENT_MEMORY_MSG "ERROR: Insufficient memory initializng buffers"
#define JACK_SW_FAIL_MSG "ERROR: Could not register JACK client"
#define JACK_HW_FAIL_MSG "ERROR: Could not open ports for JACK"
#define INSUFFICIENT_MEMORY_MSG "ERROR: Insufficient memory initializng buffers - quitting"
#define JACK_SW_FAIL_MSG "ERROR: Could not register JACK client - quitting"
#define JACK_HW_FAIL_MSG "ERROR: Could not open ports for JACK - quitting"
#define OUT_OF_MEMORY_MSG "ERROR: Out of Memory"

// sdl user events
Expand Down
28 changes: 10 additions & 18 deletions src/constants/feature_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,15 @@
# define DRAW_CURRENT_SCENE_INDICATOR 1
#endif // #if DRAW_SCENES

#if DRAW_DEBUG_TEXT
# include "../trace/trace.h"
# define DRAW_DEBUG_TEXT_L Trace::SetDbgTextC() ;
# define DRAW_DEBUG_TEXT_R Trace::SetDbgTextR() ;
#else
# define DRAW_DEBUG_TEXT_L ;
# define DRAW_DEBUG_TEXT_R ;
#endif // #if DRAW_DEBUG_TEXT

// Trace class features
#define DEBUG_TRACE 1
#define DEBUG_TRACE_JACK DEBUG_TRACE && 0
#define DEBUG_TRACE_LOOPIDITY DEBUG_TRACE && 0
#define DEBUG_TRACE_LOOPIDITYSDL DEBUG_TRACE && 0
#define DEBUG_TRACE_SCENE DEBUG_TRACE && 0
#define DEBUG_TRACE_SCENESDL DEBUG_TRACE && 0
#define DEBUG_TRACE_CLASS DEBUG_TRACE && 0
#define DEBUG_TRACE_EVS DEBUG_TRACE && 1
#define DEBUG_TRACE_IN DEBUG_TRACE && 1
#define DEBUG_TRACE_OUT DEBUG_TRACE && 1
#define DEBUG_TRACE_ALL 1
#define DEBUG_TRACE_JACK DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_LOOPIDITY DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_LOOPIDITYSDL DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_SCENE DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_SCENESDL DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_CLASS DEBUG_TRACE && (DEBUG_TRACE_ALL || 0)
#define DEBUG_TRACE_EVS DEBUG_TRACE && (DEBUG_TRACE_ALL || 1)
#define DEBUG_TRACE_IN DEBUG_TRACE && (DEBUG_TRACE_ALL || 1)
#define DEBUG_TRACE_OUT DEBUG_TRACE && (DEBUG_TRACE_ALL || 1)
40 changes: 19 additions & 21 deletions src/constants/view_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
#define GUI_UPDATE_LOW_PRIORITY_NICE 8 // n high priority updates to pass

// window magnitudes
#define SCREEN_W 1024 // minimum screen resolution
#define SCREEN_H 768 // minimum screen resolution
#define WIN_TITLE_H 20 // approximate window decoration size
#define WIN_BORDER_W 2 // approximate window decoration size
#define WIN_BORDER_H 2 // approximate window decoration size
#define PIXEL_DEPTH 32
#define WIN_W (SCREEN_W - (WIN_BORDER_W * 2))
#define WIN_H (SCREEN_H - WIN_TITLE_H - WIN_BORDER_H)
#define WIN_RECT { 0 , 0 , WIN_W , WIN_H }
#define WIN_CENTER (WinRect.w / 2)
#define SCREEN_W_MIN 1024 // minimum screen resolution
#define SCREEN_H_MIN 768 // minimum screen resolution
#define WIN_TITLE_H 20 // approximate window decoration size
#define WIN_BORDER_W 2 // approximate window decoration size
#define WIN_BORDER_H 2 // approximate window decoration size
#define BITS_PER_PIXEL 32
#define WIN_W (SCREEN_W_MIN - (WIN_BORDER_W * 2))
#define WIN_H (SCREEN_H_MIN - WIN_TITLE_H - WIN_BORDER_H)
#define WIN_RECT { 0 , 0 , WIN_W , WIN_H }
#define WIN_CENTER (WinRect.w / 2)

// header magnitudes
#define HEADER_FONT_SIZE 36
Expand Down Expand Up @@ -94,18 +94,13 @@
# define EDIT_HISTOGRAM_GRADUATION_H 12
#endif // #if SCENE_NFRAMES_EDITABLE

// external assets
#define SCOPE_IMG_PATH "scope_gradient.bmp"
#define HISTOGRAM_IMG_PATH "histogram_gradient.bmp"
#define LOOP_IMG_PATH "loop_gradient.argb.bmp"
#define PURISA_TTF_PATH "Purisa.ttf"

// fonts and colors
#define HEADER_FONT_PATH PURISA_TTF_PATH
#define PURISA_TTF "Purisa.ttf"
#define HEADER_FONT PURISA_TTF
#define HEADER_TEXT_COLOR { 255 , 0 , 255 , 0 }
#define STATUS_FONT_PATH PURISA_TTF_PATH
#define STATUS_FONT PURISA_TTF
#define STATUS_TEXT_COLOR { 255 , 0 , 255 , 0 }
#define WINDOWBGCOLOR 0xFF111111
#define WINDOWBGCOLOR 0xFF333333
#define VUSINBGCOLOR 0xFF221122
#define VUSOUTBGCOLOR 0xFF112222 // NOTE: SDL_FillRect() takes 0xAARRGGBB
#define VUSINBORDERCOLOR 0x882288FF // NOTE: roundedRectangleColor() takes 0xRRGGBBAA
Expand All @@ -119,8 +114,11 @@

// string constants
#define HEADER_TEXT "This is Loopidity"
#define X11_ERROR_MSG "ERROR: LoopiditySdl::Init(): XGetWindowAttributes(): can't get root window geometry - quitting\n"
#define RESOLUTION_ERROR_MSG "ERROR: screen resolution must be at least %dx%d - quitting\n"
#define LOOPIDITYSDL_REINIT_MSG "ERROR: LoopiditySdl::Init() should be called only once"
#define LOOPIDITYSDL_INIT_FAIL_MSG "ERROR: Data model not prepared before initializing GUI"
#define X11_ERROR_MSG "ERROR: Could not get root window geometry - quitting"
#define RESOLUTION_ERROR_MSG "ERROR: Screen resolution must be at least " + \
std::to_string(SCREEN_MIN_W) + "x" + std::to_string(SCREEN_MIN_H) + " - quitting"
#define SDL_ERROR_FMT "ERROR: %s(): %s\n"
#define SDL_INIT_ERROR_TEXT "SDL_Init"
#define SDL_SETVIDEOMODE_ERROR_TEXT "SDL_SetVideoMode"
Expand Down
51 changes: 25 additions & 26 deletions src/loopidity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ int Loopidity::Main(int argc , char** argv)
{
// sanity checks
#if INIT_JACK_BEFORE_SCENES
if (IsInitialized ) return false ;
if (IsInitialized ) { LoopiditySdl::Alert(LOOPIDITY_REINIT_MSG) ; return EXIT_FAILURE ; }
#else // INIT_JACK_BEFORE_SCENES
if (IsInitialized() ) return false ;
if (IsInitialized() ) { LoopiditySdl::Alert(LOOPIDITY_REINIT_MSG) ; return EXIT_FAILURE ; }
#endif // INIT_JACK_BEFORE_SCENES
if (N_SCENES + 2 < N_SCENES) return false ;
if (N_SCENES + 2 < N_SCENES) { LoopiditySdl::Alert(N_SCENES_ERR_MSG ) ; return EXIT_FAILURE ; }

// parse command line arguments
bool shouldMonitorInputs = true ;
Expand All @@ -92,7 +92,7 @@ int Loopidity::Main(int argc , char** argv)
// initialize Loopidity (controller), JackIO (controller), and LoopiditySdl (main view)
// and instantiate Scenes (models) and SdlScenes (views)
if (!Init(shouldMonitorInputs , shouldAutoSceneChange , recordBufferSize))
return Cleanup(EXIT_FAILURE) ;
{ Cleanup(LOOPIDITY_INIT_FAIL_MSG) ; return EXIT_FAILURE ; }

DEBUG_TRACE_LOOPIDITY_MAIN_MID

Expand Down Expand Up @@ -154,7 +154,7 @@ if (guiLongCount == GUI_UPDATE_LOW_PRIORITY_NICE)

DEBUG_TRACE_LOOPIDITY_MAIN_OUT

return Cleanup(EXIT_SUCCESS) ;
Cleanup() ; return EXIT_SUCCESS ;
}


Expand Down Expand Up @@ -196,6 +196,13 @@ bool Loopidity::IsInitialized() { return !!Scenes[0] ; }
bool Loopidity::Init(bool shouldMonitorInputs , bool shouldAutoSceneChange ,
Uint32 recordBufferSize )
{
// sanity checks
#if INIT_JACK_BEFORE_SCENES
if (IsInitialized) { LoopiditySdl::Alert(LOOPIDITY_REINIT_MSG) ; return EXIT_FAILURE ; }
#else // INIT_JACK_BEFORE_SCENES
if (IsInitialized()) { LoopiditySdl::Alert(LOOPIDITY_REINIT_MSG) ; return EXIT_FAILURE ; }
#endif // INIT_JACK_BEFORE_SCENES

// disable AutoSceneChange if SCENE_CHANGE_ARG given
if (!shouldAutoSceneChange) ToggleAutoSceneChange() ;

Expand All @@ -211,9 +218,9 @@ bool Loopidity::Init(bool shouldMonitorInputs , bool shouldAutoSceneChange ,
}

# if WAIT_FOR_JACK_INIT
// wait for JACK metadata
// wait for JACK metadata via SetMetadata()
while (!IsJackReady && (InitJackTimeout -= 100) > 0) usleep(100000) ;
if (!IsJackReady) return false ; // via SetMetadata()
if (!IsJackReady) { LoopiditySdl::Alert(JACK_INIT_FAIL_MSG) ; return false ; }
# endif // WAIT_FOR_JACK_INIT
#endif // INIT_JACK_BEFORE_SCENES

Expand Down Expand Up @@ -252,25 +259,17 @@ bool Loopidity::Init(bool shouldMonitorInputs , bool shouldAutoSceneChange ,
default: break ;
}
# if WAIT_FOR_JACK_INIT
// wait for JACK metadata
// wait for JACK metadata via SetMetadata()
while (!IsJackReady && (InitJackTimeout -= 100) > 0) usleep(100000) ;
if (!IsJackReady) return false ; // via SetMetadata()
if (!IsJackReady) { LoopiditySdl::Alert(JACK_INIT_FAIL_MSG) ; return false ; }
# endif // WAIT_FOR_JACK_INIT
#endif // INIT_JACK_BEFORE_SCENES

// initialize LoopiditySdl (view)
#if INIT_JACK_BEFORE_SCENES
IsInitialized = LoopiditySdl::Init(SdlScenes , peaksIn , peaksOut , peaksVuIn , peaksVuOut) ;

if (!IsInitialized) Cleanup(EXIT_FAILURE) ;

return IsInitialized ;
return (IsInitialized = LoopiditySdl::Init(SdlScenes , peaksIn , peaksOut , peaksVuIn , peaksVuOut)) ;
#else // INIT_JACK_BEFORE_SCENES
bool is_initialized = LoopiditySdl::Init(SdlScenes , peaksIn , peaksOut , peaksVuIn , peaksVuOut) ;

if (!is_initialized) Cleanup(EXIT_FAILURE) ;

return is_initialized ;
return LoopiditySdl::Init(SdlScenes , peaksIn , peaksOut , peaksVuIn , peaksVuOut) ;
#endif // INIT_JACK_BEFORE_SCENES
}

Expand Down Expand Up @@ -306,15 +305,15 @@ void Loopidity::SetMetadata(Uint32 sampleRate , Uint32 nFramesPerPeriod)
# endif // #if SCENE_NFRAMES_EDITABLE
#endif // #if INIT_JACK_BEFORE_SCENES

int Loopidity::Cleanup(int exit_status)
void Loopidity::Cleanup(std::string status_msg)
{
DEBUG_TRACE_LOOPIDITY_CLEANUP
DEBUG_TRACE_LOOPIDITY_CLEANUP

if (!status_msg.empty()) LoopiditySdl::Alert(status_msg) ;

for (Uint32 sceneN = 0 ; sceneN < N_SCENES ; ++sceneN)
if (!!SdlScenes[sceneN]) SdlScenes[sceneN]->cleanup() ;
LoopiditySdl::Cleanup() ;

return exit_status ;
}


Expand Down Expand Up @@ -497,11 +496,11 @@ DEBUG_TRACE_LOOPIDITY_RESETSCENE_IN
Scenes[sceneN]->reset() ; SdlScenes[sceneN]->reset() ; UpdateView(sceneN) ;

bool doesAnyPulseExist = false ;
for (sceneN = 0 ; sceneN < N_SCENES ; ++sceneN)
for (int scene_n = 0 ; scene_n < N_SCENES ; ++scene_n)
{
doesAnyPulseExist |= Scenes[sceneN]->getDoesPulseExist() ;
doesAnyPulseExist |= Scenes[scene_n]->getDoesPulseExist() ;
// TODO: extract this into doesAnyPulseExist()
//DBG("Loopidity::ResetScene() Scenes[%d]->getDoesPulseExist()=%d doesAnyPulseExist=%d\n" , sceneN , Scenes[sceneN]->getDoesPulseExist() , doesAnyPulseExist) ;
//DBG("Loopidity::ResetScene() Scenes[%d]->getDoesPulseExist()=%d doesAnyPulseExist=%d\n" , scene_n , Scenes[scene_n]->getDoesPulseExist() , doesAnyPulseExist) ;
}
IsRolling = doesAnyPulseExist ;

Expand Down
2 changes: 1 addition & 1 deletion src/loopidity.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Loopidity
#else
static void SetMetadata( Uint32 sampleRate , Uint32 nFramesPerPeriod) ;
#endif // #if INIT_JACK_BEFORE_SCENES
static int Cleanup( int retval) ;
static void Cleanup( std::string status_msg = std::string()) ;

// event handlers
static void HandleKeyEvent( SDL_Event* event) ;
Expand Down
Loading

0 comments on commit 951ecbe

Please sign in to comment.