1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2008 Andreas Persson * |
* Copyright (C) 2008 - 2012 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
189 |
uint32_t type; |
uint32_t type; |
190 |
uint32_t flags; |
uint32_t flags; |
191 |
|
|
|
// Attempt to restore from state-file |
|
192 |
const void* value = retrieve( |
const void* value = retrieve( |
193 |
handle, |
handle, |
194 |
uri_to_id(NULL, NS_LS "state-file"), |
uri_to_id(NULL, NS_LS "state-file"), |
195 |
&size, &type, &flags); |
&size, &type, &flags); |
196 |
if (value) { |
if (value) { |
197 |
|
// Restore from state-file |
198 |
assert(type == uri_to_id(NULL, LV2_STATE_PATH_URI)); |
assert(type == uri_to_id(NULL, LV2_STATE_PATH_URI)); |
199 |
const String path((const char*)value); |
const String path((const char*)value); |
200 |
dmsg(2, ("linuxsampler: restoring from file %s\n", path.c_str())); |
dmsg(2, ("linuxsampler: restoring from file %s\n", path.c_str())); |
202 |
String state; |
String state; |
203 |
std::getline(in, state, '\0'); |
std::getline(in, state, '\0'); |
204 |
SetState(state); |
SetState(state); |
205 |
return; |
} else if ((value = retrieve(handle, |
206 |
} |
uri_to_id(NULL, NS_LS "state-string"), |
207 |
|
&size, &type, &flags))) { |
208 |
// Attempt to restore from state-string |
// Restore from state-string |
|
value = retrieve( |
|
|
handle, |
|
|
uri_to_id(NULL, NS_LS "state-string"), |
|
|
&size, &type, &flags); |
|
|
if (value) { |
|
209 |
dmsg(2, ("linuxsampler: restoring from string\n")); |
dmsg(2, ("linuxsampler: restoring from string\n")); |
210 |
assert(type == uri_to_id(NULL, NS_ATOM "String")); |
assert(type == uri_to_id(NULL, NS_ATOM "String")); |
211 |
String state((const char*)value); |
String state((const char*)value); |
212 |
SetState(state); |
SetState(state); |
213 |
return; |
} else { |
214 |
|
// No valid state found, reset to default state |
215 |
|
dmsg(2, ("linuxsampler: restoring default state\n")); |
216 |
|
SetState(DefaultState); |
217 |
} |
} |
218 |
|
|
219 |
// No valid state found, reset to default state |
MapPath = OldMapPath; |
220 |
dmsg(2, ("linuxsampler: restoring default state\n")); |
MakePath = OldMakePath; |
|
SetState(DefaultState); |
|
221 |
|
|
222 |
MapPath = OldMapPath; |
MapPath = OldMapPath; |
223 |
MakePath = OldMakePath; |
MakePath = OldMakePath; |