- uint32_t chn;
- uint32_t x;
- int ret = -1;
- jack_nframes_t this_nframes;
-
- /* This is not required to be RT-safe because we are running while freewheeling */
-
- if (spec->do_freewheel == false) {
-
- /* first time in export function: get set up */
-
- if (prepare_to_export (*spec)) {
- spec->running = false;
- spec->status = -1;
- return -1;
- }
-
- spec->do_freewheel = true;
- }
-
- if (!_exporting) {
- /* finished, but still freewheeling */
- process_without_events (nframes);
- return 0;
- }
-
- if (!spec->running || spec->stop || (this_nframes = min ((spec->end_frame - spec->pos), nframes)) == 0) {
- process_without_events (nframes);
- return stop_audio_export (*spec);
- }
-
- /* make sure we've caught up with disk i/o, since
- we're running faster than realtime c/o JACK.
- */
-
- wait_till_butler_finished ();
-
- /* do the usual stuff */
-
- process_without_events (nframes);
-
- /* and now export the results */
-
- nframes = this_nframes;
-
- memset (spec->dataF, 0, sizeof (spec->dataF[0]) * nframes * spec->channels);
-
- /* foreach output channel ... */
-
- for (chn = 0; chn < spec->channels; ++chn) {
-
- AudioExportPortMap::iterator mi = spec->port_map.find (chn);
-
- if (mi == spec->port_map.end()) {
- /* no ports exported to this channel */
- continue;
- }
-
- vector<PortChannelPair>& mapped_ports ((*mi).second);
-
- for (vector<PortChannelPair>::iterator t = mapped_ports.begin(); t != mapped_ports.end(); ++t) {
-
- /* OK, this port's output is supposed to appear on this channel
- */
-
- Port* port = (*t).first;
- Sample* port_buffer = port->get_buffer (nframes);
-
- /* now interleave the data from the channel into the float buffer */
-
- for (x = 0; x < nframes; ++x) {
- spec->dataF[chn+(x*spec->channels)] += (float) port_buffer[x];
- }
- }
- }