traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/core AudioClip.cpp AudioClip.h Res...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/core AudioClip.cpp AudioClip.h Res...
Date: Mon, 28 May 2007 21:30:14 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/28 21:30:14

Modified files:
        src/core       : AudioClip.cpp AudioClip.h ResourcesManager.cpp 
                         ResourcesManager.h Track.cpp 

Log message:
        Take into account that also during record the audiodevice 
        settings can be changed!! (do we actually want to allow that?)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ResourcesManager.cpp?cvsroot=traverso&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ResourcesManager.h?cvsroot=traverso&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Track.cpp?cvsroot=traverso&r1=1.57&r2=1.58

Patches:
Index: AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- AudioClip.cpp       25 May 2007 10:37:00 -0000      1.99
+++ AudioClip.cpp       28 May 2007 21:30:13 -0000      1.100
@@ -173,8 +173,6 @@
 
 QDomNode AudioClip::get_state( QDomDocument doc )
 {
-       Q_ASSERT(m_readSource);
-       
        QDomElement node = doc.createElement("Clip");
        node.setAttribute("trackstart", trackStartFrame);
        node.setAttribute("sourcestart", sourceStartFrame);
@@ -189,7 +187,7 @@
        node.setAttribute("sheet", m_songId );
        node.setAttribute("locked", isLocked);
 
-       node.setAttribute("source", m_readSource->get_id());
+       node.setAttribute("source", m_readSourceId);
 
        QDomNode curves = doc.createElement("Curves");
 
@@ -394,9 +392,7 @@
                return 0;
        }
 
-       Q_ASSERT(m_readSource);
-
-       if (m_invalidReadSource || (channel >= 
m_readSource->get_channel_count())) {
+       if (m_invalidReadSource) {
                return -1;
        }
 
@@ -404,6 +400,11 @@
                return 0;
        }
        
+       Q_ASSERT(m_readSource);
+       
+       if (channel >= m_readSource->get_channel_count()) {
+               return -1;
+       }
        
        nframes_t mix_pos;
        audio_sample_t* mixdown;
@@ -467,6 +468,10 @@
                }
        }
        
+       if (!m_captureBus) {
+               return;
+       }
+       
        m_length += (nframes / writeSources.size());
        
        int index = 0;
@@ -476,7 +481,7 @@
        
        WriteSource* source = writeSources.at(index);
 
