Browse code

unifies indentation level in all source files to 2 (-i2)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@261 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 07/03/2007 20:34:39
Showing 106 changed files
... ...
@@ -34,195 +34,195 @@ using std::set;
34 34
 
35 35
 /* AudioQueue */
36 36
 AmAudioQueue::AmAudioQueue() 
37
-    : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16)) // we get and put in this (internal) fmt
37
+  : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16)) // we get and put in this (internal) fmt
38 38
 {
39
-	sarr.clear_all();
39
+  sarr.clear_all();
40 40
 }
41 41
 
42 42
 AmAudioQueue::~AmAudioQueue() { 
43
-    set<AmAudio*> deleted_audios; // don't delete them twice
44
-    for (list<AudioQueueEntry>::iterator it = inputQueue.begin();it != inputQueue.end(); it++) {
45
-	if (deleted_audios.find(it->audio) == deleted_audios.end()) {
46
-	    deleted_audios.insert(it->audio);
47
-	    delete it->audio;
48
-	}
43
+  set<AmAudio*> deleted_audios; // don't delete them twice
44
+  for (list<AudioQueueEntry>::iterator it = inputQueue.begin();it != inputQueue.end(); it++) {
45
+    if (deleted_audios.find(it->audio) == deleted_audios.end()) {
46
+      deleted_audios.insert(it->audio);
47
+      delete it->audio;
49 48
     }
49
+  }
50 50
 	
51
-    for (list<AudioQueueEntry>::iterator it = outputQueue.begin();it != outputQueue.end(); it++) {
52
-	if (deleted_audios.find(it->audio) == deleted_audios.end()) {
53
-	    deleted_audios.insert(it->audio);
54
-	    delete it->audio;
55
-	}
51
+  for (list<AudioQueueEntry>::iterator it = outputQueue.begin();it != outputQueue.end(); it++) {
52
+    if (deleted_audios.find(it->audio) == deleted_audios.end()) {
53
+      deleted_audios.insert(it->audio);
54
+      delete it->audio;
56 55
     }
56
+  }
57 57
 }
58 58
 
59 59
 int AmAudioQueue::write(unsigned int user_ts, unsigned int size) {
60
-    inputQueue_mut.lock();
61
-    unsigned int size_trav = size;
62
-    for (list<AudioQueueEntry>::iterator it = inputQueue.begin(); it != inputQueue.end(); it++) {
63
-	if (it->put) {
64
-	    if ((size_trav = it->audio->put(user_ts, samples, size_trav)) < 0)
65
-		break;
66
-	}
67
-	if (it->get) {
68
-	    if ((size_trav = it->audio->get(user_ts, samples, size_trav >> 1)) < 0)
69
-		break;
70
-	}
60
+  inputQueue_mut.lock();
61
+  unsigned int size_trav = size;
62
+  for (list<AudioQueueEntry>::iterator it = inputQueue.begin(); it != inputQueue.end(); it++) {
63
+    if (it->put) {
64
+      if ((size_trav = it->audio->put(user_ts, samples, size_trav)) < 0)
65
+	break;
71 66
     }
72
-    inputQueue_mut.unlock();
73
-    return size_trav;
67
+    if (it->get) {
68
+      if ((size_trav = it->audio->get(user_ts, samples, size_trav >> 1)) < 0)
69
+	break;
70
+    }
71
+  }
72
+  inputQueue_mut.unlock();
73
+  return size_trav;
74 74
 }
75 75
 
76 76
 int AmAudioQueue::read(unsigned int user_ts, unsigned int size) {
77
-    outputQueue_mut.lock();
78
-    unsigned int size_trav = size;
79
-    for (list<AudioQueueEntry>::iterator it = outputQueue.begin(); it != outputQueue.end(); it++) {
80
-	if (it->put) {
81
-	    if ((size_trav = it->audio->put(user_ts, samples, size_trav)) < 0)
82
-		break;
83
-	}
84
-	if (it->get) {
85
-	    if ((size_trav = it->audio->get(user_ts, samples, size_trav >> 1)) < 0)
86
-		break;
87
-	}
77
+  outputQueue_mut.lock();
78
+  unsigned int size_trav = size;
79
+  for (list<AudioQueueEntry>::iterator it = outputQueue.begin(); it != outputQueue.end(); it++) {
80
+    if (it->put) {
81
+      if ((size_trav = it->audio->put(user_ts, samples, size_trav)) < 0)
82
+	break;
83
+    }
84
+    if (it->get) {
85
+      if ((size_trav = it->audio->get(user_ts, samples, size_trav >> 1)) < 0)
86
+	break;
88 87
     }
89
-    outputQueue_mut.unlock();
90
-    return size_trav;
88
+  }
89
+  outputQueue_mut.unlock();
90
+  return size_trav;
91 91
 }
92 92
 
93 93
 void AmAudioQueue::pushAudio(AmAudio* audio, QueueType type, Pos pos, bool write, bool read) {
94
-    AmMutex* q_mut; 
95
-    list<AudioQueueEntry>* q; 
96
-    switch (type) {
97
-	case OutputQueue: 
98
-	    q_mut = &outputQueue_mut;
99
-	    q = &outputQueue;
100
-	    break;
101
-	case InputQueue: 
102
-	default:  q_mut = &inputQueue_mut;
103
-	    q = &inputQueue;
104
-	    break;
105
-    };
106
-    q_mut->lock();
107
-    if (pos == Front)
108
-	q->push_front(AudioQueueEntry(audio, write, read));
109
-    else
110
-	q->push_back(AudioQueueEntry(audio, write, read));
111
-    q_mut->unlock();
94
+  AmMutex* q_mut; 
95
+  list<AudioQueueEntry>* q; 
96
+  switch (type) {
97
+  case OutputQueue: 
98
+    q_mut = &outputQueue_mut;
99
+    q = &outputQueue;
100
+    break;
101
+  case InputQueue: 
102
+  default:  q_mut = &inputQueue_mut;
103
+    q = &inputQueue;
104
+    break;
105
+  };
106
+  q_mut->lock();
107
+  if (pos == Front)
108
+    q->push_front(AudioQueueEntry(audio, write, read));
109
+  else
110
+    q->push_back(AudioQueueEntry(audio, write, read));
111
+  q_mut->unlock();
112 112
 }
113 113
 
114 114
 int AmAudioQueue::popAudio(QueueType type, Pos pos) {
115
-    AmAudio* audio = popAndGetAudio(type, pos);
116
-    if (audio) {
117
-	delete audio;
118
-	return 0;
119
-    }
120
-    return -1; // error
115
+  AmAudio* audio = popAndGetAudio(type, pos);
116
+  if (audio) {
117
+    delete audio;
118
+    return 0;
119
+  }
120
+  return -1; // error
121 121
 }
122 122
 
123 123
 AmAudio* AmAudioQueue::popAndGetAudio(QueueType type, Pos pos) {
124
-    AmMutex* q_mut; 
125
-    list<AudioQueueEntry>* q; 
126
-    switch (type) {
127
-	case OutputQueue: 
128
-	    q_mut = &outputQueue_mut;
129
-	    q = &outputQueue;
130
-	    break;
131
-	case InputQueue: 
132
-	default:  q_mut = &inputQueue_mut;
133
-	    q = &inputQueue;
134
-	    break;
135
-    };
136
-    q_mut->lock();
137
-    if (q->empty()) {
138
-	q_mut->unlock();
139
-	return 0;
140
-    }
141
-
142
-    AmAudio* audio;
143
-    if (pos == Front) {
144
-	audio = q->front().audio;
145
-	q->pop_front();
146
-    }  else {
147
-	audio = q->back().audio;
148
-	q->pop_back();
149
-    }
124
+  AmMutex* q_mut; 
125
+  list<AudioQueueEntry>* q; 
126
+  switch (type) {
127
+  case OutputQueue: 
128
+    q_mut = &outputQueue_mut;
129
+    q = &outputQueue;
130
+    break;
131
+  case InputQueue: 
132
+  default:  q_mut = &inputQueue_mut;
133
+    q = &inputQueue;
134
+    break;
135
+  };
136
+  q_mut->lock();
137
+  if (q->empty()) {
150 138
     q_mut->unlock();
151
-    return audio;
139
+    return 0;
140
+  }
141
+
142
+  AmAudio* audio;
143
+  if (pos == Front) {
144
+    audio = q->front().audio;
145
+    q->pop_front();
146
+  }  else {
147
+    audio = q->back().audio;
148
+    q->pop_back();
149
+  }
150
+  q_mut->unlock();
151
+  return audio;
152 152
 }
153 153
 
154 154
 int AmAudioQueue::removeAudio(AmAudio* audio) {
155
-    bool found = false;
156
-    outputQueue_mut.lock();
157
-    for (list<AudioQueueEntry>::iterator it = outputQueue.begin(); 
158
-	 it != outputQueue.end(); it++) {
159
-	if (it->audio == audio) {
160
-	    found = true;
161
-	    outputQueue.erase(it);
162
-	    break;
163
-	}
164
-	    
155
+  bool found = false;
156
+  outputQueue_mut.lock();
157
+  for (list<AudioQueueEntry>::iterator it = outputQueue.begin(); 
158
+       it != outputQueue.end(); it++) {
159
+    if (it->audio == audio) {
160
+      found = true;
161
+      outputQueue.erase(it);
162
+      break;
165 163
     }
166
-    outputQueue_mut.unlock();
167
-    if (found)
168
-	return 0;
169
-    inputQueue_mut.lock();
170
-    for (list<AudioQueueEntry>::iterator it = inputQueue.begin(); 
171
-	 it != inputQueue.end(); it++) {
172
-	if (it->audio == audio) {
173
-	    found = true;
174
-	    inputQueue.erase(it);
175
-	    break;
176
-	}
177 164
 	    
165
+  }
166
+  outputQueue_mut.unlock();
167
+  if (found)
168
+    return 0;
169
+  inputQueue_mut.lock();
170
+  for (list<AudioQueueEntry>::iterator it = inputQueue.begin(); 
171
+       it != inputQueue.end(); it++) {
172
+    if (it->audio == audio) {
173
+      found = true;
174
+      inputQueue.erase(it);
175
+      break;
178 176
     }
179
-    inputQueue_mut.unlock();
180
-    if (found)
181
-	return 0;
182
-    else {
183
-	ERROR("could not find audio in queue\n");
184
-	return -1; // error
185
-    }
177
+	    
178
+  }
179
+  inputQueue_mut.unlock();
180
+  if (found)
181
+    return 0;
182
+  else {
183
+    ERROR("could not find audio in queue\n");
184
+    return -1; // error
185
+  }
186 186
 }
187 187
 
188 188
 
189 189
 /* AudioBridge */
190 190
 AmAudioBridge::AmAudioBridge()
191
-    : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16))
191
+  : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16))
192 192
 {
193
-	sarr.clear_all();
193
+  sarr.clear_all();
194 194
 }
195 195
 
196 196
 AmAudioBridge::~AmAudioBridge() { 
197 197
 }
198 198
 
199 199
 int AmAudioBridge::write(unsigned int user_ts, unsigned int size) {  
200
-	sarr.write(user_ts, (short*) ((unsigned char*) samples), size >> 1); 
201
-	return size; 
200
+  sarr.write(user_ts, (short*) ((unsigned char*) samples), size >> 1); 
201
+  return size; 
202 202
 }
203 203
 
204 204
 int AmAudioBridge::read(unsigned int user_ts, unsigned int size) { 
205
-    sarr.read(user_ts, (short*) ((unsigned char*) samples), size >> 1); 
206
-    return size;
205
+  sarr.read(user_ts, (short*) ((unsigned char*) samples), size >> 1); 
206
+  return size;
207 207
 }
208 208
 
209 209
 /* AudioDelay */
210 210
 AmAudioDelay::AmAudioDelay(float delay_sec)
211
-    : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16))
211
+  : AmAudio(new AmAudioSimpleFormat(CODEC_PCM16))
212 212
 {
213
-	sarr.clear_all();
214
-	delay = delay_sec;
213
+  sarr.clear_all();
214
+  delay = delay_sec;
215 215
 }
