Commit 83e5b3a9 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #28351: audiocodecfactory: use range-based for loops

parent 0f33f629
...@@ -56,9 +56,9 @@ AudioCodecFactory::AudioCodecFactory() : ...@@ -56,9 +56,9 @@ AudioCodecFactory::AudioCodecFactory() :
if (codecDynamicList.empty()) if (codecDynamicList.empty())
ERROR("No codecs available"); ERROR("No codecs available");
else { else {
for (AudioCodecVector::const_iterator iter = codecDynamicList.begin(); iter != codecDynamicList.end() ; ++iter) { for (const auto &codec: codecDynamicList) {
codecsMap_[(int)(*iter)->getPayloadType()] = *iter; codecsMap_[(int) codec->getPayloadType()] = codec;
DEBUG("Loaded codec %s" , (*iter)->getMimeSubtype().c_str()); DEBUG("Loaded codec %s" , codec->getMimeSubtype().c_str());
} }
} }
} }
...@@ -68,8 +68,8 @@ AudioCodecFactory::setDefaultOrder() ...@@ -68,8 +68,8 @@ AudioCodecFactory::setDefaultOrder()
{ {
defaultCodecList_.clear(); defaultCodecList_.clear();
for (AudioCodecsMap::const_iterator i = codecsMap_.begin(); i != codecsMap_.end(); ++i) for (const auto &codec : codecsMap_)
defaultCodecList_.push_back(i->first); defaultCodecList_.push_back(codec.first);
} }
std::string std::string
...@@ -88,9 +88,9 @@ AudioCodecFactory::getCodecList() const ...@@ -88,9 +88,9 @@ AudioCodecFactory::getCodecList() const
{ {
std::vector<int32_t> list; std::vector<int32_t> list;
for (AudioCodecsMap::const_iterator iter = codecsMap_.begin(); iter != codecsMap_.end(); ++iter) for (const auto &codec : codecsMap_)
if (iter->second) if (codec.second)
list.push_back((int32_t) iter->first); list.push_back((int32_t) codec.first);
return list; return list;
} }
...@@ -149,8 +149,8 @@ AudioCodecFactory::saveActiveCodecs(const std::vector<std::string>& list) ...@@ -149,8 +149,8 @@ AudioCodecFactory::saveActiveCodecs(const std::vector<std::string>& list)
// list contains the ordered payload of active codecs picked by the user // list contains the ordered payload of active codecs picked by the user
// we used the codec vector to save the order. // we used the codec vector to save the order.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end(); ++iter) { for (const auto &codec : list) {
int payload = std::atoi(iter->c_str()); int payload = std::atoi(codec.c_str());
if (isCodecLoaded(payload)) if (isCodecLoaded(payload))
defaultCodecList_.push_back(static_cast<int>(payload)); defaultCodecList_.push_back(static_cast<int>(payload));
...@@ -160,9 +160,8 @@ AudioCodecFactory::saveActiveCodecs(const std::vector<std::string>& list) ...@@ -160,9 +160,8 @@ AudioCodecFactory::saveActiveCodecs(const std::vector<std::string>& list)
AudioCodecFactory::~AudioCodecFactory() AudioCodecFactory::~AudioCodecFactory()
{ {
for (std::vector<AudioCodecHandlePointer>::iterator iter = for (auto &codec : codecInMemory_)
codecInMemory_.begin(); iter != codecInMemory_.end(); ++iter) unloadCodec(codec);
unloadCodec(*iter);
} }
std::vector<sfl::AudioCodec*> std::vector<sfl::AudioCodec*>
...@@ -283,14 +282,13 @@ AudioCodecFactory::instantiateCodec(int payload) const ...@@ -283,14 +282,13 @@ AudioCodecFactory::instantiateCodec(int payload) const
{ {
// flush last error // flush last error
dlerror(); dlerror();
std::vector<AudioCodecHandlePointer>::const_iterator iter;
sfl::AudioCodec *result = NULL; sfl::AudioCodec *result = NULL;
for (iter = codecInMemory_.begin(); iter != codecInMemory_.end(); ++iter) { for (const auto &codec : codecInMemory_) {
if (iter->first->getPayloadType() == payload) { if (codec.first->getPayloadType() == payload) {
create_t* createCodec = (create_t*) dlsym(iter->second , AUDIO_CODEC_ENTRY_SYMBOL); create_t* createCodec = (create_t*) dlsym(codec.second , AUDIO_CODEC_ENTRY_SYMBOL);
const char *error = dlerror(); const char *error = dlerror();
...@@ -362,10 +360,8 @@ AudioCodecFactory::alreadyInCache(const std::string &lib) ...@@ -362,10 +360,8 @@ AudioCodecFactory::alreadyInCache(const std::string &lib)
bool bool
AudioCodecFactory::isCodecLoaded(int payload) const AudioCodecFactory::isCodecLoaded(int payload) const
{ {
AudioCodecsMap::const_iterator iter; for (const auto &codec : codecsMap_)
if (codec.first == payload)
for (iter = codecsMap_.begin(); iter != codecsMap_.end(); ++iter)
if (iter->first == payload)
return true; return true;
return false; return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment