Select Git revision
sipaccount.cpp
-
Instantiation and initialization of ICE are done in a single stage (in the class constructor). To initialize the ICE instance, connection information must first be gathered asynchronously. However, when sharing ICE media instance between subcalls, it's better to have a valid ICE instance as soon as possible (even if not fully initialized) to proceed with the call initialization process, then wait for ICE initialization to start the call. Thus, the ICE instantiation will be performed synchronously as soon as the parent (main) call is created, then it will be initialized asynchronously when the connection info are ready. Gitlab: #619 Change-Id: I9c97516238f1a690603975ec968c8c6733155d4a
Instantiation and initialization of ICE are done in a single stage (in the class constructor). To initialize the ICE instance, connection information must first be gathered asynchronously. However, when sharing ICE media instance between subcalls, it's better to have a valid ICE instance as soon as possible (even if not fully initialized) to proceed with the call initialization process, then wait for ICE initialization to start the call. Thus, the ICE instantiation will be performed synchronously as soon as the parent (main) call is created, then it will be initialized asynchronously when the connection info are ready. Gitlab: #619 Change-Id: I9c97516238f1a690603975ec968c8c6733155d4a
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ringbuffer.cpp 4.54 KiB
/*
* Copyright (C) 2004, 2005, 2006 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
*
* Portions (c) Dominic Mazzoni (Audacity)
*
* 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 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* 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.
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "ringbuffer.h"
#include "../global.h"
#define MIN_BUFFER_SIZE 1280
// Create a ring buffer with 'size' bytes
RingBuffer::RingBuffer(int size) {
mBufferSize = (size > MIN_BUFFER_SIZE ? size : MIN_BUFFER_SIZE);
mStart = 0;
mEnd = 0;
mBuffer = new unsigned char[mBufferSize];
assert (mBuffer != NULL);
}
// Free memory on object deletion
RingBuffer::~RingBuffer() {
delete[] mBuffer; mBuffer = NULL;
}
void
RingBuffer::flush (void) {
mStart = 0;
mEnd = 0;
}
int
RingBuffer::Len() const {
return (mEnd + mBufferSize - mStart) % mBufferSize;
}
void
RingBuffer::debug() {
_debug("Start=%d; End=%d; BufferSize=%d\n", mStart, mEnd, mBufferSize);
}
//
// For the writer only:
//
int
RingBuffer::AvailForPut() const {
// Always keep 4 bytes safe (?)
return (mBufferSize-4) - Len();
}