216 216
 
217 217
 AmAudioDelay::~AmAudioDelay() { 
218 218
 }
219 219
 
220 220
 int AmAudioDelay::write(unsigned int user_ts, unsigned int size) {  
221
-    sarr.write(user_ts,(short*) ((unsigned char*) samples), size >> 1); 
222
-    return size; 
221
+  sarr.write(user_ts,(short*) ((unsigned char*) samples), size >> 1); 
222
+  return size; 
223 223
 }
224 224
 
225 225
 int AmAudioDelay::read(unsigned int user_ts, unsigned int size) { 
226
-    sarr.read((unsigned int) (user_ts  - delay*8000.0), (short*)  ((unsigned char*) samples), size >> 1); 
227
-    return size;
226
+  sarr.read((unsigned int) (user_ts  - delay*8000.0), (short*)  ((unsigned char*) samples), size >> 1); 
227
+  return size;
228 228
 }
... ...
@@ -40,11 +40,11 @@ using namespace std;
40 40
  * \brief Entry in an AudioQueue
41 41
  */
42 42
 struct AudioQueueEntry {
43
-    AmAudio* audio;
44
-    bool put;
45
-    bool get;
46
-    AudioQueueEntry(AmAudio* _audio, bool _put, bool _get) 
47
-	: audio(_audio), put(_put), get(_get) { }
43
+  AmAudio* audio;
44
+  bool put;
45
+  bool get;
46
+  AudioQueueEntry(AmAudio* _audio, bool _put, bool _get) 
47
+    : audio(_audio), put(_put), get(_get) { }
48 48
 };
