@@ -1142,19 +1142,22 @@ class InputMixer : public AudioStream {
1142
1142
public:
1143
1143
InputMixer () = default ;
1144
1144
1145
- // / Adds a new input stream
1146
- void add (Stream &in, int weight = 100 ) {
1145
+ // / Adds a new input stream and returns it's actual index position
1146
+ int add (Stream &in, int weight = 100 ) {
1147
1147
streams.push_back (&in);
1148
1148
weights.push_back (weight);
1149
1149
total_weights += weight;
1150
+ return streams.indexOf (&in);
1150
1151
}
1151
1152
1152
- // / Replaces a stream at the indicated channel
1153
- void set (int channel , Stream &in) {
1153
+ // / Replaces a stream at the indicated index
1154
+ bool set (int index , Stream &in) {
1154
1155
if (channel < size ()) {
1155
- streams[channel] = ∈
1156
+ streams[index] = ∈
1157
+ return true ;
1156
1158
} else {
1157
1159
LOGE (" Invalid channel %d - max is %d" , channel, size () - 1 );
1160
+ return false ;
1158
1161
}
1159
1162
}
1160
1163
@@ -1224,6 +1227,20 @@ class InputMixer : public AudioStream {
1224
1227
// / abort the read and provide empty data
1225
1228
void setRetryCount (int retry) { retry_count = retry; }
1226
1229
1230
+ // / Removes a stream by index position
1231
+ bool remove (int idx){
1232
+ if (idx < 0 || idx >= size ()) {
1233
+ return false ;
1234
+ }
1235
+ streams.erase (idx);
1236
+ return true ;
1237
+ }
1238
+
1239
+ // / Provides the actual index of the stream
1240
+ int indexOf (Stream& stream){
1241
+ return streams.indexOf (&stream);
1242
+ }
1243
+
1227
1244
protected:
1228
1245
Vector<Stream *> streams{0 };
1229
1246
Vector<int > weights{0 };
0 commit comments