~davewalker/ubuntu/maverick/asterisk/lp_705014

« back to all changes in this revision

Viewing changes to funcs/func_speex.c

  • Committer: Bazaar Package Importer
  • Author(s): Jean-Michel Dault
  • Date: 2010-02-16 14:08:54 UTC
  • mfrom: (1.2.5 upstream) (8.3.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100216140854-rb2godspb9lduazl
Tags: 1:1.6.2.2-1ubuntu1
* Merge from Debian: security update
  * Changes:
  - debian/control: Change Maintainer
  - debian/control: Removed Uploaders field.
  - debian/control: Removed Debian Vcs-Svn entry and replaced with
      ubuntu-voip Vcs-Bzr, to reflect divergence in packages.
  - debian/asterisk.init : chown /dev/dahdi
  - debian/backports/hardy : add file
  - debian/backports/asterisk.init.hardy : add file

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
#include "asterisk.h"
39
39
 
40
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 211580 $")
 
40
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 224859 $")
41
41
 
42
42
#include <speex/speex_preprocess.h>
43
43
#include "asterisk/module.h"
142
142
        struct ast_datastore *datastore = NULL;
143
143
        struct speex_direction_info *sdi = NULL;
144
144
        struct speex_info *si = NULL;
 
145
        char source[80];
145
146
 
146
147
        /* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
147
148
        if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE || frame->frametype != AST_FRAME_VOICE) {
148
 
                return 0;
 
149
                return -1;
149
150
        }
150
 
        
151
 
        ast_channel_lock(chan);
 
151
 
 
152
        /* We are called with chan already locked */
152
153
        if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
153
 
                ast_channel_unlock(chan);
154
 
                return 0;
 
154
                return -1;
155
155
        }
156
 
        ast_channel_unlock(chan);
157
156
 
158
157
        si = datastore->data;
159
158
 
160
159
        sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx;
161
160
 
162
161
        if (!sdi) {
163
 
                return 0;
 
162
                return -1;
164
163
        }
165
164
 
166
165
        if (sdi->samples != frame->samples) {
171
170
                if (!(sdi->state = speex_preprocess_state_init((sdi->samples = frame->samples), 8000))) {
172
171
                        return -1;
173
172
                }
174
 
                
 
173
 
175
174
                speex_preprocess_ctl(sdi->state, SPEEX_PREPROCESS_SET_AGC, &sdi->agc);
176
175
 
177
176
                if (sdi->agc) {
182
181
        }
183
182
 
184
183
        speex_preprocess(sdi->state, frame->data.ptr, NULL);
 
184
        snprintf(source, sizeof(source), "%s/speex", frame->src);
 
185
        if (frame->mallocd & AST_MALLOCD_SRC) {
 
186
                ast_free((char *) frame->src);
 
187
        }
 
188
        frame->src = ast_strdup(source);
 
189
        frame->mallocd |= AST_MALLOCD_SRC;
185
190
 
186
191
        return 0;
187
192
}