49 49
 
50 50
 /**
... ...
@@ -56,32 +56,32 @@ struct AudioQueueEntry {
56 56
  */
57 57
 
58 58
 class AmAudioQueue : public AmAudio {
59
-    SampleArrayShort sarr;
59
+  SampleArrayShort sarr;
60 60
 
61
-    AmMutex inputQueue_mut;
62
-    list<AudioQueueEntry> inputQueue;
63
-    AmMutex outputQueue_mut;
64
-    list<AudioQueueEntry> outputQueue;
65
-public:
66
-    AmAudioQueue();
67
-    ~AmAudioQueue();
61
+  AmMutex inputQueue_mut;
62
+  list<AudioQueueEntry> inputQueue;
63
+  AmMutex outputQueue_mut;
64
+  list<AudioQueueEntry> outputQueue;
65
+ public:
66
+  AmAudioQueue();
67
+  ~AmAudioQueue();
68 68
 
69
-    enum QueueType { OutputQueue, InputQueue };
70
-    enum Pos { Front, Back };
69
+  enum QueueType { OutputQueue, InputQueue };
70
+  enum Pos { Front, Back };
71 71
 
72
-    /** add an audio to a queue */
73
-    void pushAudio(AmAudio* audio, QueueType type, Pos pos, bool write, bool read); 
74
-    /** pop an audio from queue and delete it @return 0 on success, -1 on failure */
75
-    int popAudio(QueueType type, Pos pos); 
76
-    /** pop an audio from queue @return pointer to the audio */
77
-    AmAudio* popAndGetAudio(QueueType type, Pos pos); 
78
-    /** this removes the audio if it is in on of the queues and does not
79
-        delete them */
80
-    int removeAudio(AmAudio* audio);
72
+  /** add an audio to a queue */
73
+  void pushAudio(AmAudio* audio, QueueType type, Pos pos, bool write, bool read); 
74
+  /** pop an audio from queue and delete it @return 0 on success, -1 on failure */
75
+  int popAudio(QueueType type, Pos pos); 
76
+  /** pop an audio from queue @return pointer to the audio */
77
+  AmAudio* popAndGetAudio(QueueType type, Pos pos); 
78
+  /** this removes the audio if it is in on of the queues and does not
79
+      delete them */
80
+  int removeAudio(AmAudio* audio);
81 81
 
82
-protected:
83
-    int write(unsigned int user_ts, unsigned int size);
84
-    int read(unsigned int user_ts, unsigned int size);
82
+ protected:
83
+  int write(unsigned int user_ts, unsigned int size);
84
+  int read(unsigned int user_ts, unsigned int size);
85 85
 };
86 86
 
87 87
 /**
... ...
@@ -91,13 +91,13 @@ protected:
91 91
  *  This is useful e.g. at the end of a AudioQueue
92 92
  */
93 93
 class AmAudioBridge : public AmAudio {
94
-    SampleArrayShort sarr;
95
-public:
96
-    AmAudioBridge();
97
-    ~AmAudioBridge();
98
-protected:
99
-    int write(unsigned int user_ts, unsigned int size);
100
-    int read(unsigned int user_ts, unsigned int size);
94
+  SampleArrayShort sarr;
95
+ public:
96
+  AmAudioBridge();
97
+  ~AmAudioBridge();
98
+ protected:
99
+  int write(unsigned int user_ts, unsigned int size);
100
+  int read(unsigned int user_ts, unsigned int size);
101 101
 };
102 102
 
103 103
 /**
... ...
@@ -105,15 +105,15 @@ protected:
105 105
  * delays delay_sec seconds (up to ~2)
106 106
  */
107 107
 class AmAudioDelay : public AmAudio {
108
-    SampleArrayShort sarr;
109
-    float delay;
110
-public:
111
-    AmAudioDelay(float delay_sec);
112
-    ~AmAudioDelay();
113
-protected:
108
+  SampleArrayShort sarr;
109
+  float delay;
110
+ public:
111
+  AmAudioDelay(float delay_sec);
112
+  ~AmAudioDelay();
113
+ protected:
114 114
 
115
-    int write(unsigned int user_ts, unsigned int size);
116
-    int read(unsigned int user_ts, unsigned int size);
115
+  int write(unsigned int user_ts, unsigned int size);
116
+  int read(unsigned int user_ts, unsigned int size);
117 117
 };
118 118
 
119 119
 #endif // _AmAdvancedAudio_h_
... ...
@@ -35,11 +35,11 @@ AmDynInvoke::~AmDynInvoke() {}
35 35
 
36 36
 void AmDynInvoke::invoke(const string& method, const AmArgArray& args, AmArgArray& ret)
37 37
 {
38
-    throw NotImplemented(method);
38
+  throw NotImplemented(method);
39 39
 }
40 40
 
41 41
 AmDynInvokeFactory::AmDynInvokeFactory(const string& name)
42
-    : AmPluginFactory(name) 
42
+  : AmPluginFactory(name) 
43 43
 {
44 44
 }
45 45
 
... ...
@@ -50,7 +50,7 @@ AmSessionFactory::AmSessionFactory(const string& name)
50 50
 
51 51
 AmSession* AmSessionFactory::onRefer(const AmSipRequest& req)
52 52
 {
53
-    throw AmSession::Exception(488,"Not accepted here");
53
+  throw AmSession::Exception(488,"Not accepted here");
54 54
 }
55 55
 
