Skip to content

Commit

Permalink
Lang - keep old fx open after live loop has moved by waiting on synth…
Browse files Browse the repository at this point in the history
… tracker
  • Loading branch information
samaaron committed Oct 23, 2024
1 parent 4839a25 commit c000206
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/server/ruby/lib/sonicpi/lang/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2325,15 +2325,14 @@ def live_loop(name=nil, *args, &block)

# immediately reset for the next move
__system_thread_locals.set_local :sonic_pi_local_live_loop_move_to_bus_and_parent_t, nil
end

if new_bus
moved_prom = __system_thread_locals.get :sonic_pi_local_spider_thread_moved
ack_prom = __system_thread_locals.get :sonic_pi_local_spider_thread_moved_ack
# update the context
# reset tracker and send old tracker with ack
tracker = __current_tracker
__system_thread_locals.set_local(:sonic_pi_local_tracker, nil)
old_bus = __system_thread_locals.get :sonic_pi_mod_sound_synth_out_bus
__system_thread_locals.set(:sonic_pi_mod_sound_synth_out_bus, new_bus)
__system_thread_locals.set(:sonic_pi_mod_sound_job_group, new_group)
moved_prom.deliver! tracker
Expand All @@ -2350,6 +2349,7 @@ def live_loop(name=nil, *args, &block)
__live_loop_cue name if __system_thread_locals.get :sonic_pi_local_live_loop_auto_cue
res = send(ll_name, res)
end
end
end
end

Expand Down Expand Up @@ -2379,7 +2379,7 @@ def live_loop(name=nil, *args, &block)
_b, _g, t, p = __system_thread_locals(st).get(:sonic_pi_local_live_loop_move_to_bus_and_parent_t)
if p
## another live loop already registered a move, but didn't manage to swap in time - so we're going to clobber it
p.deliver! :clobbered
p.deliver! :clobbered, false
end
__system_thread_locals(st).set_local :sonic_pi_local_live_loop_auto_cue, auto_cue if st
## register our move
Expand All @@ -2391,7 +2391,7 @@ def live_loop(name=nil, *args, &block)
ct2 = Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "ll ct2 join waiter for #{name} #{st.object_id} #{__system_thread_locals(st).get(:sonic_pi_local_thread_group)}"
st.join
completed_prom.deliver! :joined
completed_prom.deliver! :joined, false
end

moved_or_clobbered = completed_prom.get
Expand Down Expand Up @@ -2419,7 +2419,8 @@ def live_loop(name=nil, *args, &block)
end
move_holding_thread_prom.deliver! true
end

tracker = new_thread_moved_prom.get
tracker.get
move_holding_thread_prom.get
end
end
Expand Down

0 comments on commit c000206

Please sign in to comment.