add channel_count() to audio source API
[ardour.git] / libs / ardour / chan_mapping.cc
index 20ea6722a9358079ecdbeb403b9630860ed13acb..5c5bb17de67a292c3094eb4584dbf25e84779603 100644 (file)
@@ -1,6 +1,6 @@
 /*
     Copyright (C) 2009 Paul Davis
-    Author: Dave Robillard
+    Author: David Robillard
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -41,12 +41,19 @@ ChanMapping::ChanMapping(ChanCount identity)
 }
 
 uint32_t
-ChanMapping::get(DataType t, uint32_t from)
+ChanMapping::get(DataType t, uint32_t from, bool* valid)
 {
        Mappings::iterator tm = _mappings.find(t);
-       assert(tm != _mappings.end());
+       if (tm == _mappings.end()) {
+               *valid = false;
+               return -1;
+       }
        TypeMapping::iterator m = tm->second.find(from);
-       assert(m != tm->second.end());
+       if (m == tm->second.end()) {
+               *valid = false;
+               return -1;
+       }
+       *valid = true;
        return m->second;
 }