3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "quicktune.h"
21 #include "threading/mutex_auto_lock.h"
22 #include "util/string.h"
24 std::string
QuicktuneValue::getString()
30 return ftos(value_QVT_FLOAT
.current
);
32 return "<invalid type>";
34 void QuicktuneValue::relativeAdd(float amount
)
40 value_QVT_FLOAT
.current
+= amount
* (value_QVT_FLOAT
.max
- value_QVT_FLOAT
.min
);
41 if(value_QVT_FLOAT
.current
> value_QVT_FLOAT
.max
)
42 value_QVT_FLOAT
.current
= value_QVT_FLOAT
.max
;
43 if(value_QVT_FLOAT
.current
< value_QVT_FLOAT
.min
)
44 value_QVT_FLOAT
.current
= value_QVT_FLOAT
.min
;
49 static std::map
<std::string
, QuicktuneValue
> g_values
;
50 static std::vector
<std::string
> g_names
;
51 std::mutex
*g_mutex
= NULL
;
53 static void makeMutex()
56 g_mutex
= new std::mutex();
60 std::vector
<std::string
> getQuicktuneNames()
65 QuicktuneValue
getQuicktuneValue(const std::string
&name
)
68 MutexAutoLock
lock(*g_mutex
);
69 std::map
<std::string
, QuicktuneValue
>::iterator i
= g_values
.find(name
);
70 if(i
== g_values
.end()){
78 void setQuicktuneValue(const std::string
&name
, const QuicktuneValue
&val
)
81 MutexAutoLock
lock(*g_mutex
);
83 g_values
[name
].modified
= true;
86 void updateQuicktuneValue(const std::string
&name
, QuicktuneValue
&val
)
89 MutexAutoLock
lock(*g_mutex
);
90 std::map
<std::string
, QuicktuneValue
>::iterator i
= g_values
.find(name
);
91 if(i
== g_values
.end()){
93 g_names
.push_back(name
);
96 QuicktuneValue
&ref
= i
->second
;
101 ref
.modified
= false;