Fix for [#26652] "Audio Muted" in Time Line Editor is not working
[blender-staging.git] / intern / audaspace / intern / AUD_SequencerReader.cpp
index c02f9e02b3380ce051dd96a9586d70e33b181e88..95e0dca63238e0efcbfda2481442e396f82c6c70 100644 (file)
@@ -182,55 +182,58 @@ void AUD_SequencerReader::read(int & length, sample_t* & buffer)
                m_buffer.resize(size);
        buffer = m_buffer.getBuffer();
 
-       for(AUD_StripIterator i = m_strips.begin(); i != m_strips.end(); i++)
+       if(!m_factory->getMute())
        {
-               strip = *i;
-               if(!strip->entry->muted)
+               for(AUD_StripIterator i = m_strips.begin(); i != m_strips.end(); i++)
                {
-                       if(strip->old_sound != *strip->entry->sound)
+                       strip = *i;
+                       if(!strip->entry->muted)
                        {
-                               strip->old_sound = *strip->entry->sound;
-                               if(strip->reader)
-                                       delete strip->reader;
-
-                               if(strip->old_sound)
+                               if(strip->old_sound != *strip->entry->sound)
                                {
-                                       try
+                                       strip->old_sound = *strip->entry->sound;
+                                       if(strip->reader)
+                                               delete strip->reader;
+
+                                       if(strip->old_sound)
                                        {
-                                               strip->reader = m_mixer->prepare(strip->old_sound->createReader());
+                                               try
+                                               {
+                                                       strip->reader = m_mixer->prepare(strip->old_sound->createReader());
+                                               }
+                                               catch(AUD_Exception)
+                                               {
+                                                       strip->reader = NULL;
+                                               }
                                        }
-                                       catch(AUD_Exception)
-                                       {
+                                       else
                                                strip->reader = NULL;
-                                       }
                                }
-                               else
-                                       strip->reader = NULL;
-                       }
 
-                       if(strip->reader)
-                       {
-                               end = floor(strip->entry->end * rate);
-                               if(m_position < end)
+                               if(strip->reader)
                                {
-                                       start = floor(strip->entry->begin * rate);
-                                       if(m_position + length > start)
+                                       end = floor(strip->entry->end * rate);
+                                       if(m_position < end)
                                        {
-                                               current = m_position - start;
-                                               if(current < 0)
+                                               start = floor(strip->entry->begin * rate);
+                                               if(m_position + length > start)
                                                {
-                                                       skip = -current;
-                                                       current = 0;
+                                                       current = m_position - start;
+                                                       if(current < 0)
+                                                       {
+                                                               skip = -current;
+                                                               current = 0;
+                                                       }
+                                                       else
+                                                               skip = 0;
+                                                       current += strip->entry->skip * rate;
+                                                       len = length > end - m_position ? end - m_position : length;
+                                                       len -= skip;
+                                                       if(strip->reader->getPosition() != current)
+                                                               strip->reader->seek(current);
+                                                       strip->reader->read(len, buf);
+                                                       m_mixer->add(buf, skip, len, m_volume(m_data, strip->entry->data, (float)m_position / (float)rate));
                                                }
-                                               else
-                                                       skip = 0;
-                                               current += strip->entry->skip * rate;
-                                               len = length > end - m_position ? end - m_position : length;
-                                               len -= skip;
-                                               if(strip->reader->getPosition() != current)
-                                                       strip->reader->seek(current);
-                                               strip->reader->read(len, buf);
-                                               m_mixer->add(buf, skip, len, m_volume(m_data, strip->entry->data, (float)m_position / (float)rate));
                                        }
                                }
                        }