OSC: Fix some uninitialized values.

This commit is contained in:
Jonathan Moore Liles 2012-05-03 22:57:54 -07:00
parent f279f49b1e
commit ac30a5a4e2
3 changed files with 66 additions and 41 deletions

View File

@ -48,8 +48,6 @@
#include "OSC/Endpoint.H"
#include <lo/lo.h>
#include "OSC/Endpoint.H"
const double STATUS_UPDATE_FREQ = 0.2f;
extern char *user_config_dir;

View File

@ -56,6 +56,22 @@ namespace OSC
int Signal::next_id = 0;
Signal::Signal ( const char *path, Direction dir )
{
_direction = dir;
_path = strdup( path );
_id = ++next_id;
_value = 0.0f;
_endpoint = NULL;
_peer = NULL;
_path = 0;
_documentation = 0;
_user_data = 0;
_connection_state_callback = 0;
_connection_state_userdata = 0;
}
Signal::~Signal ( )
{
if ( _endpoint )
@ -140,7 +156,9 @@ namespace OSC
return r;
}
void
Endpoint::error_handler(int num, const char *msg, const char *path)
{
@ -149,6 +167,11 @@ namespace OSC
Endpoint::Endpoint ( )
{
_peer_scan_complete_callback = 0;
_peer_scan_complete_userdata = 0;
_server = 0;
_name = 0;
owner = 0;
}
int
@ -164,7 +187,6 @@ namespace OSC
return -1;
}
add_method( "/signal/hello", "ss", &Endpoint::osc_sig_hello, this, "" );
add_method( "/signal/connect", "ii", &Endpoint::osc_sig_connect, this, "" );
add_method( "/signal/disconnect", "ii", &Endpoint::osc_sig_disconnect, this, "" );
@ -183,7 +205,11 @@ namespace OSC
Endpoint::~Endpoint ( )
{
// lo_server_thread_free( _st );
if ( _server )
{
lo_server_free( _server );
_server = 0;
}
}
OSC::Signal *
@ -248,6 +274,8 @@ namespace OSC
void
Endpoint::hello ( const char *url )
{
assert( name() );
lo_address addr = lo_address_new_from_url ( url );
char *our_url = this->url();
@ -260,6 +288,7 @@ namespace OSC
int
Endpoint::osc_sig_hello ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data )
{
Endpoint *ep = (Endpoint*)user_data;
const char *peer_name = &argv[0]->s;
@ -271,8 +300,15 @@ namespace OSC
{
ep->scan_peer( peer_name, peer_url );
if ( ep->name() )
{
ep->hello( peer_url );
}
else
{
DMESSAGE( "Not sending hello because we don't have a name yet!" );
}
}
return 0;
}

View File

@ -166,22 +166,7 @@ namespace OSC
public:
Signal ( const char *path, Direction dir )
{
_direction = dir;
_path = strdup( path );
_id = ++next_id;
_value = 0.0f;
_endpoint = NULL;
_peer = NULL;
}
void connection_state_callback ( void(*_cb)(OSC::Signal *, void*), void *userdata)
{
_connection_state_callback = _cb;
_connection_state_userdata = userdata;
}
Signal ( const char *path, Direction dir );
~Signal ( );
static Signal *get_peer_signal_by_id ( Peer *p, int signal_id );
@ -203,6 +188,13 @@ namespace OSC
_value = default_value;
}
void connection_state_callback ( void(*_cb)(OSC::Signal *, void*), void *userdata)
{
_connection_state_callback = _cb;
_connection_state_userdata = userdata;
}
const Parameter_Limits& parameter_limits ( void ) const { return _parameter_limits; }
const char *path ( void ) const { return _path; }
@ -239,8 +231,21 @@ namespace OSC
class Endpoint
{
static void error_handler(int num, const char *msg, const char *path);
Thread _thread;
// lo_server_thread _st;
lo_server _server;
std::list<Peer*> _peers;
std::list<Signal*> _signals;
std::list<Method*> _methods;
void (*_peer_scan_complete_callback)(void*);
void *_peer_scan_complete_userdata;
char *_name;
static void error_handler(int num, const char *msg, const char *path);
static int osc_reply ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
@ -256,14 +261,7 @@ namespace OSC
void scan_peer ( const char *name, const char *url );
Thread _thread;
// lo_server_thread _st;
lo_server _server;
std::list<Peer*> _peers;
std::list<Signal*> _signals;
std::list<Method*> _methods;
private:
static void *osc_thread ( void *arg );
void osc_thread ( void );
@ -278,26 +276,22 @@ namespace OSC
static Signal *find_target_by_peer_address ( std::list<Signal*> *l, lo_address addr );
char *_name;
void del_signal ( Signal *signal );
void send_signal_rename_notifications( Signal *s );
void (*_peer_scan_complete_callback)(void*);
void *_peer_scan_complete_userdata;
public:
// can be used to point back to owning object.
void *owner;
void list_peer_signals ( void (*callback) (const char *, const OSC::Signal *, void * ), void *v );
int init ( int proto, const char *port = 0 );
Endpoint ( );
~Endpoint ( );
bool disconnect_signal ( OSC::Signal *s, OSC::Signal *d );
bool disconnect_signal ( OSC::Signal *s, const char *peer_name, const char *signal_path );
bool connect_signal ( OSC::Signal *s, OSC::Signal *d );
@ -360,9 +354,6 @@ namespace OSC
int send ( lo_address to, const char *path, const char *v1, const char *v2, const char *v3, int v4, float v5, float v6, float v7 );
// can be used to point back to owning object.
void *owner;
void peer_scan_complete_callback ( void(*_cb)(void*), void *userdata)
{
_peer_scan_complete_callback = _cb;