Merged with trunk R846
[ardour.git] / libs / ardour / session_timefx.cc
index ee751b9af7c73aeb11ae1ebe97b1b54b8c5baba5..82fd25ddb28886b5d1ed34d7ac9e57b6b2e69c49 100644 (file)
@@ -33,6 +33,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace soundtouch;
 
 AudioRegion*
@@ -95,10 +96,15 @@ Session::tempoize_region (TimeStretchRequest& tsr)
                for (uint32_t i = 0; i < sources.size(); ++i) {
                        gain_t gain_buffer[bufsize];
                        Sample buffer[bufsize];
-                       char   workbuf[bufsize*4];
                        jack_nframes_t pos = 0;
                        jack_nframes_t this_read = 0;
 
+                       AudioSource* const asrc = dynamic_cast<AudioSource*>(sources[i]);
+                       if (!asrc) {
+                               cerr << "FIXME: TimeFX for non-audio" << endl;
+                               continue;
+                       }
+
                        st.clear();
                        while (tsr.running && pos < tsr.region->length()) {
                                jack_nframes_t this_time;
@@ -109,7 +115,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
                                   not the ones currently in use, in case it's already been 
                                   subject to timefx.  */
 
-                               if ((this_read = tsr.region->master_read_at (buffer, buffer, gain_buffer, workbuf, pos + tsr.region->position(), this_time)) != this_time) {
+                               if ((this_read = tsr.region->master_read_at (buffer, buffer, gain_buffer, pos + tsr.region->position(), this_time)) != this_time) {
                                        error << string_compose (_("tempoize: error reading data from %1"), sources[i]->name()) << endmsg;
                                        goto out;
                                }
@@ -122,7 +128,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
                                st.putSamples (buffer, this_read);
                        
                                while ((this_read = st.receiveSamples (buffer, bufsize)) > 0 && tsr.running) {
-                                       if (sources[i]->write (buffer, this_read, workbuf) != this_read) {
+                                       if (asrc->write (buffer, this_read) != this_read) {
                                                error << string_compose (_("error writing tempo-adjusted data to %1"), sources[i]->name()) << endmsg;
                                                goto out;
                                        }
@@ -134,7 +140,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
                        }
                
                        while (tsr.running && (this_read = st.receiveSamples (buffer, bufsize)) > 0) {
-                               if (sources[i]->write (buffer, this_read, workbuf) != this_read) {
+                               if (asrc->write (buffer, this_read) != this_read) {
                                        error << string_compose (_("error writing tempo-adjusted data to %1"), sources[i]->name()) << endmsg;
                                        goto out;
                                }