Skip to content

Commit

Permalink
Now we callback to the application with a string.
Browse files Browse the repository at this point in the history
  • Loading branch information
rec committed Dec 28, 2014
1 parent 6284425 commit d80051b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
9 changes: 3 additions & 6 deletions code/cpp/echomesh/util/EchomeshApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace echomesh {

namespace {

VoidCaller CALLBACK;
StringCaller CALLBACK;
void* USER_DATA;

CriticalSection LOCK;
Expand All @@ -21,7 +21,7 @@ class ApplicationBase : public juce::JUCEApplicationBase {
virtual bool moreThanOneInstanceAllowed() { return false; }
virtual void initialise(const String&) {
if (CALLBACK and USER_DATA)
CALLBACK(USER_DATA);
CALLBACK(USER_DATA, "start");
}
virtual void shutdown() {}
virtual void anotherInstanceStarted(const String&) {}
Expand All @@ -41,7 +41,7 @@ juce::JUCEApplicationBase* juce_CreateApplication() {

} // namespace

void startApplication(VoidCaller cb, void* userData) {
void startApplication(StringCaller cb, void* userData) {
{
ScopedLock l(LOCK);
STARTED = true;
Expand All @@ -58,7 +58,4 @@ bool isStarted() {
return STARTED;
}

string timestamp() { return __TIME__; }
string datestamp() { return __DATE__; }

} // namespace echomesh
2 changes: 1 addition & 1 deletion code/cpp/echomesh/util/EchomeshApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace echomesh {

void startApplication(VoidCaller, void*);
void startApplication(StringCaller, void*);
bool isStarted();

string timestamp();
Expand Down
9 changes: 2 additions & 7 deletions code/cpp/echomesh/util/EchomeshApplication.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ from libcpp cimport bool
from libcpp.string cimport string

cdef extern from "echomesh/util/EchomeshApplication.h" namespace "echomesh":
void startApplication(VoidCaller cb, void* user_data) nogil
void startApplication(StringCaller cb, void* user_data) nogil
bool isStarted()
string timestamp()
string datestamp()

cdef extern from "echomesh/util/Quit.h" namespace "echomesh":
void quit() nogil
Expand All @@ -18,13 +16,10 @@ def start_application(f):
else:
callback = NULL
with nogil:
startApplication(perform_callback, callback)
startApplication(perform_string_callback, callback)

def stop_application():
quit()

def is_started():
return isStarted()

def build_timestamp():
return timestamp(), datestamp()
6 changes: 5 additions & 1 deletion code/python/echomesh/Instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def do_quit():
self.score_master = ScoreMaster.ScoreMaster()
self.peers = Peers.Peers(self)
self.socket = PeerSocket.PeerSocket(self, self.peers)
self.callback = self.after_server_starts
# self.callback = self.after_server_starts

self.display = Display.display(self.callback)
self.keyboard_runnable = self.osc = None
Expand Down Expand Up @@ -97,6 +97,10 @@ def main(self):
time.sleep(self.timeout)
# Prevents crashes if you start and stop echomesh very fast.

def callback(self, data):
if data == 'start':
self.after_server_starts()

def after_server_starts(self):
if cechomesh.LOADED:
run_after(self.run,
Expand Down

0 comments on commit d80051b

Please sign in to comment.