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;
}
}
-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.
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)
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)
{
*/
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);
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)
{
}
}
+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,
std::list<AUD_SequencerEntry*> m_entries;
std::list<AUD_SequencerReader*> m_readers;
+ bool m_muted;
void* m_data;
AUD_volumeFunction m_volume;
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);
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));
}
}
}
void sound_destroy_scene(struct Scene *scene);
+void sound_mute_scene(struct Scene *scene, int muted);
+
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
void sound_create_scene(struct Scene *scene)
{
- scene->sound_scene = AUD_createSequencer(scene, (AUD_volumeFunction)&sound_get_volume);
+ scene->sound_scene = AUD_createSequencer(scene->audio.flag & AUDIO_MUTE, scene, (AUD_volumeFunction)&sound_get_volume);
}
void sound_destroy_scene(struct Scene *scene)
AUD_destroySequencer(scene->sound_scene);
}
+void sound_mute_scene(struct Scene *scene, int muted)
+{
+ if(scene->sound_scene)
+ AUD_setSequencerMuted(scene->sound_scene, muted);
+}
+
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
if(scene != sequence->scene)
rna_Scene_use_simplify_update(bmain, scene, ptr);
}
+static int rna_Scene_use_audio_get(PointerRNA *ptr)
+{
+ Scene *scene= (Scene*)ptr->data;
+ return scene->audio.flag & AUDIO_MUTE;
+}
+
+static void rna_Scene_use_audio_set(PointerRNA *ptr, int value)
+{
+ Scene *scene= (Scene*)ptr->data;
+
+ if(value)
+ scene->audio.flag |= AUDIO_MUTE;
+ else
+ scene->audio.flag &= ~AUDIO_MUTE;
+
+ sound_mute_scene(scene, value);
+}
+
static int rna_Scene_sync_mode_get(PointerRNA *ptr)
{
Scene *scene= (Scene*)ptr->data;
/* Audio Settings */
prop= RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "audio.flag", AUDIO_MUTE);
+ RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set");
RNA_def_property_ui_text(prop, "Audio Muted", "Play back of audio from Sequence Editor will be muted");
RNA_def_property_update(prop, NC_SCENE, NULL);