-       nframes_t written = source->rb_write(captureBus->get_buffer(channel, 
nframes), nframes);
+       nframes_t written = source->rb_write(m_captureBus->get_buffer(channel, 
nframes), nframes);
 
        if (written != nframes) {
                printf("couldn't write nframes %d to recording buffer, only 
%d\n", nframes, written);
@@ -488,9 +493,10 @@
        Q_ASSERT(m_song);
        Q_ASSERT(m_track);
        
-       captureBus = audiodevice().get_capture_bus(name);
+       m_captureBusName = name;
+       get_capture_bus();
 
-       if (!captureBus) {
+       if (!m_captureBus) {
                info().critical(tr("Unable to Record to Track"));
                info().warning(tr("AudioDevice doesn't have this Capture Bus: 
%1 (Track %2)").
                                arg(name.data()).arg(m_track->get_id()) );
@@ -498,7 +504,7 @@
        }
 
        int channelnumber = 0;
-       int channelcount = captureBus->get_channel_count();
+       int channelcount = m_captureBus->get_channel_count();
        if (! (m_track->capture_left_channel() && 
m_track->capture_right_channel()) ) {
                channelcount = 1;
        }
@@ -510,7 +516,7 @@
        resources_manager()->set_source_for_clip(this, rs);
        QString sourceid = QString::number(rs->get_id());
        
-       for (int chan=0; chan<captureBus->get_channel_count(); chan++) {
+       for (int chan=0; chan<m_captureBus->get_channel_count(); chan++) {
                if (chan == 0) {
                        if ( ! m_track->capture_left_channel() ) {
                                continue;
@@ -542,7 +548,7 @@
                spec->total_frames = 0;
                spec->blocksize = audiodevice().get_buffer_size();
                spec->name = m_name + "-" + sourceid;
-               spec->dataF = captureBus->get_buffer( chan, 
audiodevice().get_buffer_size());
+               spec->dataF = m_captureBus->get_buffer( chan, 
audiodevice().get_buffer_size());
 
                WriteSource* ws = new WriteSource(spec, channelnumber, 
channelcount);
                ws->set_process_peaks( true );
@@ -561,6 +567,7 @@
        init_gain_envelope();
        
        connect(m_song, SIGNAL(transferStopped()), this, 
SLOT(finish_recording()));
+       connect(&audiodevice(), SIGNAL(driverParamsChanged()), this, 
SLOT(get_capture_bus()));
 
        return 1;
 }
@@ -635,8 +642,12 @@
 {
        PENTER;
        
-       int error = rs->get_error();
-       if (error < 0) {
+       if (!rs) {
+               m_invalidReadSource = true;
+               return;
+       }
+       
+       if (rs->get_error() < 0) {
                m_invalidReadSource = true;
        } else {
                m_invalidReadSource = false;
@@ -707,6 +718,7 @@
        }
 
        disconnect(m_song, SIGNAL(transferStopped()), this, 
SLOT(finish_recording()));
+       connect(&audiodevice(), SIGNAL(driverParamsChanged()), this, 
SLOT(get_capture_bus()));
 }
 
 int AudioClip::get_channels( ) const
@@ -1016,5 +1028,10 @@
        return m_readSource;
 }
 
+void AudioClip::get_capture_bus()
+{
+       m_captureBus = audiodevice().get_capture_bus(m_captureBusName);
+}
+
 // eof
 

Index: AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- AudioClip.h 24 May 2007 17:45:19 -0000      1.50
+++ AudioClip.h 28 May 2007 21:30:13 -0000      1.51
@@ -142,13 +142,14 @@
        ReadSource*             m_readSource;
        QList<WriteSource* >    writeSources;
        QList<FadeCurve* >      m_fades;
-       AudioBus*               captureBus;
+       AudioBus*               m_captureBus;
        FadeCurve*              fadeIn;
        FadeCurve*              fadeOut;
        Curve*                  m_gainEnvelope;
        QDomNode                m_domNode;
        
        QString                 m_name;
+       QByteArray              m_captureBusName;
        nframes_t               trackStartFrame;
        nframes_t               trackEndFrame;
        nframes_t               sourceEndFrame;
@@ -218,6 +219,7 @@
 private slots:
        void private_add_fade(FadeCurve* fade);
        void private_remove_fade(FadeCurve* fade);
+       void get_capture_bus();
 
 };
 

Index: ResourcesManager.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ResourcesManager.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- ResourcesManager.cpp        24 May 2007 17:45:19 -0000      1.17
+++ ResourcesManager.cpp        28 May 2007 21:30:13 -0000      1.18
@@ -285,10 +285,7 @@
        }
        
        ReadSource* source = get_readsource(data->clip->get_readsource_id());
-       
-       if (source) {
                clip->set_audio_source(source);
-       }
        
        data->inUse = true;
        
@@ -405,3 +402,15 @@
        removed = false;
 }
 
+void ResourcesManager::destroy_clip(AudioClip * clip)
+{
+       ClipData* data = m_clips.value(clip->get_id());
+       if (!data) {
+               PERROR("Clip with id %lld not in database", clip->get_id());
+       }
+       
+       m_clips.remove(clip->get_id());
+       delete data;
+       delete clip;
+}
+

Index: ResourcesManager.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/ResourcesManager.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- ResourcesManager.h  24 May 2007 17:45:19 -0000      1.10
+++ ResourcesManager.h  28 May 2007 21:30:13 -0000      1.11
@@ -58,6 +58,7 @@
        void mark_clip_removed(AudioClip* clip);
        void mark_clip_added(AudioClip* clip);
        void set_source_for_clip(AudioClip* clip, ReadSource* source);
+       void destroy_clip(AudioClip* clip);
        
        bool is_clip_in_use(qint64) const;
        bool is_source_in_use(qint64 id) const;

Index: Track.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Track.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- Track.cpp   24 May 2007 10:56:43 -0000      1.57
+++ Track.cpp   28 May 2007 21:30:13 -0000      1.58
@@ -316,6 +316,8 @@
        
        if (clip->init_recording(busIn) < 0) {
                PERROR("Could not create AudioClip to record to!");
+               resources_manager()->destroy_clip(clip);
+               return 0;
        } else {
                return clip;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]