56 56
 int AmSessionFactory::configureModule(AmConfigReader& cfg) {
... ...
@@ -58,21 +58,21 @@ int AmSessionFactory::configureModule(AmConfigReader& cfg) {
58 58
 }
59 59
 
60 60
 void AmSessionFactory::configureSession(AmSession* sess) {
61
-    //SessionTimer::sess->configureSessionTimer(mod_conf);
61
+  //SessionTimer::sess->configureSessionTimer(mod_conf);
62 62
 }
63 63
 
64 64
 void AmSessionFactory::postEvent(AmEvent* ev) {
65
-	ERROR("unhandled Event in %s module\n", getName().c_str());
66
-	delete ev;
65
+  ERROR("unhandled Event in %s module\n", getName().c_str());
66
+  delete ev;
67 67
 }
68 68
 
69 69
 AmSessionEventHandlerFactory::AmSessionEventHandlerFactory(const string& name)
70
-	: AmPluginFactory(name) 
70
+  : AmPluginFactory(name) 
71 71
 {
72 72
 }
73 73
 
74 74
 AmSIPEventHandler::AmSIPEventHandler(const string& name) 
75
-    : AmPluginFactory(name) 
75
+  : AmPluginFactory(name) 
76 76
 {
77 77
 }
78 78
 
... ...
@@ -45,16 +45,16 @@ using std::string;
45 45
 class AmDynInvoke
46 46
 {
47 47
 public:
48
-    /** \brief NotImplemented result for DI API calls */
49
-    struct NotImplemented {
50
-	string what;
51
-	NotImplemented(const string& w)
52
-	    : what(w) {}
53
-    };
54
-
55
-    AmDynInvoke();
56
-    virtual ~AmDynInvoke();
57
-    virtual void invoke(const string& method, const AmArgArray& args, AmArgArray& ret);
48
+  /** \brief NotImplemented result for DI API calls */
49
+  struct NotImplemented {
50
+    string what;
51
+    NotImplemented(const string& w)
52
+      : what(w) {}
53
+  };
54
+
55
+  AmDynInvoke();
56
+  virtual ~AmDynInvoke();
57
+  virtual void invoke(const string& method, const AmArgArray& args, AmArgArray& ret);
58 58
 };
59 59
 
60 60
 /**
... ...
@@ -62,23 +62,23 @@ public:
62 62
  */
63 63
 class AmPluginFactory
64 64
 {
65
-    string plugin_name;
65
+  string plugin_name;
66 66
 
67 67
 public:
68
-    AmPluginFactory(const string& name)
69
-	: plugin_name(name) {}
68
+  AmPluginFactory(const string& name)
69
+    : plugin_name(name) {}
70 70
 
71
-    virtual ~AmPluginFactory() {}
71
+  virtual ~AmPluginFactory() {}
72 72
 
73
-    const string& getName() { return plugin_name; } 
73
+  const string& getName() { return plugin_name; } 
74 74
 
75
-    /**
76
-     * Enables the plug-in to initialize whatever it needs.
77
-     * Ex. load the configuration.
78
-     * @return 0 everything was ok.
79
-     * @return 1 on error.
80
-     */
81
-    virtual int onLoad()=0;
75
+  /**
76
+   * Enables the plug-in to initialize whatever it needs.
77
+   * Ex. load the configuration.
78
+   * @return 0 everything was ok.
79
+   * @return 1 on error.
80
+   */
81
+  virtual int onLoad()=0;
82 82
 };
83 83
 
84 84
 /**
... ...
@@ -90,8 +90,8 @@ public:
90 90
 class AmDynInvokeFactory: public AmPluginFactory
91 91
 {
92 92
 public:
93
-    AmDynInvokeFactory(const string& name);
94
-    virtual AmDynInvoke* getInstance()=0;
93
+  AmDynInvokeFactory(const string& name);
94
+  virtual AmDynInvoke* getInstance()=0;
95 95
 };
96 96
 
97 97
 
... ...
@@ -103,14 +103,14 @@ class AmSessionEventHandler;
103 103
 class AmSessionEventHandlerFactory: public AmPluginFactory
104 104
 {
105 105
 public:
106
-    AmSessionEventHandlerFactory(const string& name);
106
+  AmSessionEventHandlerFactory(const string& name);
107 107
 
108
-    virtual AmSessionEventHandler* getHandler(AmSession*)=0;
108
+  virtual AmSessionEventHandler* getHandler(AmSession*)=0;
109 109
 
110
-    /**
111
-     * @return true if session creation should be stopped
112
-     */
113
-    virtual bool onInvite(const AmSipRequest& req)=0;
110
+  /**
111
+   * @return true if session creation should be stopped
112
+   */
113
+  virtual bool onInvite(const AmSipRequest& req)=0;
114 114
 };
115 115
 
116 116
 /** \brief Interface for plugins to create sessions */
... ...
@@ -120,50 +120,50 @@ class AmSessionFactory: public AmPluginFactory
120 120
   AmSessionTimerConfig mod_conf;
121 121
 
122 122
 protected:
123
-    /**
124
-     * This reads the module configuration from 
125
-     * cfg into the modules mod_conf.
126
-     */
127
-    int configureModule(AmConfigReader& cfg);
123
+  /**
124
+   * This reads the module configuration from 
125
+   * cfg into the modules mod_conf.
126
+   */
127
+  int configureModule(AmConfigReader& cfg);
128 128
 
129 129
 public:
130
-    /**
131
-     * This function applys the module configuration 
132
-     */
133
-    void configureSession(AmSession* sess);
134
-
135
-    AmSessionFactory(const string& name);
136
-
137
-    /**
138
-     * Creates a dialog state on new request.
139
-     * @return 0 if the request is not acceptable.
140
-     *
141
-     * Warning:
142
-     *   This method should not make any expensive
143
-     *   processing as it would block the server.
144
-     */
145
-    virtual AmSession* onInvite(const AmSipRequest& req)=0;
146
-
147
-    /**
148
-     * Creates a dialog state on new REFER with local-tag.
149
-     * @return 0 if the request is not acceptable.
150
-     *
151
-     * Warning:
152
-     *   This method should not make any expensive
153
-     *   processing as it would block the server.
154
-     */
155
-    virtual AmSession* onRefer(const AmSipRequest& req);
156
-
157
-    /**
158
-     * method to receive an Event that is posted
159
-	 * to  the factory
160
-	 *
161
-     * Warning:
162
-     *   This method should not make any expensive
163
-     *   processing as it would block the thread 
164
-	 *   posting the event!
165
-     */
166
-    virtual void postEvent(AmEvent* ev);	
130
+  /**
131
+   * This function applys the module configuration 
132
+   */
133
+  void configureSession(AmSession* sess);
134
+
135
+  AmSessionFactory(const string& name);
136
+
137
+  /**
138
+   * Creates a dialog state on new request.
139
+   * @return 0 if the request is not acceptable.
140
+   *
141
+   * Warning:
142
+   *   This method should not make any expensive
143
+   *   processing as it would block the server.
144
+   */
145
+  virtual AmSession* onInvite(const AmSipRequest& req)=0;
146
+
147
+  /**
148
+   * Creates a dialog state on new REFER with local-tag.
149
+   * @return 0 if the request is not acceptable.
150
+   *
151
+   * Warning:
152
+   *   This method should not make any expensive
153
+   *   processing as it would block the server.
154
+   */
155
+  virtual AmSession* onRefer(const AmSipRequest& req);
156
+
157
+  /**
158
+   * method to receive an Event that is posted
159
+   * to  the factory
160
+   *
161
+   * Warning:
162
+   *   This method should not make any expensive
163
+   *   processing as it would block the thread 
164
+   *   posting the event!
165
+   */
166
+  virtual void postEvent(AmEvent* ev);	
167 167
 
