UI: Fix audio ids not being stored properly
Audio ids were being stored in a map with const char pointers, thus they were destroyed when call_once finished. To fix this, store std::strings instead.
This commit is contained in:
parent
2a991a4fa0
commit
02e5410381
@ -18,12 +18,12 @@ static const char *NullToEmpty(const char *str)
|
||||
return str ? str : "";
|
||||
}
|
||||
|
||||
static const char *EncoderName(const char *id)
|
||||
static const char *EncoderName(const std::string &id)
|
||||
{
|
||||
return NullToEmpty(obs_encoder_get_display_name(id));
|
||||
return NullToEmpty(obs_encoder_get_display_name(id.c_str()));
|
||||
}
|
||||
|
||||
static map<int, const char *> bitrateMap;
|
||||
static map<int, std::string> bitrateMap;
|
||||
|
||||
static void HandleIntProperty(obs_property_t *prop, const char *id)
|
||||
{
|
||||
@ -199,7 +199,7 @@ static void PopulateBitrateMap()
|
||||
});
|
||||
}
|
||||
|
||||
const map<int, const char *> &GetAACEncoderBitrateMap()
|
||||
const map<int, std::string> &GetAACEncoderBitrateMap()
|
||||
{
|
||||
PopulateBitrateMap();
|
||||
return bitrateMap;
|
||||
@ -211,7 +211,7 @@ const char *GetAACEncoderForBitrate(int bitrate)
|
||||
auto res = map_.find(bitrate);
|
||||
if (res == end(map_))
|
||||
return NULL;
|
||||
return res->second;
|
||||
return res->second.c_str();
|
||||
}
|
||||
|
||||
#define INVALID_BITRATE 10000
|
||||
|
@ -4,6 +4,6 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
const std::map<int, const char *> &GetAACEncoderBitrateMap();
|
||||
const std::map<int, std::string> &GetAACEncoderBitrateMap();
|
||||
const char *GetAACEncoderForBitrate(int bitrate);
|
||||
int FindClosestAvailableAACBitrate(int bitrate);
|
||||
|
@ -277,8 +277,9 @@ static void PopulateAACBitrates(initializer_list<QComboBox *> boxes)
|
||||
|
||||
vector<pair<QString, QString>> pairs;
|
||||
for (auto &entry : bitrateMap)
|
||||
pairs.emplace_back(QString::number(entry.first),
|
||||
obs_encoder_get_display_name(entry.second));
|
||||
pairs.emplace_back(
|
||||
QString::number(entry.first),
|
||||
obs_encoder_get_display_name(entry.second.c_str()));
|
||||
|
||||
for (auto box : boxes) {
|
||||
QString currentText = box->currentText();
|
||||
|
Loading…
x
Reference in New Issue
Block a user