Commit e332c5f2 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#1777] Code indentation

parent 0d62fc07
......@@ -30,7 +30,7 @@
#include <sys/poll.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
#include <dbus/dbus.h>
......@@ -98,9 +98,9 @@ void DefaultMutex::unlock()
DefaultMainLoop::DefaultMainLoop()
{
if(pipe(_terminateFd) < 0) {
if (pipe (_terminateFd) < 0) {
throw ErrorFailed ("unable to create unamed pipe");
}
}
}
DefaultMainLoop::~DefaultMainLoop()
......@@ -133,23 +133,24 @@ DefaultMainLoop::~DefaultMainLoop()
ti = tmp;
}
close(_terminateFd[0]);
close(_terminateFd[1]);
close (_terminateFd[0]);
close (_terminateFd[1]);
_mutex_t.unlock();
}
void DefaultMainLoop::terminate()
void DefaultMainLoop::terminate()
{
write(_terminateFd[1], " ", 1);
write (_terminateFd[1], " ", 1);
}
void DefaultMainLoop::dispatch()
{
{
_mutex_w.lock();
int nfd = _watches.size() + 1;
pollfd fds[nfd];
DefaultWatches::iterator wi = _watches.begin();
......@@ -165,9 +166,10 @@ void DefaultMainLoop::dispatch()
}
fds[nfd].fd = _terminateFd[0];
fds[nfd].events = POLLIN;
fds[nfd].revents = 0;
_mutex_w.unlock();
int wait_min = 10000;
......
......@@ -23,10 +23,10 @@
#include "manager.h"
Account::Account (const AccountID& accountID, std::string type) :
_accountID (accountID)
, _link (NULL)
, _enabled (false)
, _type (type)
_accountID (accountID)
, _link (NULL)
, _enabled (false)
, _type (type)
{
setRegistrationState (Unregistered);
}
......
......@@ -25,7 +25,6 @@
#include <cstdlib>
#include <ccrtp/rtp.h>
#include <assert.h>
#include <string>
#include <cstring>
#include <math.h>
#include <dlfcn.h>
......@@ -366,7 +365,7 @@ AudioRtpRTX::processDataEncode()
if (_audiocodec->getClockRate() != _layerSampleRate) {
int nb_sample_up = nbSample;
//_debug("_nbSample audiolayer->getMic(): %i \n", nbSample);
//_debug("_nbSample audiolayer->getMic(): %i \n", nbSample);
// Store the length of the mic buffer in samples for recording
_nSamplesMic = nbSample;
......
......@@ -25,13 +25,13 @@ static pa_channel_map channel_map ;
AudioStream::AudioStream (PulseLayerType * driver)
: _audiostream (NULL),
_context (driver->context),
_streamType (driver->type),
_streamDescription (driver->description),
_volume(),
flag (PA_STREAM_AUTO_TIMING_UPDATE),
sample_spec(),
_mainloop(driver->mainloop)
_context (driver->context),
_streamType (driver->type),
_streamDescription (driver->description),
_volume(),
flag (PA_STREAM_AUTO_TIMING_UPDATE),
sample_spec(),
_mainloop (driver->mainloop)
{
sample_spec.format = PA_SAMPLE_S16LE;
sample_spec.rate = 44100;
......@@ -56,54 +56,58 @@ AudioStream::connectStream()
return true;
}
static void success_cb(pa_stream *s, int success, void *userdata) {
static void success_cb (pa_stream *s, int success, void *userdata)
{
assert (s);
assert(s);
pa_threaded_mainloop * mainloop = (pa_threaded_mainloop *) userdata;
pa_threaded_mainloop_signal(mainloop, 0);
pa_threaded_mainloop_signal (mainloop, 0);
}
bool
AudioStream::drainStream(void) {
AudioStream::drainStream (void)
{
if (_audiostream) {
_debug("Draining stream\n");
_debug ("Draining stream\n");
pa_operation * operation;
pa_threaded_mainloop_lock(_mainloop);
if ((operation = pa_stream_drain(_audiostream, success_cb, _mainloop))) {
while (pa_operation_get_state(operation) != PA_OPERATION_DONE) {
if (!_context || pa_context_get_state(_context) != PA_CONTEXT_READY || !_audiostream || pa_stream_get_state(_audiostream) != PA_STREAM_READY) {
_debug("Connection died: %s\n", _context ? pa_strerror(pa_context_errno(_context)) : "NULL");
pa_operation_unref(operation);
pa_threaded_mainloop_lock (_mainloop);
if ( (operation = pa_stream_drain (_audiostream, success_cb, _mainloop))) {
while (pa_operation_get_state (operation) != PA_OPERATION_DONE) {
if (!_context || pa_context_get_state (_context) != PA_CONTEXT_READY || !_audiostream || pa_stream_get_state (_audiostream) != PA_STREAM_READY) {
_debug ("Connection died: %s\n", _context ? pa_strerror (pa_context_errno (_context)) : "NULL");
pa_operation_unref (operation);
break;
} else {
pa_threaded_mainloop_wait(_mainloop);
pa_threaded_mainloop_wait (_mainloop);
}
}
}
pa_threaded_mainloop_unlock(_mainloop);
pa_threaded_mainloop_unlock (_mainloop);
}
return true;
return true;
}
bool
AudioStream::disconnectStream (void)
{
_debug ("Destroy audio streams\n");
pa_threaded_mainloop_lock(_mainloop);
if(_audiostream) {
pa_threaded_mainloop_lock (_mainloop);
if (_audiostream) {
pa_stream_disconnect (_audiostream);
pa_stream_unref (_audiostream);
_audiostream = NULL;
}
pa_threaded_mainloop_unlock(_mainloop);
pa_threaded_mainloop_unlock (_mainloop);
return true;
}
......@@ -114,12 +118,12 @@ void
AudioStream::stream_state_callback (pa_stream* s, void* user_data)
{
pa_threaded_mainloop *m;
_debug ("AudioStream::stream_state_callback :: The state of the stream changed\n");
assert (s);
m = (pa_threaded_mainloop*) user_data;
assert(m);
assert (m);
switch (pa_stream_get_state (s)) {
......
......@@ -335,13 +335,13 @@ class G722 : public AudioCodec
int g722_encode_release() {
delete decode_s;
return 0;
return 0;
}
int g722_decode_release() {
delete encode_s;
return 0;
return 0;
}
int g722_decode (int16_t amp[], const uint8_t g722_data[], int len) {
......
......@@ -51,31 +51,32 @@ bool
PulseLayer::closeLayer (void)
{
_debug ("PulseLayer::closeLayer :: Destroy pulselayer\n");
// Commenting the line below will make the
// PulseLayer to close immediately, not
// waiting for the playback buffer to be
// emptied. It should not hurt.
// Commenting the line below will make the
// PulseLayer to close immediately, not
// waiting for the playback buffer to be
// emptied. It should not hurt.
playback->drainStream();
if(m) {
pa_threaded_mainloop_stop(m);
if (m) {
pa_threaded_mainloop_stop (m);
}
playback->disconnectStream();
record->disconnectStream();
if(context) {
if (context) {
pa_context_disconnect (context);
pa_context_unref (context);
context = NULL;
}
if(m) {
if (m) {
pa_threaded_mainloop_free (m);
m = NULL;
}
return true;
}
......@@ -177,7 +178,7 @@ bool PulseLayer::createStreams (pa_context* c)
playbackParam->description = PLAYBACK_STREAM_NAME;
playbackParam->volume = _manager->getSpkrVolume();
playbackParam->mainloop = m;
playback = new AudioStream (playbackParam);
playback->connectStream();
pa_stream_set_write_callback (playback->pulseStream(), audioCallback, this);
......@@ -189,7 +190,7 @@ bool PulseLayer::createStreams (pa_context* c)
recordParam->description = CAPTURE_STREAM_NAME;
recordParam->volume = _manager->getMicVolume();
recordParam->mainloop = m;
record = new AudioStream (recordParam);
record->connectStream();
pa_stream_set_read_callback (record->pulseStream() , audioCallback, this);
......@@ -229,7 +230,7 @@ bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int sample
_debug ("Connection Done!! \n");
return true;
return true;
}
void PulseLayer::closeCaptureStream (void)
......
......@@ -258,11 +258,11 @@ ConfigTree::saveConfigTree (const std::string& fileName)
}
file.close();
if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
_debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
if (chmod (fileName.c_str(), S_IRUSR | S_IWUSR)) {
_debug ("Failed to set permission on configuration file because: %s\n",strerror (errno));
}
return true;
}
......@@ -274,7 +274,7 @@ int
ConfigTree::populateFromFile (const std::string& fileName)
{
bool out = false;
if (fileName.empty()) {
return 0;
}
......@@ -339,11 +339,11 @@ ConfigTree::populateFromFile (const std::string& fileName)
}
file.close();
if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
_debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
if (chmod (fileName.c_str(), S_IRUSR | S_IWUSR)) {
_debug ("Failed to set permission on configuration file because: %s\n",strerror (errno));
}
return 1;
}
......
......@@ -155,7 +155,7 @@ class ConfigTree
* List of sections. Each sections has an ItemList as child
*/
SectionMap _sections;
friend class ConfigTreeIterator;
public:
......
......@@ -27,12 +27,12 @@
#define EMPTY_STRING "empty"
HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string account_id)
: _timestamp_start (timestamp_start),
_timestamp_stop (timestamp_stop),
_call_type (call_type),
_name (name),
_number (number),
_account_id (account_id)
: _timestamp_start (timestamp_start),
_timestamp_stop (timestamp_stop),
_call_type (call_type),
_name (name),
_number (number),
_account_id (account_id)
{
}
......
......@@ -23,9 +23,9 @@
#include <cc++/file.h>
#include <time.h>
HistoryManager::HistoryManager ()
: _history_loaded (false),
_history_path ("")
HistoryManager::HistoryManager ()
: _history_loaded (false),
_history_path ("")
{
}
......
......@@ -86,29 +86,30 @@ main (int argc, char **argv)
}
} else {
// PID file exists. Check the former process still alive or not. If alive, give user a hint.
char *res;
char *res;
res = fgets (cOldPid, 64, fp);
if (res == NULL) perror ("Error getting string from stream");
else
{
fclose (fp);
if (kill (atoi (cOldPid), 0) == SUCCESS) {
fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
exit (-1);
} else {
if ( (fp = fopen (homepid,"w")) == NULL) {
fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
exit (-1);
} else {
fputs (cPid , fp);
fclose (fp);
}
}
}
}
else {
fclose (fp);
if (kill (atoi (cOldPid), 0) == SUCCESS) {
fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
exit (-1);
} else {
if ( (fp = fopen (homepid,"w")) == NULL) {
fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
exit (-1);
} else {
fputs (cPid , fp);
fclose (fp);
}
}
}
}
int sessionPort = 0;
if (argc == 2) {
......
......@@ -1620,14 +1620,14 @@ ManagerImpl::getAudioOutputDeviceList (void)
{
_debug ("Get audio output device list\n");
AlsaLayer *layer;
std::vector <std::string> devices;
std::vector <std::string> devices;
layer = dynamic_cast<AlsaLayer*> (getAudioDriver ());
if (layer)
devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
return devices;
return devices;
}
/**
......@@ -1661,14 +1661,14 @@ std::vector<std::string>
ManagerImpl::getAudioInputDeviceList (void)
{
AlsaLayer *audiolayer;
std::vector <std::string> devices;
std::vector <std::string> devices;
audiolayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
if (audiolayer)
devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
return devices;
return devices;
}
/**
......@@ -1950,7 +1950,7 @@ void ManagerImpl::setAudioManager (const int32_t& api)
switchAudioManager();
return;
}
int32_t
......@@ -1983,10 +1983,10 @@ ManagerImpl::getAudioDeviceIndex (const std::string name)
alsalayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
if (alsalayer)
return alsalayer -> soundCardGetIndex (name);
else
return 0;
if (alsalayer)
return alsalayer -> soundCardGetIndex (name);
else
return 0;
}
std::string
......@@ -2205,9 +2205,9 @@ void ManagerImpl::setMicVolume (unsigned short mic_vol)
void ManagerImpl::setSipPort (int port)
{
_debug("Setting to new port %d\n", port);
setConfig(PREFERENCES, CONFIG_SIP_PORT, port);
_debug ("Setting to new port %d\n", port);
setConfig (PREFERENCES, CONFIG_SIP_PORT, port);
this->restartPJSIP ();
}
......@@ -2464,12 +2464,13 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
a.insert (std::pair<std::string, std::string> (PASSWORD, getConfigString (accountID, PASSWORD)));
a.insert (std::pair<std::string, std::string> (HOSTNAME, getConfigString (accountID, HOSTNAME)));
a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_MAILBOX, getConfigString (accountID, CONFIG_ACCOUNT_MAILBOX)));
if (getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE).empty()) {
a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, DFT_EXPIRE_VALUE));
} else {
a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE)));
}
return a;
}
......@@ -2682,7 +2683,7 @@ ManagerImpl::loadAccountMap()
short nbAccount = 0;
TokenList sections = _config.getSections();
std::string accountType;
Account *tmpAccount = 0;
Account *tmpAccount = 0;
std::vector <std::string> account_order;
TokenList::iterator iter = sections.begin();
......
......@@ -207,8 +207,8 @@ bool AudioRecord::setRecording()
recordingEnabled_ = true; // once opend file, start recording
}
// WARNING: Unused return value
return true;
// WARNING: Unused return value
return true;
}
......@@ -348,7 +348,7 @@ bool AudioRecord::openExistingRawFile()
return false;
}
return true;
return true;
}
......@@ -391,7 +391,7 @@ bool AudioRecord::openExistingWavFile()
if (fseek (fp, 4 , SEEK_END) != 0)
_debug ("AudioRecors::OpenExistingWavFile : 2.Couldn't seek at the en of the file \n");
return true;
return true;
}
......
......@@ -35,14 +35,14 @@ static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
Sdp::Sdp (pj_pool_t *pool)
: _local_media_cap()
, _session_media (0)
, _negociator (NULL)
, _ip_addr ("")
, _local_offer (NULL)
, _negociated_offer (NULL)
, _pool (NULL)
, _local_extern_audio_port (0)
: _local_media_cap()
, _session_media (0)
, _negociator (NULL)
, _ip_addr ("")
, _local_offer (NULL)
, _negociated_offer (NULL)
, _pool (NULL)
, _local_extern_audio_port (0)
{
_pool = pool;
}
......@@ -211,60 +211,63 @@ int Sdp::receiving_initial_offer (pjmedia_sdp_session* remote)
return PJ_SUCCESS;
}
pj_status_t Sdp::check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata)
pj_status_t Sdp::check_sdp_answer (pjsip_inv_session *inv, pjsip_rx_data *rdata)
{
static const pj_str_t str_application = { (char*) "application", 11 };
static const pj_str_t str_sdp = { (char*) "sdp", 3 };
pj_status_t status;
pjsip_msg * message = NULL;
pjmedia_sdp_session * remote_sdp = NULL;
if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
if (pjmedia_sdp_neg_get_state (inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
message = rdata->msg_info.msg;
if(message == NULL) {