168 168
 };
169 169
 
... ...
@@ -175,17 +175,17 @@ class AmSIPEventHandler : public AmPluginFactory
175 175
 {
176 176
 
177 177
 public:
178
-	AmSIPEventHandler(const string& name);
179
-	virtual ~AmSIPEventHandler() { }
180
-
181
-	/** will be called on incoming replies which do 
182
-	 *  not belong to a dialog of a session in the 
183
-	 *  SessionContainer.
184
-	 *
185
-	 *  @return true if reply was handled by plugin, false 
186
-	 *          otherwise
187
-	 */
188
-	virtual bool onSipReply(const AmSipReply& rep) = 0;
178
+  AmSIPEventHandler(const string& name);
179
+  virtual ~AmSIPEventHandler() { }
180
+
181
+  /** will be called on incoming replies which do 
182
+   *  not belong to a dialog of a session in the 
183
+   *  SessionContainer.
184
+   *
185
+   *  @return true if reply was handled by plugin, false 
186
+   *          otherwise
187
+   */
188
+  virtual bool onSipReply(const AmSipReply& rep) = 0;
189 189
 };
190 190
 
191 191
 #if  __GNUC__ < 3
... ...
@@ -232,6 +232,3 @@ typedef void* (*FactoryCreate)();
232 232
             EXPORT_FACTORY(FACTORY_SIP_EVENT_HANDLER_EXPORT,class_name,app_name)
233 233
 
234 234
 #endif
235
-// Local Variables:
236
-// mode:C++
237
-// End:
... ...
@@ -1,3 +1,30 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2002-2003 Fhg Fokus
5
+ *
6
+ * This file is part of sems, a free SIP media server.
7
+ *
8
+ * sems is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * sems is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ */
27
+
1 28
 #ifndef _AmArg_h_
2 29
 #define _AmArg_h_
3 30
 
... ...
@@ -9,105 +36,105 @@ using std::vector;
9 36
 /** base for Objects as @see AmArg parameter*/
10 37
 class ArgObject {
11 38
  public:
12
-	ArgObject() { }
13
-	virtual ~ArgObject() { }
39
+  ArgObject() { }
40
+  virtual ~ArgObject() { }
14 41
 };
15 42
 
16 43
 /** \brief variable type argument for DynInvoke APIs */
17 44
 class AmArg
18 45
 {
19
-public:
20
-    // type enum
21
-    enum {
22
-	Undef=0,
23
-
24
-	Int,
25
-	Double,
26
-	CStr,
27
-	AObject
28
-    };
29
-
30
-private:
31
-    // type
32
-    short type;
46
+ public:
47
+  // type enum
48
+  enum {
49
+    Undef=0,
50
+
51
+    Int,
52
+    Double,
53
+    CStr,
54
+    AObject
55
+  };
56
+
57
+ private:
58
+  // type
59
+  short type;
33 60
     
34
-    // value
35
-    union {
61
+  // value
62
+  union {
36 63
 	
37
-	int         v_int;
38
-	double      v_double;
39
-	const char* v_cstr;
40
-	ArgObject* v_obj;
41
-    };
42
-
43
-public:
44
-    AmArg(const AmArg& v)
45
-	: type(v.type){
64
+    int         v_int;
65
+    double      v_double;
66
+    const char* v_cstr;
67
+    ArgObject* v_obj;
68
+  };
69
+
70
+ public:
71
+  AmArg(const AmArg& v)
72
+    : type(v.type){
46 73
 	
47
-	switch(type){
48
-	case Int: v_int = v.v_int; break;
49
-	case Double: v_double = v.v_double; break;
50
-	case CStr: v_cstr = v.v_cstr; break;
51
-	case AObject: v_obj = v.v_obj; break;
52
-	default: assert(0);
53
-	}
74
+    switch(type){
75
+    case Int: v_int = v.v_int; break;
76
+    case Double: v_double = v.v_double; break;
77
+    case CStr: v_cstr = v.v_cstr; break;
78
+    case AObject: v_obj = v.v_obj; break;
79
+    default: assert(0);
54 80
     }
81
+  }
55 82
 
56
-    AmArg(const int& v)
57
-	: type(Int),
58
-	  v_int(v)
83
+  AmArg(const int& v)
84
+    : type(Int),
85
+    v_int(v)
59 86
     {}
60 87
 
61
-    AmArg(const double& v)
62
-	: type(Double),
63
-	  v_double(v)
88
+  AmArg(const double& v)
89
+    : type(Double),
90
+    v_double(v)
64 91
     {}
65 92
 
66
-    AmArg(const char* v)
67
-	: type(CStr),
68
-	  v_cstr(v)
93
+  AmArg(const char* v)
94
+    : type(CStr),
95
+    v_cstr(v)
69 96
     {}
70 97
 
71
-    AmArg(ArgObject* v)
72
-	: type(AObject),
73
-	  v_obj(v)
98
+  AmArg(ArgObject* v)
99
+    : type(AObject),
100
+    v_obj(v)
74 101
     {}
75 102
 
76 103
 
77
-    short getType() const { return type; }
104
+  short getType() const { return type; }
78 105
 
79
-    int         asInt()    const { return v_int; }
80
-    double      asDouble() const { return v_double; }
81
-    const char* asCStr()   const { return v_cstr; }
82
-	ArgObject*  asObject() const { return v_obj; }
106
+  int         asInt()    const { return v_int; }
107
+  double      asDouble() const { return v_double; }
108
+  const char* asCStr()   const { return v_cstr; }
109
+  ArgObject*  asObject() const { return v_obj; }
83 110
 };
84 111
 
85 112
 /** \brief array of variable args for DI APIs*/
86 113
 class AmArgArray
87 114
 {
88
-    vector<AmArg> v;
115
+  vector<AmArg> v;
89 116
 
90
-public:
91
-	struct OutOfBoundsException {
92
-		OutOfBoundsException() { }
93
-	};
117
+ public:
118
+  struct OutOfBoundsException {
119
+    OutOfBoundsException() { }
120
+  };
94 121
 
95
-    AmArgArray() : v() {}
96
-    AmArgArray(const AmArgArray& a) : v(a.v) {}
122
+  AmArgArray() : v() {}
123
+  AmArgArray(const AmArgArray& a) : v(a.v) {}
97 124
     
98
-    void push(const AmArg& a){
99
-	v.push_back(a);
100
-    }
125
+  void push(const AmArg& a){
126
+    v.push_back(a);
127
+  }
101 128
 
102
-    const AmArg& get(size_t idx) const {
129
+  const AmArg& get(size_t idx) const {
103 130
 	
104
-	if (idx >= v.size())
105
-		throw OutOfBoundsException();
106
-	//	assert(idx < v.size());
107
-	return v[idx];
108
-    }
131
+    if (idx >= v.size())
132
+      throw OutOfBoundsException();
133
+    //	assert(idx < v.size());
134
+    return v[idx];
135
+  }
109 136
 
110
-    size_t size() { return v.size(); }
137
+  size_t size() { return v.size(); }
111 138
 };
112 139
 
113 140
 #endif
... ...
@@ -61,59 +61,59 @@ AmAudioFormat::AmAudioFormat()
61 61
 }
