Merge big changes (mostly Controllable) from trunk
[ardour.git] / libs / ardour / session_process.cc
1 /*
2     Copyright (C) 1999-2002 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #include <cmath>
22 #include <cerrno>
23 #include <algorithm>
24 #include <unistd.h>
25
26 #include <pbd/error.h>
27
28 #include <glibmm/thread.h>
29
30 #include <ardour/ardour.h>
31 #include <ardour/session.h>
32 #include <ardour/timestamps.h>
33 #include <ardour/audio_diskstream.h>
34 #include <ardour/audioengine.h>
35 #include <ardour/slave.h>
36 #include <ardour/auditioner.h>
37 #include <ardour/cycles.h>
38 #include <ardour/cycle_timer.h>
39
40 #include <midi++/manager.h>
41
42 #include "i18n.h"
43
44 using namespace ARDOUR;
45 using namespace PBD;
46 using namespace std;
47
48 void
49 Session::process (jack_nframes_t nframes)
50 {
51         MIDI::Manager::instance()->cycle_start(nframes);
52
53         if (synced_to_jack() && waiting_to_start) {
54                 if ( _engine.transport_state() == AudioEngine::TransportRolling) {
55                         actually_start_transport ();
56                 }
57         }
58
59         if (non_realtime_work_pending()) {
60                 if (g_atomic_int_get (&butler_should_do_transport_work) == 0) {
61                         post_transport ();
62                 } 
63         } 
64         
65         (this->*process_function) (nframes);
66         
67         MIDI::Manager::instance()->cycle_end();
68
69         SendFeedback (); /* EMIT SIGNAL */
70 }
71
72 void
73 Session::prepare_diskstreams ()
74 {
75         for (DiskstreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
76                 (*i)->prepare ();
77         }
78 }
79
80 int
81 Session::no_roll (jack_nframes_t nframes, jack_nframes_t offset)
82 {
83         jack_nframes_t end_frame = _transport_frame + nframes;
84         int ret = 0;
85         bool declick = get_transport_declick_required();
86
87         if (_click_io) {
88                 _click_io->silence (nframes, offset);
89         }
90
91         /* XXX we're supposed to have the route_lock while doing this.
92            this is really bad ...
93         */
94
95         if (g_atomic_int_get (&processing_prohibited)) {
96                 for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
97                         (*i)->silence (nframes, offset);
98                 }
99                 return 0;
100         }
101
102         for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
103                 
104                 if ((*i)->hidden()) {
105                         continue;
106                 }
107                 
108                 (*i)->set_pending_declick (declick);
109                 
110                 if ((*i)->no_roll (nframes, _transport_frame, end_frame, offset, non_realtime_work_pending(), 
111                                    actively_recording(), declick)) {
112                         error << string_compose(_("Session: error in no roll for %1"), (*i)->name()) << endmsg;
113                         ret = -1;
114                         break;
115                 }
116         }
117
118         return ret;
119 }
120
121 int
122 Session::process_routes (jack_nframes_t nframes, jack_nframes_t offset)
123 {
124         bool record_active;
125         int  declick = get_transport_declick_required();
126         bool rec_monitors = get_rec_monitors_input();
127
128         if (transport_sub_state & StopPendingCapture) {
129                 /* force a declick out */
130                 declick = -1;
131         }
132
133         record_active = actively_recording(); // || (get_record_enabled() && get_punch_in());
134
135         for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
136
137                 int ret;
138
139                 if ((*i)->hidden()) {
140                         continue;
141                 }
142
143                 (*i)->set_pending_declick (declick);
144
145                 if ((ret = (*i)->roll (nframes, _transport_frame, _transport_frame + nframes, offset, declick, record_active, rec_monitors)) < 0) {
146
147                         /* we have to do this here. Route::roll() for an AudioTrack will have called AudioDiskstream::process(),
148                            and the DS will expect AudioDiskstream::commit() to be called. but we're aborting from that
149                            call path, so make sure we release any outstanding locks here before we return failure.
150                         */
151
152                         for (DiskstreamList::iterator ids = diskstreams.begin(); ids != diskstreams.end(); ++ids) {
153                                 (*ids)->recover ();
154                         }
155
156                         stop_transport ();
157                         return -1;
158                 } 
159         }
160
161         return 0;
162 }
163
164 int
165 Session::silent_process_routes (jack_nframes_t nframes, jack_nframes_t offset)
166 {
167         bool record_active = actively_recording();
168         int  declick = get_transport_declick_required();
169         bool rec_monitors = get_rec_monitors_input();
170
171         if (transport_sub_state & StopPendingCapture) {
172                 /* force a declick out */
173                 declick = -1;
174         }
175
176         for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
177
178                 int ret;
179
180                 if ((*i)->hidden()) {
181                         continue;
182                 }
183
184                 if ((ret = (*i)->silent_roll (nframes, _transport_frame, _transport_frame + nframes, offset, record_active, rec_monitors)) < 0) {
185                         
186                         /* we have to do this here. Route::roll() for an AudioTrack will have called AudioDiskstream::process(),
187                            and the DS will expect AudioDiskstream::commit() to be called. but we're aborting from that
188                            call path, so make sure we release any outstanding locks here before we return failure.
189                         */
190
191                         for (DiskstreamList::iterator ids = diskstreams.begin(); ids != diskstreams.end(); ++ids) {
192                                 (*ids)->recover ();
193                         }
194
195                         stop_transport ();
196                         return -1;
197                 } 
198         }
199
200         return 0;
201 }
202
203 void
204 Session::commit_diskstreams (jack_nframes_t nframes, bool &needs_butler)
205 {
206         int dret;
207         float pworst = 1.0f;
208         float cworst = 1.0f;
209
210         for (DiskstreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
211
212                 if ((*i)->hidden()) {
213                         continue;
214                 }
215                 
216                 /* force all diskstreams not handled by a Route to call do their stuff.
217                  */
218
219                 if ((dret = (*i)->process (_transport_frame, nframes, 0, actively_recording(), get_rec_monitors_input())) == 0) {
220                         if ((*i)->commit (nframes)) {
221                                 needs_butler = true;
222                         }
223
224                 } else if (dret < 0) {
225                         (*i)->recover();
226                 }
227                 
228                 pworst = min (pworst, (*i)->playback_buffer_load());
229                 cworst = min (cworst, (*i)->capture_buffer_load());
230         }
231
232         uint32_t pmin = g_atomic_int_get (&_playback_load);
233         uint32_t pminold = g_atomic_int_get (&_playback_load_min);
234         uint32_t cmin = g_atomic_int_get (&_capture_load);
235         uint32_t cminold = g_atomic_int_get (&_capture_load_min);
236
237         g_atomic_int_set (&_playback_load, (uint32_t) floor (pworst * 100.0f));
238         g_atomic_int_set (&_capture_load, (uint32_t) floor (cworst * 100.0f));
239         g_atomic_int_set (&_playback_load_min, min (pmin, pminold));
240         g_atomic_int_set (&_capture_load_min, min (cmin, cminold));
241
242         if (actively_recording()) {
243                 set_dirty();
244         }
245 }
246
247
248 void
249 Session::process_with_events (jack_nframes_t nframes)
250 {
251         Event*         ev;
252         jack_nframes_t this_nframes;
253         jack_nframes_t end_frame;
254         jack_nframes_t offset;
255         jack_nframes_t stop_limit;
256         long           frames_moved;
257         bool           session_needs_butler = false;
258
259         if (auditioner) {
260                 auditioner->silence (nframes, 0);
261         }
262
263         while (pending_events.read (&ev, 1) == 1) {
264                 merge_event (ev);
265         }
266
267         /* if we are not in the middle of a state change,
268            and there are immediate events queued up,
269            process them. 
270         */
271
272         while (!non_realtime_work_pending() && !immediate_events.empty()) {
273                 Event *ev = immediate_events.front ();
274                 immediate_events.pop_front ();
275                 process_event (ev);
276         }
277
278         /* Events caused a transport change, send an MTC Full Frame (SMPTE) message.
279          * This is sent whether rolling or not, to give slaves an idea of ardour time
280          * on locates (and allow slow slaves to position and prepare for rolling)
281          */
282         if (_send_smpte_update) {
283                 send_full_time_code(nframes);
284         }
285
286         if (!process_can_proceed()) {
287                 no_roll (nframes, 0);
288                 return;
289         }
290
291         if (events.empty() || next_event == events.end()) {
292                 process_without_events (nframes);
293                 return;
294         }
295
296         end_frame = _transport_frame + nframes;
297
298         {
299                 Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK);
300                 Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK);
301                 
302                 Event* this_event;
303                 Events::iterator the_next_one;
304
305                 if (!rm.locked() || !dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) {
306                         no_roll (nframes, 0);
307                         return;
308                 }
309                 
310                 if (!_exporting && _slave) {
311                         if (!follow_slave (nframes, 0)) {
312                                 return;
313                         }
314                 } 
315
316                 if (_transport_speed == 0) {
317                         no_roll (nframes, 0);
318                         return;
319                 }
320         
321                 send_midi_time_code_for_cycle(nframes);
322
323                 if (actively_recording()) {
324                         stop_limit = max_frames;
325                 } else {
326
327                         if (Config->get_stop_at_session_end()) {
328                                 stop_limit = current_end_frame();
329                         } else {
330                                 stop_limit = max_frames;
331                         }
332                 }
333
334                 if (maybe_stop (stop_limit)) {
335                         no_roll (nframes, 0);
336                         return;
337                 } 
338
339                 this_event = *next_event;
340                 the_next_one = next_event;
341                 ++the_next_one;
342
343                 offset = 0;
344
345                 while (nframes) {
346
347                         if (this_event == 0 || this_event->action_frame > end_frame || this_event->action_frame < _transport_frame) {
348
349                                 this_nframes = nframes;
350                                 
351                         } else {
352                                 
353                                 /* compute nframes to next event */
354
355                                 if (this_event->action_frame < end_frame) {
356                                         this_nframes = nframes - (end_frame - this_event->action_frame);
357                                 } else {
358                                         this_nframes = nframes;
359                                 }
360                         }
361
362                         if (this_nframes) {
363                                 
364                                 click (_transport_frame, nframes, offset);
365                                 
366                                 /* now process frames between now and the first event in this block */
367                                 prepare_diskstreams ();
368
369                                 if (process_routes (this_nframes, offset)) {
370                                         no_roll (nframes, 0);
371                                         return;
372                                 }
373                                 
374                                 commit_diskstreams (this_nframes, session_needs_butler);
375
376                                 nframes -= this_nframes;
377                                 offset += this_nframes;
378                                 
379                                 frames_moved = (jack_nframes_t) floor (_transport_speed * this_nframes);
380                         
381                                 if (frames_moved < 0) {
382                                         decrement_transport_position (-frames_moved);
383                                 } else {
384                                         increment_transport_position (frames_moved);
385                                 }
386
387                                 maybe_stop (stop_limit);
388                                 check_declick_out ();
389                         }
390
391                         /* now handle this event and all others scheduled for the same time */
392                         
393                         while (this_event && this_event->action_frame == _transport_frame) {
394                                 process_event (this_event);
395
396                                 if (the_next_one == events.end()) {
397                                         this_event = 0;
398                                 } else {
399                                         this_event = *the_next_one;
400                                         ++the_next_one;
401                                 }
402                         } 
403
404                         /* if an event left our state changing, do the right thing */
405
406                         if (non_realtime_work_pending()) {
407                                 no_roll (nframes, offset);
408                                 break;
409                         }
410
411                         /* this is necessary to handle the case of seamless looping */
412                         /* not sure if it will work in conjuction with varispeed */
413                         end_frame = _transport_frame + nframes;
414                         
415                 }
416
417                 set_next_event ();
418
419         } /* implicit release of route lock */
420
421         if (session_needs_butler)
422                 summon_butler ();
423 }
424
425 void
426 Session::reset_slave_state ()
427 {
428         average_slave_delta = 1800;
429         delta_accumulator_cnt = 0;
430         have_first_delta_accumulator = false;
431         slave_state = Stopped;
432 }
433
434 bool
435 Session::transport_locked () const
436 {
437         Slave* sl = _slave;
438
439         if (!locate_pending() && ((_slave_type == None) || (sl && sl->ok() && sl->locked()))) {
440                 return true;
441         }
442
443         return false;
444 }
445
446 bool
447 Session::follow_slave (jack_nframes_t nframes, jack_nframes_t offset)
448 {
449         float slave_speed;
450         jack_nframes_t slave_transport_frame;
451         jack_nframes_t this_delta;
452         int dir;
453         bool starting;
454
455         if (!_slave->ok()) {
456                 stop_transport ();
457                 set_slave_source (None, 0);
458                 goto noroll;
459         }
460         
461         _slave->speed_and_position (slave_speed, slave_transport_frame);
462
463         if (!_slave->locked()) {
464                 goto noroll;
465         }
466
467         if (slave_transport_frame > _transport_frame) {
468                 this_delta = slave_transport_frame - _transport_frame;
469                 dir = 1;
470         } else {
471                 this_delta = _transport_frame - slave_transport_frame;
472                 dir = -1;
473         }
474
475         if ((starting = _slave->starting())) {
476                 slave_speed = 0.0f;
477         }
478
479 #if 0
480         cerr << "delta = " << (int) (dir * this_delta)
481              << " speed = " << slave_speed 
482              << " ts = " << _transport_speed 
483              << " M@"<< slave_transport_frame << " S@" << _transport_frame 
484              << " avgdelta = " << average_slave_delta 
485              << endl;
486 #endif  
487
488         if (Config->get_timecode_source_is_synced()) {
489
490                 /* if the TC source is synced, then we assume that its 
491                    speed is binary: 0.0 or 1.0
492                 */
493
494                 if (slave_speed != 0.0f) {
495                         slave_speed = 1.0f;
496                 } 
497
498         } else {
499
500                 /* TC source is able to drift relative to us (slave)
501                    so we need to keep track of the drift and adjust
502                    our speed to remain locked.
503                 */
504
505                 if (delta_accumulator_cnt >= delta_accumulator_size) {
506                         have_first_delta_accumulator = true;
507                         delta_accumulator_cnt = 0;
508                 }
509
510                 if (delta_accumulator_cnt != 0 || this_delta < _current_frame_rate) {
511                         delta_accumulator[delta_accumulator_cnt++] = dir*this_delta;
512                 }
513                 
514                 if (have_first_delta_accumulator) {
515                         average_slave_delta = 0;
516                         for (int i = 0; i < delta_accumulator_size; ++i) {
517                                 average_slave_delta += delta_accumulator[i];
518                         }
519                         average_slave_delta /= delta_accumulator_size;
520                         if (average_slave_delta < 0) {
521                                 average_dir = -1;
522                                 average_slave_delta = -average_slave_delta;
523                         } else {
524                                 average_dir = 1;
525                         }
526                         // cerr << "avgdelta = " << average_slave_delta*average_dir << endl;
527                 }
528         }
529
530         if (slave_speed != 0.0f) {
531
532                 /* slave is running */
533
534                 switch (slave_state) {
535                 case Stopped:
536                         if (_slave->requires_seekahead()) {
537                                 slave_wait_end = slave_transport_frame + _current_frame_rate;
538                                 locate (slave_wait_end, false, false);
539                                 slave_state = Waiting;
540                                 starting = true;
541
542                         } else {
543
544                                 slave_state = Running;
545
546                                 Location* al = _locations.auto_loop_location();
547
548                                 if (al && auto_loop && (slave_transport_frame < al->start() || slave_transport_frame > al->end())) {
549                                         // cancel looping
550                                         request_auto_loop(false);
551                                 }
552
553                                 if (slave_transport_frame != _transport_frame) {
554                                         locate (slave_transport_frame, false, false);
555                                 }
556                         }
557                         break;
558
559                 case Waiting:
560                         break;
561
562                 default:
563                         break;
564
565                 }
566
567                 if (slave_state == Waiting) {
568
569                         // cerr << "waiting at " << slave_transport_frame << endl;
570                         Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK);
571                         
572                         if (dsm.locked() && slave_transport_frame >= slave_wait_end) {
573                                 // cerr << "\tstart at " << _transport_frame << endl;
574
575                                 slave_state = Running;
576
577                                 bool ok = true;
578                                 jack_nframes_t frame_delta = slave_transport_frame - _transport_frame;
579                                 
580                                 for (DiskstreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
581                                         if (!(*i)->can_internal_playback_seek (frame_delta)) {
582                                                 ok = false;
583                                                 break;
584                                         }
585                                 }
586
587                                 if (ok) {
588                                         for (DiskstreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
589                                                 (*i)->internal_playback_seek (frame_delta);
590                                         }
591                                         _transport_frame += frame_delta;
592                                        
593                                 } else {
594                                         // cerr << "cannot micro-seek\n";
595                                         /* XXX what? */
596                                 }
597
598                                 memset (delta_accumulator, 0, sizeof (jack_nframes_t) * delta_accumulator_size);
599                                 average_slave_delta = 0;
600                                 this_delta = 0;
601                         }
602                 }
603                 
604                 if (slave_state == Running && _transport_speed == 0.0f) {
605                         
606                         // cerr << "slave starts transport\n";
607                         
608                         start_transport ();
609                 } 
610
611         } else {
612
613                 /* slave has stopped */
614
615                 if (_transport_speed != 0.0f) {
616
617                         // cerr << "slave stops transport: " << slave_speed << " frame: " << slave_transport_frame 
618                         // << " tf = " << _transport_frame
619                         // << endl;
620                         
621                         if (_slave_type == JACK) {
622                                 last_stop_frame = _transport_frame;
623                         }
624
625                         stop_transport();
626                 }
627
628                 if (slave_transport_frame != _transport_frame) {
629                         // cerr << "slave stopped, move to " << slave_transport_frame << endl;
630                         force_locate (slave_transport_frame, false);
631                 }
632
633                 slave_state = Stopped;
634         }
635
636         if (slave_state == Running && !Config->get_timecode_source_is_synced()) {
637
638
639                 if (_transport_speed != 0.0f) {
640                         
641                         /* 
642                            note that average_dir is +1 or -1 
643                         */
644                         
645                         const float adjust_seconds = 1.0f;
646                         float delta;
647
648                         //if (average_slave_delta == 0) {
649                                 delta = this_delta;
650                                 delta *= dir;
651 //                      } else {
652 //                              delta = average_slave_delta;
653 //                              delta *= average_dir;
654 //                      }
655
656                         float adjusted_speed = slave_speed +
657                                 (delta / (adjust_seconds * _current_frame_rate));
658                         
659                         // cerr << "adjust using " << delta
660                         // << " towards " << adjusted_speed
661                         // << " ratio = " << adjusted_speed / slave_speed
662                         // << " current = " << _transport_speed
663                         // << " slave @ " << slave_speed
664                         // << endl;
665                         
666                         request_transport_speed (adjusted_speed);
667                         
668 #if 1
669                         if ((jack_nframes_t) average_slave_delta > _slave->resolution()) {
670                                 // cerr << "not locked\n";
671                                 goto silent_motion;
672                         }
673 #endif
674                 }
675         } 
676
677         if (!starting && !non_realtime_work_pending()) {
678                 /* speed is set, we're locked, and good to go */
679                 return true;
680         }
681
682   silent_motion:
683
684         if (slave_speed && _transport_speed) {
685
686                 /* something isn't right, but we should move with the master
687                    for now.
688                 */
689
690                 bool need_butler;
691                 
692                 Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK);
693                 if (!dsm.locked()) {
694                         goto noroll;
695                 }
696
697                 
698                 prepare_diskstreams ();
699                 silent_process_routes (nframes, offset);
700                 commit_diskstreams (nframes, need_butler);
701
702                 if (need_butler) {
703                         summon_butler ();
704                 }
705                 
706                 jack_nframes_t frames_moved = (long) floor (_transport_speed * nframes);
707                 
708                 if (frames_moved < 0) {
709                         decrement_transport_position (-frames_moved);
710                 } else {
711                         increment_transport_position (frames_moved);
712                 }
713                 
714                 jack_nframes_t stop_limit;
715                 
716                 if (actively_recording()) {
717                         stop_limit = max_frames;
718                 } else {
719                         if (Config->get_stop_at_session_end()) {
720                                 stop_limit = current_end_frame();
721                         } else {
722                                 stop_limit = max_frames;
723                         }
724                 }
725
726                 maybe_stop (stop_limit);
727         }
728
729   noroll:
730         /* don't move at all */
731         no_roll (nframes, 0);
732         return false;
733 }
734
735 void
736 Session::process_without_events (jack_nframes_t nframes)
737 {
738         bool session_needs_butler = false;
739         jack_nframes_t stop_limit;
740         long frames_moved;
741         
742         {
743                 Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK);
744                 Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK);
745
746                 if (!rm.locked() || !dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) {
747                         no_roll (nframes, 0);
748                         return;
749                 }
750
751                 if (!_exporting && _slave) {
752                         if (!follow_slave (nframes, 0)) {
753                                 return;
754                         }
755                 } 
756
757                 if (_transport_speed == 0) {
758                         no_roll (nframes, 0);
759                         return;
760                 }
761         
762                 send_midi_time_code_for_cycle(nframes);
763                 
764                 if (actively_recording()) {
765                         stop_limit = max_frames;
766                 } else {
767                         if (Config->get_stop_at_session_end()) {
768                                 stop_limit = current_end_frame();
769                         } else {
770                                 stop_limit = max_frames;
771                         }
772                 }
773                 
774                 if (maybe_stop (stop_limit)) {
775                         no_roll (nframes, 0);
776                         return;
777                 } 
778
779                 click (_transport_frame, nframes, 0);
780
781                 prepare_diskstreams ();
782         
783                 frames_moved = (long) floor (_transport_speed * nframes);
784
785                 if (process_routes (nframes, 0)) {
786                         no_roll (nframes, 0);
787                         return;
788                 }
789
790                 commit_diskstreams (nframes, session_needs_butler);
791
792                 if (frames_moved < 0) {
793                         decrement_transport_position (-frames_moved);
794                 } else {
795                         increment_transport_position (frames_moved);
796                 }
797                 
798                 maybe_stop (stop_limit);
799                 check_declick_out ();
800
801         } /* implicit release of route lock */
802
803         if (session_needs_butler)
804                 summon_butler ();
805 }
806
807 void
808 Session::process_audition (jack_nframes_t nframes)
809 {
810         Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK);
811         Event* ev;
812
813         if (rm.locked()) {
814                 for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
815                         if (!(*i)->hidden()) {
816                                 (*i)->silence (nframes, 0);
817                         }
818                 }
819         }
820         
821         if (auditioner->play_audition (nframes) > 0) {
822                 summon_butler ();
823         } 
824
825         while (pending_events.read (&ev, 1) == 1) {
826                 merge_event (ev);
827         }
828
829         /* if we are not in the middle of a state change,
830            and there are immediate events queued up,
831            process them. 
832         */
833
834         while (!non_realtime_work_pending() && !immediate_events.empty()) {
835                 Event *ev = immediate_events.front ();
836                 immediate_events.pop_front ();
837                 process_event (ev);
838         }
839
840         if (!auditioner->active()) {
841                 process_function = &Session::process_with_events;
842         }
843 }
844