Fixed a couple really old LibraryTrack bugs caused by code that was

never exercised.
This commit is contained in:
casey langen 2020-10-05 22:03:26 -07:00
parent b51dee258f
commit c63892bcdc
2 changed files with 17 additions and 4 deletions

View File

@ -69,8 +69,11 @@ LibraryTrack::~LibraryTrack() {
std::string LibraryTrack::GetString(const char* metakey) {
std::unique_lock<std::mutex> lock(this->mutex);
MetadataMap::iterator metavalue = this->metadata.find(metakey);
if (metavalue != this->metadata.end()) {
return metavalue->second;
while (metavalue != this->metadata.end()) {
if (metavalue->second.size() > 0) {
return metavalue->second;
}
++metavalue;
}
return "";
}
@ -112,8 +115,14 @@ double LibraryTrack::GetDouble(const char* key, double defaultValue) {
}
void LibraryTrack::SetValue(const char* metakey, const char* value) {
std::unique_lock<std::mutex> lock(this->mutex);
this->metadata.insert(std::pair<std::string, std::string>(metakey,value));
if (value) {
std::string strValue(value);
if (strValue.size()) {
std::unique_lock<std::mutex> lock(this->mutex);
this->metadata.insert(std::pair<std::string, std::string>(metakey, strValue));
}
}
}
void LibraryTrack::ClearValue(const char* metakey) {

View File

@ -66,6 +66,10 @@ class SdkWrapper : public Track {
}
}
virtual int64_t GetId() {
return track->GetId();
}
virtual int GetString(const char* key, char* dst, int size) override {
return track->GetString(key, dst, size);
}