~ubuntu-branches/ubuntu/karmic/asterisk/karmic-proposed

« back to all changes in this revision

Viewing changes to formats/format_wav_gsm.c

  • Committer: Bazaar Package Importer
  • Author(s): Faidon Liambotis, Faidon Liambotis, Tzafrir Cohen
  • Date: 2009-07-28 03:42:54 UTC
  • mfrom: (8.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090728034254-ip2jeh7h3s45fqre
Tags: 1:1.6.2.0~dfsg~beta3-1
[ Faidon Liambotis ]
* New upstream release.
  - Drop patches astvarrundir, pubkey_jnctn; merged upstream (finally!).
  - Adapt patch safe_asterisk-nobg.
* Switch to downloads.asterisk.org instead of downloads.digium.com.
* Add depends on libxml2-dev for the new XML documentation.
* Remove Conflicts/Replaces with asterisk-classic, asterisk-bristuff,
  asterisk-chan-capi (<< 1.1.1-1~), since those are pre-lenny.
* Revert upstream's r190830 that ported app_osplookup to OSP Toolkit 3.5;
  the API is not backwards compatible and Debian still has 3.4.2.
* Accommodate for the rename of libcap2-dev to libcap-dev (Closes: #532971).
* Add dependency to libspandsp to build the fax applications.
* Update Standards-Version to 3.8.2, no changes needed.
* Remove init script's "zaptel-fix" action; there's no zaptel anymore and
  was also lintian-buggy in its current form.
* Don't include /var/run/asterisk in the package, it is created at boot-time
  by the init script (thanks lintian).
* Remove asterisk-progdocs: it is of very limited use but a) is enormous in
  size and b) takes too long to build.
* Re-enable and port to 1.6 the h323 segfault patch, apparently it's still
  needed.
* Fix asterisk's Makefiles so that the openh323/libpt dependencies are added
  to chan_h323.so instead of the main asterisk binary.
* Fix astgenkey to respect system's umask. Thanks Jonas Smedegaard.
  (Closes: #531730) 
* Create /var/log/asterisk/* directories if non-existent, for /var/log on
  tmpfs scenarios. Thanks martin f krafft! (Closes: #524015)
* Use the lsb-base standard way of gathering and reporting status in the
  init script. Thanks Dustin Kirkland and Ubuntu! (Closes: #506453)
* Fix debian/rules so that configure isn't called twice during a build.
* Install Zaptel-to-DAHDI.txt, explains the migration procedure from Zaptel
  to DAHDI and is therefore useful when upgrading from lenny.

[ Tzafrir Cohen ]
* New upstream release.
  - Fixes that bashism in safe_asterisk (Closes: #530047) (not dashism).
  - Dropped patch astcanary_startup: merged upstream.
* Patch makefile_appdocs_dtd: fix location of DTD installation.
* Register the HTML docs with doc-base as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include "asterisk.h"
31
31
 
32
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 111658 $")
33
 
 
34
 
#include <unistd.h>
35
 
#include <netinet/in.h>
36
 
#include <arpa/inet.h>
37
 
#include <stdlib.h>
38
 
#include <sys/time.h>
39
 
#include <stdio.h>
40
 
#include <errno.h>
41
 
#include <string.h>
42
 
 
43
 
#include "asterisk/lock.h"
44
 
#include "asterisk/channel.h"
45
 
#include "asterisk/file.h"
46
 
#include "asterisk/logger.h"
47
 
#include "asterisk/sched.h"
 
32
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 186845 $")
 
33
 
 
34
#include "asterisk/mod_format.h"
48
35
#include "asterisk/module.h"
49
36
#include "asterisk/endian.h"
50
37
 
163
150
                return -1;
164
151
        }
165
152
        if (ltohl(freq) != DEFAULT_SAMPLE_RATE) {
166
 
                ast_log(LOG_WARNING, "Unexpected freqency %d\n", ltohl(freq));
 
153
                ast_log(LOG_WARNING, "Unexpected frequency %d\n", ltohl(freq));
167
154
                return -1;
168
155
        }
169
156
        /* Ignore the byte frequency */
415
402
        AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
416
403
        if (fs->secondhalf) {
417
404
                /* Just return a frame based on the second GSM frame */
418
 
                s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE;
 
405
                s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE;
419
406
                s->fr.offset += GSM_FRAME_SIZE;
420
407
        } else {
421
408
                /* read and convert */
428
415
                        return NULL;
429
416
                }
430
417
                /* Convert from MS format to two real GSM frames */
431
 
                conv65(msdata, s->fr.data);
 
418
                conv65(msdata, s->fr.data.ptr);
432
419
        }
433
420
        fs->secondhalf = !fs->secondhalf;
434
421
        *whennext = GSM_SAMPLES;
462
449
                int res;
463
450
                unsigned char *src, msdata[MSGSM_FRAME_SIZE];
464
451
                if (fs->secondhalf) {   /* second half of raw gsm to be converted */
465
 
                        memcpy(s->buf + GSM_FRAME_SIZE, f->data + len, GSM_FRAME_SIZE);
 
452
                        memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE);
466
453
                        conv66((unsigned char *) s->buf, msdata);
467
454
                        src = msdata;
468
455
                        fs->secondhalf = 0;
469
456
                } else if (size == GSM_FRAME_SIZE) {    /* first half of raw gsm */
470
 
                        memcpy(s->buf, f->data + len, GSM_FRAME_SIZE);
 
457
                        memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE);
471
458
                        src = NULL;     /* nothing to write */
472
459
                        fs->secondhalf = 1;
473
460
                } else {        /* raw msgsm data */
474
 
                        src = f->data + len;
 
461
                        src = f->data.ptr + len;
475
462
                }
476
463
                if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) {
477
464
                        ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));
509
496
                int i;
510
497
                fseek(fs->f, 0, SEEK_END);
511
498
                for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) {
512
 
                        fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f);
 
499
                        if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) {
 
500
                                ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
 
501
                        }
513
502
                }
514
503
        }
515
504
        s->secondhalf = 0;
549
538
 
550
539
static int load_module(void)
551
540
{
552
 
        return ast_format_register(&wav49_f);
 
541
        if (ast_format_register(&wav49_f))
 
542
                return AST_MODULE_LOAD_FAILURE;
 
543
        return AST_MODULE_LOAD_SUCCESS;
553
544
}
554
545
 
555
546
static int unload_module(void)