Skip to content

Commit

Permalink
fixing d34bbfa
Browse files Browse the repository at this point in the history
  • Loading branch information
00sapo committed Jul 23, 2021
1 parent aac9f8d commit 39b8ada
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 0 additions & 2 deletions pycarla/audiorecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ def __init__(self):

# a simple callback that ends the processing if
# carla disconnects
global recorder_unregister_callback

@self.client.set_client_registration_callback
def recorder_unregister_callback(name, register):
if 'carla' in name.lower() and not register:
Expand Down
26 changes: 13 additions & 13 deletions pycarla/carla.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ def start(self):
# starting Carla
self.__make_carla_popen(proj_path)

self.client = jack.Client("pycarla")

# a simple callback that restart carla if
# carla disconnects
@self.client.set_process_callback
def carla_process(frames):
if (self.client.last_frame_time // frames) % 8 == 0:
if not self.exists():
print("Carla doesn't exists anymore, restarting it")
self.restart_carla()
self.error = True

# waiting
start = time.time()
READY = self.exists()
Expand All @@ -175,19 +187,7 @@ def start(self):
start = time.time()
time.sleep(0.1)

self.client = jack.Client("pycarla")

global carla_unregister_callback

# a simple callback that restart carla if
# carla disconnects
@self.client.set_process_callback
def carla_process(frames):
if (self.client.last_time_frames / frames) % 8 == 0:
if not self.exists():
print("Carla doesn't exists anymore, restarting it")
self.restart_carla()
self.error = True
# activate AFTER having started the Carla process
self.client.activate()

def kill_carla(self):
Expand Down
3 changes: 1 addition & 2 deletions pycarla/midiplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ def __init__(self):
For now, only one Carla instance should be active.
"""
super().__init__("MIDIPlayer")

# a simple callback that ends the processing if
# carla disconnects
global player_unregister_callback

@self.client.set_client_registration_callback
def player_unregister_callback(name, register):
if 'carla' in name.lower() and not register:
Expand Down

0 comments on commit 39b8ada

Please sign in to comment.