Commit a9f3dc57 authored by Tristan Matthews's avatar Tristan Matthews

* #7127: apply astylerc to daemon and client.

99 % of these are just whitespace changes. Some unnecessary includes
removed as well
parent 58a31825
......@@ -5,12 +5,14 @@
# Savoir-faire Linux Inc
# http://www.sflphone.org
style=k&r # Kernighan & Ritchie style formatting/indenting uses linux bracket
indent=spaces=4 # Use spaces instead of tabs for indentation
indent-classes # Indent 'class' and 'struct' blocks so that the blocks 'public:', 'protected:' and 'private:' are indented
indent-switches # Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block
break-blocks # Pad empty lines around header blocks (e.g. 'if', 'while'...).
style=stroustrup # stroustrup style http://astyle.sourceforge.net/astyle.html#_style=stroustrup
indent=spaces=4 # Use spaces instead of tabs for indentation
indent-classes # Indent 'class' and 'struct' blocks so that the blocks 'public:', 'protected:' and 'private:' are indented
indent-switches # Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block
break-blocks # Pad empty lines around header blocks (e.g. 'if', 'while'...).
brackets=linux
unpad=paren
formatted
-d
unpad-paren # Remove unwanted space around parentheses
pad-header # Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...)
formatted # only display files that have changed
recursive # recursively enter subdirs
suffix=none # don't create backup files (that's what version control is for)
......@@ -36,8 +36,7 @@
* Interface for both audio codecs as well as video codecs.
*/
namespace sfl {
class Codec
{
class Codec {
public:
Codec() {};
virtual ~Codec() {}
......
......@@ -33,18 +33,18 @@
#include "account.h"
#include "manager.h"
Account::Account (const std::string& accountID, const std::string &type) :
accountID_ (accountID)
, link_ (NULL)
, enabled_ (true)
, type_ (type)
, registrationState_ (Unregistered)
, codecOrder_ ()
, codecStr_ ("")
, ringtonePath_ ("/usr/share/sflphone/ringtones/konga.ul")
, ringtoneEnabled_ (true)
, displayName_ ("")
, userAgent_ ("SFLphone")
Account::Account(const std::string& accountID, const std::string &type) :
accountID_(accountID)
, link_(NULL)
, enabled_(true)
, type_(type)
, registrationState_(Unregistered)
, codecOrder_()
, codecStr_("")
, ringtonePath_("/usr/share/sflphone/ringtones/konga.ul")
, ringtoneEnabled_(true)
, displayName_("")
, userAgent_("SFLphone")
{
// Initialize the codec order, used when creating a new account
loadDefaultCodecs();
......@@ -54,7 +54,7 @@ Account::~Account()
{
}
void Account::setRegistrationState (const RegistrationState &state)
void Account::setRegistrationState(const RegistrationState &state)
{
if (state != registrationState_) {
registrationState_ = state;
......@@ -71,20 +71,20 @@ void Account::loadDefaultCodecs()
// Initialize codec
std::vector <std::string> codecList;
codecList.push_back ("0");
codecList.push_back ("3");
codecList.push_back ("8");
codecList.push_back ("9");
codecList.push_back ("110");
codecList.push_back ("111");
codecList.push_back ("112");
setActiveCodecs (codecList);
codecList.push_back("0");
codecList.push_back("3");
codecList.push_back("8");
codecList.push_back("9");
codecList.push_back("110");
codecList.push_back("111");
codecList.push_back("112");
setActiveCodecs(codecList);
}
void Account::setActiveCodecs (const std::vector <std::string> &list)
void Account::setActiveCodecs(const std::vector <std::string> &list)
{
// first clear the previously stored codecs
codecOrder_.clear();
......@@ -93,12 +93,12 @@ void Account::setActiveCodecs (const std::vector <std::string> &list)
// we used the CodecOrder vector to save the order.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end();
++iter) {
int payload = std::atoi (iter->c_str());
codecOrder_.push_back ( (int) payload);
int payload = std::atoi(iter->c_str());
codecOrder_.push_back((int) payload);
}
// update the codec string according to new codec selection
codecStr_ = ManagerImpl::serialize (list);
codecStr_ = ManagerImpl::serialize(list);
}
std::string Account::mapStateNumberToString(RegistrationState state)
......
......@@ -143,12 +143,11 @@ static const char * const ringtonePathKey = "ringtonePath";
static const char * const ringtoneEnabledKey = "ringtoneEnabled";
static const char * const displayNameKey = "displayName";
class Account : public Serializable
{
class Account : public Serializable {
public:
Account (const std::string& accountID, const std::string &type);
Account(const std::string& accountID, const std::string &type);
/**
* Virtual destructor
......@@ -159,15 +158,15 @@ class Account : public Serializable
* Method called by the configuration engine to serialize instance's information
* into configuration file.
*/
virtual void serialize (Conf::YamlEmitter *emitter) = 0;
virtual void serialize(Conf::YamlEmitter *emitter) = 0;
/**
* Method called by the configuration engine to restore instance internal state
* from configuration file.
*/
virtual void unserialize (Conf::MappingNode *map) = 0;
virtual void unserialize(Conf::MappingNode *map) = 0;
virtual void setAccountDetails (std::map<std::string, std::string> details) = 0;
virtual void setAccountDetails(std::map<std::string, std::string> details) = 0;
virtual std::map<std::string, std::string> getAccountDetails() const = 0;
......@@ -213,7 +212,7 @@ class Account : public Serializable
return enabled_;
}
void setEnabled (bool enable) {
void setEnabled(bool enable) {
enabled_ = enable;
}
......@@ -221,31 +220,31 @@ class Account : public Serializable
* Set the registration state of the specified link
* @param state The registration state of underlying VoIPLink
*/
void setRegistrationState (const RegistrationState &state);
void setRegistrationState(const RegistrationState &state);
/* They should be treated like macro definitions by the C++ compiler */
std::string getUsername (void) const {
std::string getUsername(void) const {
return username_;
}
std::string getHostname (void) const {
std::string getHostname(void) const {
return hostname_;
}
void setHostname (const std::string &hostname) {
void setHostname(const std::string &hostname) {
hostname_ = hostname;
}
std::string getAlias (void) const {
std::string getAlias(void) const {
return alias_;
}
void setAlias (const std::string &alias) {
void setAlias(const std::string &alias) {
alias_ = alias;
}
std::string getType (void) const {
std::string getType(void) const {
return type_;
}
void setType (const std::string &type) {
void setType(const std::string &type) {
type_ = type;
}
......@@ -253,7 +252,7 @@ class Account : public Serializable
* Accessor to data structures
* @return CodecOrder& The list that reflects the user's choice
*/
const CodecOrder& getActiveCodecs (void) const {
const CodecOrder& getActiveCodecs(void) const {
return codecOrder_;
}
......@@ -261,40 +260,40 @@ class Account : public Serializable
* Update both the codec order structure and the codec string used for
* SDP offer and configuration respectively
*/
void setActiveCodecs (const std::vector <std::string>& list);
void setActiveCodecs(const std::vector <std::string>& list);
std::string getRingtonePath (void) const {
std::string getRingtonePath(void) const {
return ringtonePath_;
}
void setRingtonePath (const std::string &path) {
void setRingtonePath(const std::string &path) {
ringtonePath_ = path;
}
bool getRingtoneEnabled (void) const {
bool getRingtoneEnabled(void) const {
return ringtoneEnabled_;
}
void setRingtoneEnabled (bool enable) {
void setRingtoneEnabled(bool enable) {
ringtoneEnabled_ = enable;
}
std::string getDisplayName (void) const {
std::string getDisplayName(void) const {
return displayName_;
}
void setDisplayName (const std::string &name) {
void setDisplayName(const std::string &name) {
displayName_ = name;
}
std::string getMailBox (void) const {
std::string getMailBox(void) const {
return mailBox_;
}
void setMailBox (const std::string &mb) {
void setMailBox(const std::string &mb) {
mailBox_ = mb;
}
private:
// copy constructor
Account (const Account& rh);
Account(const Account& rh);
// assignment operator
Account& operator= (const Account& rh);
......@@ -303,10 +302,10 @@ class Account : public Serializable
* Helper function used to load the default codec order from the codec factory
* setActiveCodecs is called to sync both codecOrder_ and codecStr_
*/
void loadDefaultCodecs (void);
void loadDefaultCodecs(void);
protected:
static std::string mapStateNumberToString (RegistrationState state);
static std::string mapStateNumberToString(RegistrationState state);
/**
* Account ID are assign in constructor and shall not changed
......
This diff is collapsed.
......@@ -47,32 +47,31 @@ class AlsaThread;
/** Associate a sound card index to its string description */
typedef std::pair<int , std::string> HwIDPair;
class AlsaLayer : public AudioLayer
{
class AlsaLayer : public AudioLayer {
public:
/**
* Constructor
*/
AlsaLayer ();
AlsaLayer();
/**
* Destructor
*/
~AlsaLayer (void);
~AlsaLayer(void);
/**
* Start the capture stream and prepare the playback stream.
* The playback starts accordingly to its threshold
* ALSA Library API
*/
void startStream (void);
void startStream(void);
/**
* Stop the playback and capture streams.
* Drops the pending frames and put the capture and playback handles to PREPARED state
* ALSA Library API
*/
void stopStream (void);
void stopStream(void);
/**
* Concatenate two strings. Used to build a valid pcm device name.
......@@ -80,7 +79,7 @@ class AlsaLayer : public AudioLayer
* @param card the sound card number
* @return std::string the concatenated string
*/
std::string buildDeviceTopo (const std::string &plugin, int card);
std::string buildDeviceTopo(const std::string &plugin, int card);
/**
* Scan the sound card available on the system
......@@ -90,7 +89,7 @@ class AlsaLayer : public AudioLayer
* SFL_PCM_BOTH
* @return std::vector<std::string> The vector containing the string description of the card
*/
std::vector<std::string> getSoundCardsInfo (int stream);
std::vector<std::string> getSoundCardsInfo(int stream);
/**
* Check if the given index corresponds to an existing sound card and supports the specified streaming mode
......@@ -109,12 +108,12 @@ class AlsaLayer : public AudioLayer
* @param description The string description
* @return int Its index
*/
int soundCardGetIndex (const std::string &description);
int soundCardGetIndex(const std::string &description);
void playback(int maxSamples);
void capture(void);
void audioCallback (void);
void audioCallback(void);
/**
* Get the index of the audio card for capture
......@@ -135,10 +134,10 @@ class AlsaLayer : public AudioLayer
}
/**
* Get the index of the audio card for ringtone (could be differnet from playback)
* @return int The index of the card used for ringtone
* 0 for the first available card on the system, 1 ...
*/
* Get the index of the audio card for ringtone (could be differnet from playback)
* @return int The index of the card used for ringtone
* 0 for the first available card on the system, 1 ...
*/
int getIndexRing() const {
return indexRing_;
}
......@@ -170,7 +169,7 @@ class AlsaLayer : public AudioLayer
// Copy Constructor
AlsaLayer (const AlsaLayer& rh);
AlsaLayer(const AlsaLayer& rh);
// Assignment Operator
AlsaLayer& operator= (const AlsaLayer& rh);
......@@ -179,17 +178,17 @@ class AlsaLayer : public AudioLayer
* Drop the pending frames and close the capture device
* ALSA Library API
*/
void closeCaptureStream (void);
void stopCaptureStream (void);
void startCaptureStream (void);
void prepareCaptureStream (void);
void closeCaptureStream(void);
void stopCaptureStream(void);
void startCaptureStream(void);
void prepareCaptureStream(void);
void closePlaybackStream (void);
void stopPlaybackStream (void);
void startPlaybackStream (void);
void preparePlaybackStream (void);
void closePlaybackStream(void);
void stopPlaybackStream(void);
void startPlaybackStream(void);
void preparePlaybackStream(void);
bool alsa_set_params (snd_pcm_t *pcm_handle);
bool alsa_set_params(snd_pcm_t *pcm_handle);
/**
* Copy a data buffer in the internal ring buffer
......@@ -197,7 +196,7 @@ class AlsaLayer : public AudioLayer
* @param buffer The data to be copied
* @param length The size of the buffer
*/
void write (void* buffer, int length, snd_pcm_t *handle);
void write(void* buffer, int length, snd_pcm_t *handle);
/**
* Read data from the internal ring buffer
......@@ -206,7 +205,7 @@ class AlsaLayer : public AudioLayer
* @param toCopy The number of bytes to get
* @return int The number of frames actually read
*/
int read (void* buffer, int toCopy);
int read(void* buffer, int toCopy);
/**
* Handles to manipulate playback stream
......
......@@ -34,70 +34,70 @@
#include "audio/dcblocker.h"
#include "manager.h"
AudioLayer::AudioLayer ()
: isStarted_ (false)
, urgentRingBuffer_ (SIZEBUF, Call::DEFAULT_ID)
, audioSampleRate_(Manager::instance().getMainBuffer()->getInternalSamplingRate())
, mutex_ ()
, audioPref(Manager::instance().audioPreference)
, converter_ (new SamplerateConverter(audioSampleRate_))
, lastNotificationTime_ (0)
AudioLayer::AudioLayer()
: isStarted_(false)
, urgentRingBuffer_(SIZEBUF, Call::DEFAULT_ID)
, audioSampleRate_(Manager::instance().getMainBuffer()->getInternalSamplingRate())
, mutex_()
, audioPref(Manager::instance().audioPreference)
, converter_(new SamplerateConverter(audioSampleRate_))
, lastNotificationTime_(0)
{
urgentRingBuffer_.createReadPointer();
}
AudioLayer::~AudioLayer ()
AudioLayer::~AudioLayer()
{
delete converter_;
delete converter_;
}
void AudioLayer::flushMain (void)
void AudioLayer::flushMain(void)
{
ost::MutexLock guard (mutex_);
ost::MutexLock guard(mutex_);
// should pass call id
Manager::instance().getMainBuffer()->flushAllBuffers();
}
void AudioLayer::flushUrgent (void)
void AudioLayer::flushUrgent(void)
{
ost::MutexLock guard (mutex_);
ost::MutexLock guard(mutex_);
urgentRingBuffer_.flushAll();
}
void AudioLayer::putUrgent (void* buffer, int toCopy)
void AudioLayer::putUrgent(void* buffer, int toCopy)
{
ost::MutexLock guard (mutex_);
urgentRingBuffer_.Put (buffer, toCopy);
ost::MutexLock guard(mutex_);
urgentRingBuffer_.Put(buffer, toCopy);
}
// Notify (with a beep) an incoming call when there is already a call in progress
void AudioLayer::notifyincomingCall()
{
if (!Manager::instance().incomingCallWaiting())
return;
return;
time_t now = time(NULL);
time_t now = time(NULL);
// Notify maximum once every 5 seconds
if (difftime(now, lastNotificationTime_) < 5)
return;
// Notify maximum once every 5 seconds
if (difftime(now, lastNotificationTime_) < 5)
return;
lastNotificationTime_ = now;
lastNotificationTime_ = now;
// Enable notification only if more than one call
if (!Manager::instance().hasCurrentCall())
return;
// Enable notification only if more than one call
if (!Manager::instance().hasCurrentCall())
return;
Tone tone ("440/160", getSampleRate());
unsigned int nbSample = tone.getSize();
SFLDataFormat buf[nbSample];
tone.getNext (buf, nbSample);
Tone tone("440/160", getSampleRate());
unsigned int nbSample = tone.getSize();
SFLDataFormat buf[nbSample];
tone.getNext(buf, nbSample);
/* Put the data in the urgent ring buffer */
Manager::instance().audioLayerMutexLock();
flushUrgent();
putUrgent (buf, sizeof buf);
Manager::instance().audioLayerMutexUnlock();
/* Put the data in the urgent ring buffer */
Manager::instance().audioLayerMutexLock();
flushUrgent();
putUrgent(buf, sizeof buf);
Manager::instance().audioLayerMutexUnlock();
}
......@@ -50,14 +50,13 @@
class MainBuffer;
namespace ost {
class Time;
class Time;
}
class AudioLayer
{
class AudioLayer {
private:
//copy constructor
AudioLayer (const AudioLayer& rh);
AudioLayer(const AudioLayer& rh);
// assignment operator
AudioLayer& operator= (const AudioLayer& rh);
......@@ -66,28 +65,30 @@ class AudioLayer
/**
* Constructor
*/
AudioLayer ();
AudioLayer();
/**
* Destructor
*/
virtual ~AudioLayer (void);
virtual ~AudioLayer(void);
/**
* Start the capture stream and prepare the playback stream.
* The playback starts accordingly to its threshold
* ALSA Library API
*/
virtual void startStream (void) = 0;
virtual void startStream(void) = 0;
/**
* Stop the playback and capture streams.
* Drops the pending frames and put the capture and playback handles to PREPARED state
* ALSA Library API
*/
virtual void stopStream (void) = 0;
virtual void stopStream(void) = 0;
bool isStarted(void) const { return isStarted_; }
bool isStarted(void) const {
return isStarted_;
}
/**
* Send a chunk of data to the hardware buffer to start the playback
......@@ -95,11 +96,11 @@ class AudioLayer
* @param buffer The buffer containing the data to be played ( ringtones )
* @param toCopy The size of the buffer
*/
void putUrgent (void* buffer, int toCopy);
void putUrgent(void* buffer, int toCopy);
void flushMain (void);
void flushMain(void);
void flushUrgent (void);
void flushUrgent(void);
/**
......@@ -114,14 +115,14 @@ class AudioLayer
/**
* Get the mutex lock for the entire audio layer
*/
ost::Mutex* getMutexLock (void) {
ost::Mutex* getMutexLock(void) {
return &mutex_;
}
void notifyincomingCall (void);
void notifyincomingCall(void);
protected:
/**
* Wether or not the audio layer stream is started
*/
......
......@@ -47,13 +47,13 @@ AudioLoop::~AudioLoop()
}
void
AudioLoop::getNext (SFLDataFormat* output, size_t total_samples, short volume)
AudioLoop::getNext(SFLDataFormat* output, size_t total_samples, short volume)
{
size_t pos = pos_;
if (size_ == 0) {
_error("AudioLoop: Error: Audio loop size is 0");
return;
_error("AudioLoop: Error: Audio loop size is 0");
return;
}
while (total_samples) {
......@@ -67,6 +67,7 @@ AudioLoop::getNext (SFLDataFormat* output, size_t total_samples, short volume)
if (volume != 100) {
double gain = volume * 0.01;
for (size_t i = 0; i < samples; i++) {
*output *= gain;
output++;
......
......@@ -33,25 +33,17 @@
#ifndef __AUDIOLOOP_H__
#define __AUDIOLOOP_H__
#include <string>
#include "global.h" // for int16 declaration
#include "global.h" // for SFLDataFormat