bool Context::process_object(Object *o, Sources &sset, std::vector<source_t> &lsources, unsigned n) {
    typedef typename std::map<typename Sources::key_type, unsigned> stats_type;
    stats_type sources_stats;

    for(typename Sources::iterator j = sset.begin(); j != sset.end(); ) {
        const typename Sources::key_type &name = j->first;
        Source *s = j->second;
        if (!s->playing()) {
            //LOG_DEBUG(("purging inactive source %s", j->first.c_str()));
            delete j->second;
            sset.erase(j++);
            continue;
        }

        typename stats_type::iterator s_i = sources_stats.find(name);
        unsigned same_sounds_n = (s_i != sources_stats.end())? s_i->second: 0;
        if (lsources.size() < max_sources && same_sounds_n < distance_model.same_sounds_limit) {
            lsources.push_back(source_t(s, _listener->transform(o->_position + s->delta_position), o->_velocity, _listener->_velocity));
            if (same_sounds_n == 0) {
                sources_stats.insert(typename stats_type::value_type(name, 1));
            } else {
                ++s_i->second;
            }
            //LOG_DEBUG(("%u: source: %s", (unsigned)lsources.size(), name.c_str()));
        } else {
            s->_update_position(n);
        }
        ++j;
    }

    if (sset.empty() && o->dead)
        return false;

    return true;
}
Exemple #2
0
void removeSource(const address &baddr, bool timeout) {
	Sources::iterator i = sources.find(baddr);
	if (i != sources.end()) {
		if (verbose) {
			char tmp[64];

			if (i->second.identified) {
				info("Removing source %s [%s]%s",
					baddr.to_string(tmp, sizeof(tmp)), i->second.name.c_str(),
					(timeout ? " by Timeout" : ""));
			} else {
				info("Removing source %s%s",
					baddr.to_string(tmp, sizeof(tmp)), (timeout ? " by Timeout" : ""));
			}
		}

		if (IsSSMEnabled())
			CountSSMLeave(ssmProbeAddr, baddr);

		sources.erase(i);
	}
}