diff options
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp | 2 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 9 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.h | 4 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerFactory.cpp | 14 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerFactory.h | 5 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_SequencerReader.cpp | 75 |
6 files changed, 67 insertions, 42 deletions
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index 078a10a68cb..0dc525b0e5a 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -253,7 +253,7 @@ void AUD_FFMPEGReader::seek(int position) if(position >= 0) { uint64_t st_time = m_formatCtx->start_time; - uint64_t seek_pos = position * AV_TIME_BASE / m_specs.rate; + uint64_t seek_pos = ((uint64_t)position) * ((uint64_t)AV_TIME_BASE) / ((uint64_t)m_specs.rate); if (seek_pos < 0) { seek_pos = 0; diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index 3fb11e31c37..0119bb105d8 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -864,7 +864,7 @@ AUD_Channel* AUD_pauseAfter(AUD_Channel* handle, float seconds) } } -AUD_Sound* AUD_createSequencer(void* data, AUD_volumeFunction volume) +AUD_Sound* AUD_createSequencer(int muted, void* data, AUD_volumeFunction volume) { /* AUD_XXX should be this: but AUD_createSequencer is called before the device * is initialized. @@ -874,7 +874,7 @@ AUD_Sound* AUD_createSequencer(void* data, AUD_volumeFunction volume) AUD_Specs specs; specs.channels = AUD_CHANNELS_STEREO; specs.rate = AUD_RATE_44100; - return new AUD_SequencerFactory(specs, data, volume); + return new AUD_SequencerFactory(specs, muted, data, volume); } void AUD_destroySequencer(AUD_Sound* sequencer) @@ -882,6 +882,11 @@ void AUD_destroySequencer(AUD_Sound* sequencer) delete ((AUD_SequencerFactory*)sequencer); } +void AUD_setSequencerMuted(AUD_Sound* sequencer, int muted) +{ + ((AUD_SequencerFactory*)sequencer)->mute(muted); +} + AUD_SequencerEntry* AUD_addSequencer(AUD_Sound** sequencer, AUD_Sound* sound, float begin, float end, float skip, void* data) { diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h index 04343bb9c4c..b2242f09547 100644 --- a/intern/audaspace/intern/AUD_C-API.h +++ b/intern/audaspace/intern/AUD_C-API.h @@ -459,10 +459,12 @@ extern float* AUD_readSoundBuffer(const char* filename, float low, float high, */ extern AUD_Channel* AUD_pauseAfter(AUD_Channel* handle, float seconds); -extern AUD_Sound* AUD_createSequencer(void* data, AUD_volumeFunction volume); +extern AUD_Sound* AUD_createSequencer(int muted, void* data, AUD_volumeFunction volume); extern void AUD_destroySequencer(AUD_Sound* sequencer); +extern void AUD_setSequencerMuted(AUD_Sound* sequencer, int muted); + extern AUD_SequencerEntry* AUD_addSequencer(AUD_Sound** sequencer, AUD_Sound* sound, float begin, float end, float skip, void* data); diff --git a/intern/audaspace/intern/AUD_SequencerFactory.cpp b/intern/audaspace/intern/AUD_SequencerFactory.cpp index 77d83458c68..f49dd94fe11 100644 --- a/intern/audaspace/intern/AUD_SequencerFactory.cpp +++ b/intern/audaspace/intern/AUD_SequencerFactory.cpp @@ -34,9 +34,11 @@ typedef std::list<AUD_SequencerReader*>::iterator AUD_ReaderIterator; -AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, void* data, +AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, bool muted, + void* data, AUD_volumeFunction volume) : m_specs(specs), + m_muted(muted), m_data(data), m_volume(volume) { @@ -62,6 +64,16 @@ AUD_SequencerFactory::~AUD_SequencerFactory() } } +void AUD_SequencerFactory::mute(bool muted) +{ + m_muted = muted; +} + +bool AUD_SequencerFactory::getMute() const +{ + return m_muted; +} + AUD_IReader* AUD_SequencerFactory::newReader() { AUD_SequencerReader* reader = new AUD_SequencerReader(this, m_entries, diff --git a/intern/audaspace/intern/AUD_SequencerFactory.h b/intern/audaspace/intern/AUD_SequencerFactory.h index 5eea95eb6ef..8f3466f75ce 100644 --- a/intern/audaspace/intern/AUD_SequencerFactory.h +++ b/intern/audaspace/intern/AUD_SequencerFactory.h @@ -63,6 +63,7 @@ private: std::list<AUD_SequencerEntry*> m_entries; std::list<AUD_SequencerReader*> m_readers; + bool m_muted; void* m_data; AUD_volumeFunction m_volume; @@ -73,9 +74,11 @@ private: AUD_SequencerFactory& operator=(const AUD_SequencerFactory&); public: - AUD_SequencerFactory(AUD_Specs specs, void* data, AUD_volumeFunction volume); + AUD_SequencerFactory(AUD_Specs specs, bool muted, void* data, AUD_volumeFunction volume); ~AUD_SequencerFactory(); + void mute(bool muted); + bool getMute() const; AUD_SequencerEntry* add(AUD_IFactory** sound, float begin, float end, float skip, void* data); void remove(AUD_SequencerEntry* entry); void move(AUD_SequencerEntry* entry, float begin, float end, float skip); diff --git a/intern/audaspace/intern/AUD_SequencerReader.cpp b/intern/audaspace/intern/AUD_SequencerReader.cpp index c02f9e02b33..95e0dca6323 100644 --- a/intern/audaspace/intern/AUD_SequencerReader.cpp +++ b/intern/audaspace/intern/AUD_SequencerReader.cpp @@ -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)); } } } |