mainbuffer.cpp 14 KB
Newer Older
1
/*
2
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
3
 *  Author : Alexandre Savard <alexandre.savard@savoirfairelinux.com>
Emmanuel Milou's avatar
Emmanuel Milou committed
4
5
 *
 *
6
7
8
9
 *  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
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
Emmanuel Milou's avatar
Emmanuel Milou committed
10
 *
11
12
13
14
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
Emmanuel Milou's avatar
Emmanuel Milou committed
15
 *
16
17
18
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21
22
23
24
25
26
27
28
29
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
30
31
32
33
 */

#include "mainbuffer.h"

34
#include "manager.h"
35

36
MainBuffer::MainBuffer() : _internalSamplingRate (8000)
37
{
38
    mixBuffer = new SFLDataFormat[STATIC_BUFSIZE];
39
40
41
42
43
}


MainBuffer::~MainBuffer()
{
44

45
    delete [] mixBuffer; mixBuffer = NULL;
46
47
}

48

Emmanuel Milou's avatar
Emmanuel Milou committed
49
void MainBuffer::setInternalSamplingRate (int sr)
50
{
Alexandre Savard's avatar
Alexandre Savard committed
51
  // ost::MutexLock guard (_mutex);
52

Emmanuel Milou's avatar
Emmanuel Milou committed
53
    if (sr != _internalSamplingRate) {
54

Emmanuel Milou's avatar
Emmanuel Milou committed
55
56
57
        _internalSamplingRate = sr;

        flushAllBuffers();
58

59
60
	Manager::instance().audioSamplingRateChanged();

61
62
63
    }
}

Emmanuel Milou's avatar
Emmanuel Milou committed
64
CallIDSet* MainBuffer::getCallIDSet (CallID call_id)
65
66
{

Emmanuel Milou's avatar
Emmanuel Milou committed
67
68
    CallIDMap::iterator iter = _callIDMap.find (call_id);

69
    if (iter != _callIDMap.end())
Emmanuel Milou's avatar
Emmanuel Milou committed
70
        return iter->second;
71
    else
Emmanuel Milou's avatar
Emmanuel Milou committed
72
        return NULL;
73
74
75

}

Emmanuel Milou's avatar
Emmanuel Milou committed
76
bool MainBuffer::createCallIDSet (CallID set_id)
77
{
Emmanuel Milou's avatar
Emmanuel Milou committed
78

79
    CallIDSet* newCallIDSet = new CallIDSet;
80

Emmanuel Milou's avatar
Emmanuel Milou committed
81
    _callIDMap.insert (pair<CallID, CallIDSet*> (set_id, newCallIDSet));
82
83
84
85
86

    return true;

}

