VST3: use read-only substream to restore state
This commit is contained in:
parent
5a25db34ae
commit
9e7cfdd880
@ -2214,10 +2214,15 @@ VST3PI::load_state (RAMStream& stream)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kComponentState))) {
|
if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kComponentState))) {
|
||||||
tresult res = _component->setState(&stream);
|
ROMStream s (stream, i->_offset, i->_size);
|
||||||
|
tresult res = _component->setState(&s);
|
||||||
|
tresult re2 = res;
|
||||||
|
|
||||||
stream.seek (i->_offset, IBStream::kIBSeekSet, &seek_result);
|
if (FUnknownPtr<Vst::IEditController> (_component) == 0) {
|
||||||
tresult re2 = _controller->setComponentState(&stream);
|
/* only if component and controller are not identical */
|
||||||
|
s.seek (0, IBStream::kIBSeekSet, NULL);
|
||||||
|
re2 = _controller->setComponentState(&s);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(re2 == kResultOk || re2 == kNotImplemented || res == kResultOk || res == kNotImplemented)) {
|
if (!(re2 == kResultOk || re2 == kNotImplemented || res == kResultOk || res == kNotImplemented)) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -2227,7 +2232,8 @@ VST3PI::load_state (RAMStream& stream)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kControllerState))) {
|
else if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kControllerState))) {
|
||||||
tresult res = _controller->setState (&stream);
|
ROMStream s (stream, i->_offset, i->_size);
|
||||||
|
tresult res = _controller->setState (&s);
|
||||||
if (!(res == kResultOk || res == kNotImplemented)) {
|
if (!(res == kResultOk || res == kNotImplemented)) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
std::cerr << "VST3: failed to restore controller state\n";
|
std::cerr << "VST3: failed to restore controller state\n";
|
||||||
@ -2277,11 +2283,14 @@ VST3PI::save_state (RAMStream& stream)
|
|||||||
entries.push_back (c);
|
entries.push_back (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FUnknownPtr<Vst::IEditController> (_component) == 0) {
|
||||||
|
/* only if component and controller are not identical */
|
||||||
c.start_chunk (getChunkID (Vst::kControllerState), stream);
|
c.start_chunk (getChunkID (Vst::kControllerState), stream);
|
||||||
if (_controller->getState (&stream) == kResultTrue) {
|
if (_controller->getState (&stream) == kResultTrue) {
|
||||||
c.end_chunk (stream);
|
c.end_chunk (stream);
|
||||||
entries.push_back (c);
|
entries.push_back (c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* update header */
|
/* update header */
|
||||||
int64 pos;
|
int64 pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user