62 62
 
63 63
 AmAudioSimpleFormat::AmAudioSimpleFormat(int codec_id)
64
-    : AmAudioFormat(), codec_id(codec_id)
64
+  : AmAudioFormat(), codec_id(codec_id)
65 65
 {
66
-    codec = getCodec();
67
-    rate = 8000;
68
-    channels = 1;
66
+  codec = getCodec();
67
+  rate = 8000;
68
+  channels = 1;
69 69
 }
70 70
 
71 71
 AmAudioFileFormat::AmAudioFileFormat(const string& name, int subtype)
72
-    : name(name), subtype(subtype), p_subtype(0)
72
+  : name(name), subtype(subtype), p_subtype(0)
73 73
 {
74
-    getSubtype();
75
-    codec = getCodec();
74
+  getSubtype();
75
+  codec = getCodec();
76 76
     
77
-    if(p_subtype && codec){
78
-	rate = p_subtype->sample_rate;
79
-	channels = p_subtype->channels;
80
-	subtype = p_subtype->type;
81
-    } 
77
+  if(p_subtype && codec){
78
+    rate = p_subtype->sample_rate;
79
+    channels = p_subtype->channels;
80
+    subtype = p_subtype->type;
81
+  } 
82 82
 }
83 83
 
84 84
 AmAudioFormat::~AmAudioFormat()
85 85
 {
86
-    destroyCodec();
86
+  destroyCodec();
87 87
 }
88 88
 
89 89
 unsigned int AmAudioFormat::samples2bytes(unsigned int nb_samples) const
90 90
 {
91
-    if (codec && codec->samples2bytes)
92
-	return codec->samples2bytes(h_codec, nb_samples) * channels;
93
-    WARN("Cannot convert samples to bytes\n");
94
-    return nb_samples * channels;
91
+  if (codec && codec->samples2bytes)
92
+    return codec->samples2bytes(h_codec, nb_samples) * channels;
93
+  WARN("Cannot convert samples to bytes\n");
94
+  return nb_samples * channels;
95 95
 }
96 96
 
97 97
 unsigned int AmAudioFormat::bytes2samples(unsigned int bytes) const
98 98
 {
99
-    if (codec && codec->samples2bytes)
100
-	return codec->bytes2samples(h_codec, bytes) / channels;
101
-    WARN("Cannot convert bytes to samples\n");
102
-    return bytes / channels;
99
+  if (codec && codec->samples2bytes)
100
+    return codec->bytes2samples(h_codec, bytes) / channels;
101
+  WARN("Cannot convert bytes to samples\n");
102
+  return bytes / channels;
103 103
 }
104 104
 
105 105
 bool AmAudioFormat::operator == (const AmAudioFormat& r) const
106 106
 {
107
-    return ( codec && r.codec
108
-	     && (r.codec->id == codec->id) 
109
-	     && (r.bytes2samples(1024) == bytes2samples(1024))
110
-	     && (r.channels == channels)
111
-	     && (r.rate == rate));
107
+  return ( codec && r.codec
108
+	   && (r.codec->id == codec->id) 
109
+	   && (r.bytes2samples(1024) == bytes2samples(1024))
110
+	   && (r.channels == channels)
111
+	   && (r.rate == rate));
112 112
 }
113 113
 
114 114
 bool AmAudioFormat::operator != (const AmAudioFormat& r) const
115 115
 {
116
-    return !(this->operator == (r));
116
+  return !(this->operator == (r));
117 117
 }
118 118
 
119 119
 void AmAudioFormat::initCodec()
... ...
@@ -128,22 +128,22 @@ void AmAudioFormat::initCodec()
128 128
     } else {
129 129
       string s; 
130 130
       int i=0;
131
-	while (fmt_i[i].id) {
132
-	  switch (fmt_i[i].id) {
133
-	  case AMCI_FMT_FRAME_LENGTH : {
134
-	    frame_length=fmt_i[i].value; 
135
-	  } break;
136
-	  case AMCI_FMT_FRAME_SIZE: {
137
-	    frame_size=fmt_i[i].value; 
138
-	  } break;
139
-	  case AMCI_FMT_ENCODED_FRAME_SIZE: {
140
-	    frame_encoded_size=fmt_i[i].value; 
141
-	  } break;
142
-	  default: {
143
-	    DBG("Unknown codec format descriptor: %d\n", fmt_i[i].id);
144
-	  } break;
145
-	  }
146
-	  i++;
131
+      while (fmt_i[i].id) {
132
+	switch (fmt_i[i].id) {
133
+	case AMCI_FMT_FRAME_LENGTH : {
134
+	  frame_length=fmt_i[i].value; 
135
+	} break;
136
+	case AMCI_FMT_FRAME_SIZE: {
137
+	  frame_size=fmt_i[i].value; 
138
+	} break;
139
+	case AMCI_FMT_ENCODED_FRAME_SIZE: {
140
+	  frame_encoded_size=fmt_i[i].value; 
141
+	} break;
142
+	default: {
143
+	  DBG("Unknown codec format descriptor: %d\n", fmt_i[i].id);
144
+	} break;
145
+	}
146
+	i++;
147 147
       }
148 148
     }  
149 149
   } 
