| 106 | } |
| 107 | |
| 108 | void streamfx::obs::source_tracker::remove_source(obs_source_t* source) |
| 109 | { |
| 110 | std::lock_guard<decltype(_mutex)> lock(_mutex); |
| 111 | const char* name = obs_source_get_name(source); |
| 112 | |
| 113 | // Try and find the source by name. |
| 114 | if (name) { |
| 115 | if (auto kv = _sources.find(std::string{name}); kv != _sources.end()) { |
| 116 | _sources.erase(kv); |
| 117 | return; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // Try and find the source by pointer. |
| 122 | for (auto kv = _sources.begin(); kv != _sources.end(); kv++) { |
| 123 | if (kv->second == source) { |
| 124 | _sources.erase(kv); |
| 125 | return; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // If we're still here, there's something wrong. |
| 130 | if (name) { |
| 131 | D_LOG_ERROR("Attempt to remove untracked source '0x%08zX' with name %s failed.", source, name); |
| 132 | throw std::runtime_error("Failed to find given source."); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | void streamfx::obs::source_tracker::rename_source(std::string_view old_name, std::string_view new_name, obs_source_t* source) |
| 137 | { |
no outgoing calls
no test coverage detected