Emmanuel Milou's avatar
Emmanuel Milou committed
87
bool MainBuffer::removeCallIDSet (CallID set_id)
88
89
{

90

Emmanuel Milou's avatar
Emmanuel Milou committed
91
    CallIDSet* callid_set = getCallIDSet (set_id);
92

Emmanuel Milou's avatar
Emmanuel Milou committed
93
94
    if (callid_set != NULL) {
        if (_callIDMap.erase (set_id) != 0) {
95
        	delete callid_set; callid_set = NULL;
Emmanuel Milou's avatar
Emmanuel Milou committed
96
97
            return true;
        } else {
Alexandre Savard's avatar
Alexandre Savard committed
98
            _debug ("removeCallIDSet error while removing callid set %s!", set_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
99
100
101
            return false;
        }
    } else {
Alexandre Savard's avatar
Alexandre Savard committed
102
        _debug ("removeCallIDSet error callid set %s does not exist!", set_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
103
        return false;
104
    }
105
106
107

}

Emmanuel Milou's avatar
Emmanuel Milou committed
108
void MainBuffer::addCallIDtoSet (CallID set_id, CallID call_id)
109
110
{

Emmanuel Milou's avatar
Emmanuel Milou committed
111
112
    CallIDSet* callid_set = getCallIDSet (set_id);
    callid_set->insert (call_id);
113
114
115

}

Emmanuel Milou's avatar
Emmanuel Milou committed
116
void MainBuffer::removeCallIDfromSet (CallID set_id, CallID call_id)
117
{
Emmanuel Milou's avatar
Emmanuel Milou committed
118
119
120
121
122
123

    CallIDSet* callid_set = getCallIDSet (set_id);

    if (callid_set != NULL) {
        if (callid_set->erase (call_id) != 0) {
        } else {
Alexandre Savard's avatar
Alexandre Savard committed
124
            _debug ("removeCallIDfromSet error while removing callid %s from set %s!", call_id.c_str(), set_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
125
126
        }
    } else {
Alexandre Savard's avatar
Alexandre Savard committed
127
        _debug ("removeCallIDfromSet error callid set %s does not exist!", set_id.c_str());
128
    }
129
130
131
}


Emmanuel Milou's avatar
Emmanuel Milou committed
132
RingBuffer* MainBuffer::getRingBuffer (CallID call_id)
133
{
Emmanuel Milou's avatar
Emmanuel Milou committed
134
135
136
137

    RingBufferMap::iterator iter = _ringBufferMap.find (call_id);

    if (iter == _ringBufferMap.end()) {
Julien Bonjean's avatar
Julien Bonjean committed
138
        // _debug("ringBuffer with ID: \"%s\" doesn't exist! ", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
139
140
141
        return NULL;
    } else
        return iter->second;
142
143
144
}


Emmanuel Milou's avatar
Emmanuel Milou committed
145
RingBuffer* MainBuffer::createRingBuffer (CallID call_id)
146
{
147

Emmanuel Milou's avatar
Emmanuel Milou committed
148
    RingBuffer* newRingBuffer = new RingBuffer (SIZEBUF, call_id);
149

Emmanuel Milou's avatar
Emmanuel Milou committed
150
    _ringBufferMap.insert (pair<CallID, RingBuffer*> (call_id, newRingBuffer));
151
152
153
154
155

    return newRingBuffer;
}


Emmanuel Milou's avatar
Emmanuel Milou committed
156
bool MainBuffer::removeRingBuffer (CallID call_id)
157
{
158

Emmanuel Milou's avatar
Emmanuel Milou committed
159
160
161
162
    RingBuffer* ring_buffer = getRingBuffer (call_id);

    if (ring_buffer != NULL) {
        if (_ringBufferMap.erase (call_id) != 0) {
163
        	delete ring_buffer;
164
            return true;
Emmanuel Milou's avatar
Emmanuel Milou committed
165
        } else {
166
            _error ("BufferManager: Error: Fail to delete ringbuffer %s!", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
167
168
169
            return false;
        }
    } else {
170
        _debug ("BufferManager: Error: Ringbuffer %s does not exist!", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
171
        return true;
172
    }
173
}
174
175


Emmanuel Milou's avatar
Emmanuel Milou committed
176
void MainBuffer::bindCallID (CallID call_id1, CallID call_id2)
177
178
{

Alexandre Savard's avatar
Alexandre Savard committed
179
  // ost::MutexLock guard (_mutex);
180

181
182
    RingBuffer* ring_buffer;
    CallIDSet* callid_set;
183

Emmanuel Milou's avatar
Emmanuel Milou committed
184
185
186
187
188
189
190
191
    if ( (ring_buffer = getRingBuffer (call_id1)) == NULL)
        createRingBuffer (call_id1);

    if ( (callid_set = getCallIDSet (call_id1)) == NULL)
        createCallIDSet (call_id1);

    if ( (ring_buffer = getRingBuffer (call_id2)) == NULL)
        createRingBuffer (call_id2);
192

Emmanuel Milou's avatar
Emmanuel Milou committed
193
194
    if ( (callid_set = getCallIDSet (call_id2)) == NULL)
        createCallIDSet (call_id2);
195

Emmanuel Milou's avatar
Emmanuel Milou committed
196
    getRingBuffer (call_id1)->createReadPointer (call_id2);
197

Emmanuel Milou's avatar
Emmanuel Milou committed
198
    getRingBuffer (call_id2)->createReadPointer (call_id1);
199

Emmanuel Milou's avatar
Emmanuel Milou committed
200
    addCallIDtoSet (call_id1, call_id2);
201

Emmanuel Milou's avatar
Emmanuel Milou committed
202
    addCallIDtoSet (call_id2, call_id1);
203

204
205
206
}


Emmanuel Milou's avatar
Emmanuel Milou committed
207
void MainBuffer::unBindCallID (CallID call_id1, CallID call_id2)
208
{
209

Alexandre Savard's avatar
Alexandre Savard committed
210
  // ost::MutexLock guard (_mutex);
211

Emmanuel Milou's avatar
Emmanuel Milou committed
212
213
    removeCallIDfromSet (call_id1, call_id2);
    removeCallIDfromSet (call_id2, call_id1);
214
215
216

    RingBuffer* ringbuffer;

Emmanuel Milou's avatar
Emmanuel Milou committed
217
    ringbuffer = getRingBuffer (call_id2);
218

Emmanuel Milou's avatar
Emmanuel Milou committed
219
    if (ringbuffer != NULL) {
220

Emmanuel Milou's avatar
Emmanuel Milou committed
221
222
223
224
225
        ringbuffer->removeReadPointer (call_id1);

        if (ringbuffer->getNbReadPointer() == 0) {
            removeCallIDSet (call_id2);
            removeRingBuffer (call_id2);
226
227
228
229
        }

    }

Emmanuel Milou's avatar
Emmanuel Milou committed
230
231
232
233
    ringbuffer = getRingBuffer (call_id1);

    if (ringbuffer != NULL) {
        ringbuffer->removeReadPointer (call_id2);
234

Emmanuel Milou's avatar
Emmanuel Milou committed
235
236
237
        if (ringbuffer->getNbReadPointer() == 0) {
            removeCallIDSet (call_id1);
            removeRingBuffer (call_id1);
238
        }
239
    }
240

241
242
243

}

Emmanuel Milou's avatar
Emmanuel Milou committed
244
void MainBuffer::unBindAll (CallID call_id)
245
246
{

247
    // ost::MutexLock guard (_mutex);
248

Emmanuel Milou's avatar
Emmanuel Milou committed
249
    CallIDSet* callid_set = getCallIDSet (call_id);
250
251

    if (callid_set == NULL)
Emmanuel Milou's avatar
Emmanuel Milou committed
252
        return;
253
254

    if (callid_set->empty())
Emmanuel Milou's avatar
Emmanuel Milou committed
255
256
        return;

257
    CallIDSet temp_set = *callid_set;
Emmanuel Milou's avatar
Emmanuel Milou committed
258

259
    CallIDSet::iterator iter_set = temp_set.begin();
260

Emmanuel Milou's avatar
Emmanuel Milou committed
261
262
263
    while (iter_set != temp_set.end()) {
        CallID call_id_in_set = *iter_set;
        unBindCallID (call_id, call_id_in_set);
264

Emmanuel Milou's avatar
Emmanuel Milou committed
265
        iter_set++;
266
    }
267

268
269
270
}


Emmanuel Milou's avatar
Emmanuel Milou committed
271
int MainBuffer::putData (void *buffer, int toCopy, unsigned short volume, CallID call_id)
272
273
{

274
    // ost::MutexLock guard (_mutex);
275

Emmanuel Milou's avatar
Emmanuel Milou committed
276
    RingBuffer* ring_buffer = getRingBuffer (call_id);
277

Emmanuel Milou's avatar
Emmanuel Milou committed
278
279
    if (ring_buffer == NULL) {
        return 0;
280
281
    }

282
283
    int a;

284
    // ost::MutexLock guard (_mutex);
285
286
287
    a = ring_buffer->AvailForPut();

    if (a >= toCopy) {
288

289
        return ring_buffer->Put (buffer, toCopy, volume);
290

291
    } else {
292

293
294
295
296
297
        return ring_buffer->Put (buffer, a, volume);
    }

}

Emmanuel Milou's avatar
Emmanuel Milou committed
298
int MainBuffer::availForPut (CallID call_id)
299
300
{

301
    // ost::MutexLock guard (_mutex);
302

Emmanuel Milou's avatar
Emmanuel Milou committed
303
    RingBuffer* ringbuffer = getRingBuffer (call_id);
304
305

    if (ringbuffer == NULL)
Emmanuel Milou's avatar
Emmanuel Milou committed
306
        return 0;
307
    else
Emmanuel Milou's avatar
Emmanuel Milou committed
308
309
        return ringbuffer->AvailForPut();

310
311
}

312

Emmanuel Milou's avatar
Emmanuel Milou committed
313
int MainBuffer::getData (void *buffer, int toCopy, unsigned short volume, CallID call_id)
314
{
Alexandre Savard's avatar
Alexandre Savard committed
315
  // ost::MutexLock guard (_mutex);
316

Emmanuel Milou's avatar
Emmanuel Milou committed
317
    CallIDSet* callid_set = getCallIDSet (call_id);
318

Emmanuel Milou's avatar
Emmanuel Milou committed
319
    int nbSmplToCopy = toCopy / sizeof (SFLDataFormat);
320

Emmanuel Milou's avatar
Emmanuel Milou committed
321
322
    if (callid_set == NULL)
        return 0;
323

Emmanuel Milou's avatar
Emmanuel Milou committed
324
325
    if (callid_set->empty()) {
        return 0;
326
    }
Emmanuel Milou's avatar
Emmanuel Milou committed
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359

    if (callid_set->size() == 1) {

        CallIDSet::iterator iter_id = callid_set->begin();

        if (iter_id != callid_set->end()) {
            return getDataByID (buffer, toCopy, volume, *iter_id, call_id);
        } else
            return 0;
    } else {

        for (int k = 0; k < nbSmplToCopy; k++) {
            ( (SFLDataFormat*) (buffer)) [k] = 0;
        }

        int size = 0;

        CallIDSet::iterator iter_id = callid_set->begin();

        while (iter_id != callid_set->end()) {

            size = getDataByID (mixBuffer, toCopy, volume, (CallID) (*iter_id), call_id);

            if (size > 0) {
                for (int k = 0; k < nbSmplToCopy; k++) {
                    ( (SFLDataFormat*) (buffer)) [k] += mixBuffer[k];
                }
            }

            iter_id++;
        }

        return size;
360
    }
361
362
363
}


Emmanuel Milou's avatar
Emmanuel Milou committed
364
int MainBuffer::getDataByID (void *buffer, int toCopy, unsigned short volume, CallID call_id, CallID reader_id)
365
366
{

Emmanuel Milou's avatar
Emmanuel Milou committed
367
    RingBuffer* ring_buffer = getRingBuffer (call_id);
368

369
    if (!ring_buffer) {
Emmanuel Milou's avatar
Emmanuel Milou committed
370
        return 0;
371
372
    }

373
    return ring_buffer->Get (buffer, toCopy, volume, reader_id);
374
}
375
376


Emmanuel Milou's avatar
Emmanuel Milou committed
377
int MainBuffer::availForGet (CallID call_id)
378
{
379

Alexandre Savard's avatar
Alexandre Savard committed
380
  // ost::MutexLock guard (_mutex);
381

Emmanuel Milou's avatar
Emmanuel Milou committed
382
    CallIDSet* callid_set = getCallIDSet (call_id);
383

384
    if (callid_set == NULL)
Emmanuel Milou's avatar
Emmanuel Milou committed
385
        return 0;
386

Emmanuel Milou's avatar
Emmanuel Milou committed
387
    if (callid_set->empty()) {
388
        _debug ("MainBuffer: CallIDSet with ID: \"%s\" is empty!", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
389
        return 0;
390
    }
391

Emmanuel Milou's avatar
Emmanuel Milou committed
392
393
394
395
    if (callid_set->size() == 1) {
        CallIDSet::iterator iter_id = callid_set->begin();

        if ( (call_id != default_id) && (*iter_id == call_id)) {
Julien Bonjean's avatar
Julien Bonjean committed
396
            _debug ("This problem should not occur since we have %i element", (int) callid_set->size());
Emmanuel Milou's avatar
Emmanuel Milou committed
397
398
399
400
401
        }

        // else
        return availForGetByID (*iter_id, call_id);
    } else {
Julien Bonjean's avatar
Julien Bonjean committed
402
        // _debug("CallIDSet with ID: \"%s\" is a conference!", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
403
404
405
406
407
408
409
410
411
412
413
414
        int avail_bytes = 99999;
        int nb_bytes;
        CallIDSet::iterator iter_id = callid_set->begin();

        for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
            nb_bytes = availForGetByID (*iter_id, call_id);

            if ( (nb_bytes != 0) && (nb_bytes < avail_bytes))
                avail_bytes = nb_bytes;
        }

        return avail_bytes != 99999 ? avail_bytes : 0;
415
    }
416
417
418
419

}


Emmanuel Milou's avatar
Emmanuel Milou committed
420
int MainBuffer::availForGetByID (CallID call_id, CallID reader_id)
421
422
{

Emmanuel Milou's avatar
Emmanuel Milou committed
423
    if ( (call_id != default_id) && (reader_id == call_id)) {
424
        _error("MainBuffer: Error: RingBuffer has a readpointer on tiself");
425
426
    }

Emmanuel Milou's avatar
Emmanuel Milou committed
427
428
429
    RingBuffer* ringbuffer = getRingBuffer (call_id);

    if (ringbuffer == NULL) {
430
        _error("MainBuffer: Error: RingBuffer does not exist");
Emmanuel Milou's avatar
Emmanuel Milou committed
431
432
433
        return 0;
    } else
        return ringbuffer->AvailForGet (reader_id);
434
435

}
436
437


Emmanuel Milou's avatar
Emmanuel Milou committed
438
int MainBuffer::discard (int toDiscard, CallID call_id)
439
{
Julien Bonjean's avatar
Julien Bonjean committed
440
    // _debug("MainBuffer::discard");
441

Alexandre Savard's avatar
Alexandre Savard committed
442
    // ost::MutexLock guard (_mutex);
443

Emmanuel Milou's avatar
Emmanuel Milou committed
444
    CallIDSet* callid_set = getCallIDSet (call_id);
445

446
    if (callid_set == NULL)
Emmanuel Milou's avatar
Emmanuel Milou committed
447
        return 0;
448

Emmanuel Milou's avatar
Emmanuel Milou committed
449
    if (callid_set->empty()) {
Julien Bonjean's avatar
Julien Bonjean committed
450
        // _debug("CallIDSet with ID: \"%s\" is empty!", call_id.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
451
        return 0;
452
    }
453
454


Emmanuel Milou's avatar
Emmanuel Milou committed
455
    if (callid_set->size() == 1) {
456

Emmanuel Milou's avatar
Emmanuel Milou committed
457
        CallIDSet::iterator iter_id = callid_set->begin();
Alexandre Savard's avatar
Alexandre Savard committed
458

Emmanuel Milou's avatar
Emmanuel Milou committed
459
460
        return discardByID (toDiscard, *iter_id, call_id);
    } else {
461

Alexandre Savard's avatar
Alexandre Savard committed
462

Emmanuel Milou's avatar
Emmanuel Milou committed
463
464
465
466
467
468
469
        CallIDSet::iterator iter_id;

        for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
            discardByID (toDiscard, *iter_id, call_id);
        }

        return toDiscard;
470
    }
471
472
473
474

}


Emmanuel Milou's avatar
Emmanuel Milou committed
475
int MainBuffer::discardByID (int toDiscard, CallID call_id, CallID reader_id)
476
477
{

Emmanuel Milou's avatar
Emmanuel Milou committed
478
479
480
481
    RingBuffer* ringbuffer = getRingBuffer (call_id);

    if (ringbuffer == NULL)
        return 0;
482
    else
Emmanuel Milou's avatar
Emmanuel Milou committed
483
        return ringbuffer->Discard (toDiscard, reader_id);
484
485
486
487
488

}



Emmanuel Milou's avatar
Emmanuel Milou committed
489
void MainBuffer::flush (CallID call_id)
490
{
Alexandre Savard's avatar
Alexandre Savard committed
491
  // ost::MutexLock guard (_mutex);
492

Emmanuel Milou's avatar
Emmanuel Milou committed
493
    CallIDSet* callid_set = getCallIDSet (call_id);
494

495
    if (callid_set == NULL)
Emmanuel Milou's avatar
Emmanuel Milou committed
496
        return;
497

Emmanuel Milou's avatar
Emmanuel Milou committed
498
    if (callid_set->empty()) {
Julien Bonjean's avatar
Julien Bonjean committed
499
        // _debug("CallIDSet with ID: \"%s\" is empty!", call_id.c_str());
500
501
    }

Emmanuel Milou's avatar
Emmanuel Milou committed
502
503
504
505
    if (callid_set->size() == 1) {
        CallIDSet::iterator iter_id = callid_set->begin();
        flushByID (*iter_id, call_id);
    } else {
506

Emmanuel Milou's avatar
Emmanuel Milou committed
507
508
509
510
511
        CallIDSet::iterator iter_id;

        for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
            flushByID (*iter_id, call_id);
        }
512
    }
513
514
515

}

516
517
void MainBuffer::flushDefault()
{
Alexandre Savard's avatar
Alexandre Savard committed
518
  // ost::MutexLock guard (_mutex);
519

Emmanuel Milou's avatar
Emmanuel Milou committed
520
    flushByID (default_id, default_id);
521
522
523

}

524

Emmanuel Milou's avatar
Emmanuel Milou committed
525
void MainBuffer::flushByID (CallID call_id, CallID reader_id)
526
527
{

Emmanuel Milou's avatar
Emmanuel Milou committed
528
    RingBuffer* ringbuffer = getRingBuffer (call_id);
529

Emmanuel Milou's avatar
Emmanuel Milou committed
530
531
    if (ringbuffer != NULL)
        ringbuffer->flush (reader_id);
532
}
533
534


535
536
void MainBuffer::flushAllBuffers()
{
537

538
539
    RingBufferMap::iterator iter_buffer = _ringBufferMap.begin();

Emmanuel Milou's avatar
Emmanuel Milou committed
540
    while (iter_buffer != _ringBufferMap.end()) {
541

Emmanuel Milou's avatar
Emmanuel Milou committed
542
        iter_buffer->second->flushAll();
543

Emmanuel Milou's avatar
Emmanuel Milou committed
544
        iter_buffer++;
545
546
547
548
    }
}


549
550
void MainBuffer::stateInfo()
{
551
    _debug ("MainBuffer: State info");
552

553
554
555
556
    CallIDMap::iterator iter_call = _callIDMap.begin();

    // print each call and bound call ids

Emmanuel Milou's avatar
Emmanuel Milou committed
557
    while (iter_call != _callIDMap.end()) {
558

Emmanuel Milou's avatar
Emmanuel Milou committed
559
560
561
        std::string dbg_str ("    Call: ");
        dbg_str.append (std::string (iter_call->first.c_str()));
        dbg_str.append (std::string ("   is bound to: "));
562

Emmanuel Milou's avatar
Emmanuel Milou committed
563
        CallIDSet* call_id_set = (CallIDSet*) iter_call->second;
564

Emmanuel Milou's avatar
Emmanuel Milou committed
565
        CallIDSet::iterator iter_call_id = call_id_set->begin();
566

Emmanuel Milou's avatar
Emmanuel Milou committed
567
        while (iter_call_id != call_id_set->end()) {
568

Emmanuel Milou's avatar
Emmanuel Milou committed
569
570
            dbg_str.append (std::string (*iter_call_id));
            dbg_str.append (std::string (", "));
571

Emmanuel Milou's avatar
Emmanuel Milou committed
572
573
574
            iter_call_id++;
        }

575
        _debug ("%s", dbg_str.c_str());
Emmanuel Milou's avatar
Emmanuel Milou committed
576
577

        iter_call++;
578
579
580
581
582
583
584
    }

    // Print ringbuffers ids and readpointers
    RingBufferMap::iterator iter_buffer = _ringBufferMap.begin();

    while (iter_buffer != _ringBufferMap.end()) {

Emmanuel Milou's avatar
Emmanuel Milou committed
585
586
        RingBuffer* rbuffer = (RingBuffer*) iter_buffer->second;
        ReadPointer* rpointer = NULL;
587

Emmanuel Milou's avatar
Emmanuel Milou committed
588
        std::string dbg_str ("    Buffer: ");
589

590
591
        dbg_str.append (std::string (iter_buffer->first.c_str()));
        dbg_str.append (std::string ("   as read pointer: "));
592

Emmanuel Milou's avatar
Emmanuel Milou committed
593
594
        if (rbuffer)
            rpointer = rbuffer->getReadPointerList();
Emmanuel Milou's avatar
Emmanuel Milou committed
595

Emmanuel Milou's avatar
Emmanuel Milou committed
596
        if (rpointer) {
597

Emmanuel Milou's avatar
Emmanuel Milou committed
598
            ReadPointer::iterator iter_pointer = rpointer->begin();
Emmanuel Milou's avatar
Emmanuel Milou committed
599

Emmanuel Milou's avatar
Emmanuel Milou committed
600
            while (iter_pointer != rpointer->end()) {
601

Emmanuel Milou's avatar
Emmanuel Milou committed
602
                dbg_str.append (string (iter_pointer->first.c_str()));
Emmanuel Milou's avatar
Emmanuel Milou committed
603
                dbg_str.append (string (", "));
604

Emmanuel Milou's avatar
Emmanuel Milou committed
605
606
607
                iter_pointer++;
            }
        }
608

609
        _debug ("%s", dbg_str.c_str());
610
611

        iter_buffer++;
612
    }
613
614
615



Emmanuel Milou's avatar
Emmanuel Milou committed
616

617
}