... ...
@@ -151,65 +151,65 @@ void AmAudioFormat::initCodec()
151 151
 
152 152
 void AmAudioFormat::destroyCodec()
153 153
 {
154
-    if( codec && codec->destroy ){
155
-	(*codec->destroy)(h_codec);
156
-	h_codec = 0;
157
-    }
154
+  if( codec && codec->destroy ){
155
+    (*codec->destroy)(h_codec);
156
+    h_codec = 0;
157
+  }
158 158
 }
159 159
 
160 160
 amci_subtype_t*  AmAudioFileFormat::getSubtype()
161 161
 {
162
-    if(!p_subtype && !name.empty()){
162
+  if(!p_subtype && !name.empty()){
163 163
 
164
-	amci_inoutfmt_t* iofmt = AmPlugIn::instance()->fileFormat(name.c_str());
165
-	if(!iofmt){
166
-	    ERROR("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n",
167
-		  name.c_str());
168
-	    throw string("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n");
169
-	}
170
-	else {
171
-	    p_subtype = AmPlugIn::instance()->subtype(iofmt,subtype);
172
-	    if(!p_subtype)
173
-		ERROR("AmAudioFileFormat::getSubtype: subtype %i in format '%s' does not exist\n",
174
-		      subtype,iofmt->name);
175
-	    subtype = p_subtype->type;
176
-	}
164
+    amci_inoutfmt_t* iofmt = AmPlugIn::instance()->fileFormat(name.c_str());
165
+    if(!iofmt){
166
+      ERROR("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n",
167
+	    name.c_str());
168
+      throw string("AmAudioFileFormat::getSubtype: file format '%s' does not exist\n");
177 169
     }
178
-    return p_subtype;
170
+    else {
171
+      p_subtype = AmPlugIn::instance()->subtype(iofmt,subtype);
172
+      if(!p_subtype)
173
+	ERROR("AmAudioFileFormat::getSubtype: subtype %i in format '%s' does not exist\n",
174
+	      subtype,iofmt->name);
175
+      subtype = p_subtype->type;
176
+    }
177
+  }
178
+  return p_subtype;
179 179
 }
180 180
 
181 181
 
182 182
 amci_codec_t* AmAudioFormat::getCodec()
183 183
 {
184 184
 
185
-    if(!codec){
186
-	int codec_id = getCodecId();
187
-	codec = AmPlugIn::instance()->codec(codec_id);
185
+  if(!codec){
186
+    int codec_id = getCodecId();
187
+    codec = AmPlugIn::instance()->codec(codec_id);
188 188
 
189
-	initCodec();
190
-    }
189
+    initCodec();
190
+  }
191 191
     
192
-    return codec;
192
+  return codec;
193 193
 }
194 194
 
195 195
 long AmAudioFormat::getHCodec()
196 196
 {
197
-    if(!codec)
198
-	getCodec();
199
-    return h_codec;
197
+  if(!codec)
198
+    getCodec();
199
+  return h_codec;
200 200
 }
201 201
 
202 202
 AmAudio::AmAudio()
203
-    : fmt(new AmAudioSimpleFormat(CODEC_PCM16)),
204
-      max_rec_time(-1),
205
-      rec_time(0)
203
+  : fmt(new AmAudioSimpleFormat(CODEC_PCM16)),
204
+    max_rec_time(-1),
205
+    rec_time(0)
206 206
 {
207 207
 }
208 208
 
209 209
 AmAudio::AmAudio(AmAudioFormat *_fmt)
210
-    : fmt(_fmt),
211
-      max_rec_time(-1),
212
-      rec_time(0)
210
+  : fmt(_fmt),
211
+    max_rec_time(-1),
212
+    rec_time(0)
213 213
 {
214 214
 }
215 215
 
... ...
@@ -224,453 +224,453 @@ void AmAudio::close()
224 224
 // returns bytes read, else -1 if error (0 is OK)
225 225
 int AmAudio::get(unsigned int user_ts, unsigned char* buffer, unsigned int nb_samples)
226 226
 {
227
-    int size = samples2bytes(nb_samples);
227
+  int size = samples2bytes(nb_samples);
228 228
 
229
-    size = read(user_ts,size);
230
-    //DBG("size = %d\n",size);
231
-    if(size <= 0){
232
-	return size;
233
-    }
229
+  size = read(user_ts,size);
230
+  //DBG("size = %d\n",size);
231
+  if(size <= 0){
232
+    return size;
233
+  }
234 234
 
235
-    size = decode(size);
236
-    if(size < 0) {
237
-	DBG("decode returned %i\n",size);
238
-	return -1; 
239
-    }
240
-    size = downMix(size);
235
+  size = decode(size);
236
+  if(size < 0) {
237
+    DBG("decode returned %i\n",size);
238
+    return -1; 
239
+  }
240
+  size = downMix(size);
241 241
     
242
-    if(size>0)
243
-	memcpy(buffer,(unsigned char*)samples,size);
242
+  if(size>0)
243
+    memcpy(buffer,(unsigned char*)samples,size);
244 244
 
245
-    return size;
245
+  return size;
246 246
 }
247 247
 
248 248
 // returns bytes written, else -1 if error (0 is OK)
249 249
 int AmAudio::put(unsigned int user_ts, unsigned char* buffer, unsigned int size)
250 250
 {
251
-    if(!size){
252
-	return 0;
253
-    }
251
+  if(!size){
252
+    return 0;
253
+  }
254 254
 
255
-    if(max_rec_time > -1 && rec_time >= max_rec_time)
256
-	return -1;
255
+  if(max_rec_time > -1 && rec_time >= max_rec_time)
256
+    return -1;
257 257
 
258 258
 
259
-    memcpy((unsigned char*)samples,buffer,size);
259
+  memcpy((unsigned char*)samples,buffer,size);
260 260
 
261
-    unsigned int s = encode(size);
262
-    if(s>0){
263
-	//DBG("%s\n",typeid(this).name());
264
-	incRecordTime(bytes2samples(size));
265
-	return write(user_ts,(unsigned int)s);
266
-    }
267
-    else{
268
-	return s;
269
-    }
261
+  unsigned int s = encode(size);
262
+  if(s>0){
263
+    //DBG("%s\n",typeid(this).name());
264
+    incRecordTime(bytes2samples(size));
265
+    return write(user_ts,(unsigned int)s);
266
+  }
267
+  else{
268
+    return s;
269
+  }
270 270
 }
271 271
 
272 272
 void AmAudio::stereo2mono(unsigned char* out_buf,unsigned char* in_buf,unsigned int& size)
273 273
 {
274
-    short* in  = (short*)in_buf;
275
-    short* end = (short*)(in_buf + size);
276
-    short* out = (short*)out_buf;
274
+  short* in  = (short*)in_buf;
275
+  short* end = (short*)(in_buf + size);
276
+  short* out = (short*)out_buf;
277 277
     
278
-    while(in != end){
279
-	*(out++) = (*in + *(in+1)) / 2;
280
-	in += 2;
281
-    }
278
+  while(in != end){
279
+    *(out++) = (*in + *(in+1)) / 2;
280
+    in += 2;
281
+  }
282 282
 
283
-    size /= 2;
283
+  size /= 2;
284 284
 }
285 285
 
286 286
 int AmAudio::decode(unsigned int size)
287 287
 {
288
-    int s = size;
288
+  int s = size;
289 289
 
290
-    if(!fmt.get()){
291
- 	DBG("no fmt !\n");
292
- 	return s;
293
-    }
290
+  if(!fmt.get()){
291
+    DBG("no fmt !\n");
292
+    return s;
293
+  }
294 294
 
295
-    amci_codec_t* codec = fmt->getCodec();
296
-    long h_codec = fmt->getHCodec();
295
+  amci_codec_t* codec = fmt->getCodec();
296
+  long h_codec = fmt->getHCodec();
297 297
 
298
-//     if(!codec){
299
-// 	ERROR("audio format set, but no codec has been loaded\n");
300
-// 	abort();
301
-// 	return -1;
302
-//     }
298
+  //     if(!codec){
299
+  // 	ERROR("audio format set, but no codec has been loaded\n");
300
+  // 	abort();
301
+  // 	return -1;
302
+  //     }
303 303
 
304
-    if(codec->decode){
305
-	s = (*codec->decode)(samples.back_buffer(),samples,s,
306
-			     fmt->channels,fmt->rate,h_codec);
307
-	if(s<0) return s;
308
-	samples.swap();
309
-    }
304
+  if(codec->decode){
305
+    s = (*codec->decode)(samples.back_buffer(),samples,s,
306
+			 fmt->channels,fmt->rate,h_codec);
307
+    if(s<0) return s;
308
+    samples.swap();
309
+  }
310 310
     
311
-    return s;
311
+  return s;
312 312
 }
313 313
 
314 314
 int AmAudio::encode(unsigned int size)
315 315
 {
316
-    int s = size;
316
+  int s = size;
317 317
 
318
-//     if(!fmt.get()){
319
-// 	DBG("no encode fmt\n");
320
-// 	return 0;
321
-//     }
318
+  //     if(!fmt.get()){
319
+  // 	DBG("no encode fmt\n");
320
+  // 	return 0;
321
+  //     }
322 322
 
323
-    amci_codec_t* codec = fmt->getCodec();
324
-    long h_codec = fmt->getHCodec();
323
+  amci_codec_t* codec = fmt->getCodec();
324
+  long h_codec = fmt->getHCodec();
325 325
 
326
-    if(codec->encode){
327
-	s = (*codec->encode)(samples.back_buffer(),samples,(unsigned int) size,
328
-				      fmt->channels,fmt->rate,h_codec);
329
-	if(s<0) return s;
330
-	samples.swap();
331
-    }
326
+  if(codec->encode){
327
+    s = (*codec->encode)(samples.back_buffer(),samples,(unsigned int) size,
328
+			 fmt->channels,fmt->rate,h_codec);
329
+    if(s<0) return s;
330
+    samples.swap();
331
+  }
332 332
     
333
-    return s;
333
+  return s;
334 334
 }
335 335
 
336 336
 unsigned int AmAudio::downMix(unsigned int size)
337 337
 {
338
-    unsigned int s = size;
339
-    if(fmt->channels == 2){
340
-	stereo2mono(samples.back_buffer(),(unsigned char*)samples,s);
341
-	samples.swap();
342
-    }
338
+  unsigned int s = size;
339
+  if(fmt->channels == 2){
340
+    stereo2mono(samples.back_buffer(),(unsigned char*)samples,s);
341
+    samples.swap();
342
+  }
343 343
 
344
-    return s;
344
+  return s;
345 345
 }
346 346
 
347 347
 unsigned int AmAudio::getFrameSize()
348 348
 {
349
-    assert(fmt.get());
350
-    return fmt->frame_size;
349
+  assert(fmt.get());
350
+  return fmt->frame_size;
351 351
 }
352 352
 
353 353
 unsigned int AmAudio::samples2bytes(unsigned int nb_samples) const
354 354
 {
355
-    return fmt->samples2bytes(nb_samples);
355
+  return fmt->samples2bytes(nb_samples);
356 356
 }
357 357
 
358 358
 unsigned int AmAudio::bytes2samples(unsigned int bytes) const
359 359
 {
360
-    return fmt->bytes2samples(bytes);
360
+  return fmt->bytes2samples(bytes);
361 361
 }
362 362
 
363 363
 void AmAudio::setRecordTime(unsigned int ms)
364 364
 {
365
-    max_rec_time = ms * (fmt->rate / 1000);
365
+  max_rec_time = ms * (fmt->rate / 1000);
366 366
 }
367 367
 
368 368
 int AmAudio::incRecordTime(unsigned int samples)
369 369
 {
370
-    return rec_time += samples;
370
+  return rec_time += samples;
371 371
 }
372 372
 
373 373
 
374 374
 DblBuffer::DblBuffer()
375
-    : active_buf(0)
375
+  : active_buf(0)
376 376
 { 
377 377
 }
378 378
 
379 379
 DblBuffer::operator unsigned char*()
380 380
 {
381
-    return samples + (active_buf ? AUDIO_BUFFER_SIZE : 0);
381
+  return samples + (active_buf ? AUDIO_BUFFER_SIZE : 0);
382 382
 }
383 383
 
384 384
 unsigned char* DblBuffer::back_buffer()
385 385
 {
386
-    return samples + (active_buf ? 0 : AUDIO_BUFFER_SIZE);
386
+  return samples + (active_buf ? 0 : AUDIO_BUFFER_SIZE);
387 387
 }
388 388
 
389 389
 void DblBuffer::swap()
390 390
 {
391
-    active_buf = !active_buf;
391
+  active_buf = !active_buf;
392 392
 }
393 393
 
394 394
 // returns 0 if everything's OK
395 395
 // return -1 if error