Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Data Structures | Macros | Functions | Variables
format_wav.c File Reference

Work with WAV in the proprietary Microsoft format. Microsoft WAV format (8000hz Signed Linear) More...

#include "asterisk.h"
#include "asterisk/mod_format.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
#include "asterisk/format_cache.h"
#include "asterisk/format.h"
#include "asterisk/codec.h"
Include dependency graph for format_wav.c:

Go to the source code of this file.

Data Structures

struct  wav_desc
 

Macros

#define BLOCKSIZE   160
 
#define WAV_BUF_SIZE   320
 
#define WAV_HEADER_SIZE   44
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int check_header (FILE *f, int hz)
 
static int check_header_fmt (FILE *f, int hsize, int hz)
 
static int load_module (void)
 
static int unload_module (void)
 
static int update_header (FILE *f)
 
static void wav_close (struct ast_filestream *s)
 
static int wav_open (struct ast_filestream *s)
 
static struct ast_framewav_read (struct ast_filestream *s, int *whennext)
 
static int wav_rewrite (struct ast_filestream *s, const char *comment)
 
static int wav_seek (struct ast_filestream *fs, off_t sample_offset, int whence)
 
static off_t wav_tell (struct ast_filestream *fs)
 
static int wav_trunc (struct ast_filestream *fs)
 
static int wav_write (struct ast_filestream *fs, struct ast_frame *f)
 
static int write_header (FILE *f, int writehz)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Microsoft WAV/WAV16 format (8kHz/16kHz Signed Linear)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_format_def wav16_f
 
static struct ast_format_def wav_f
 

Detailed Description

Work with WAV in the proprietary Microsoft format. Microsoft WAV format (8000hz Signed Linear)

Definition in file format_wav.c.

Macro Definition Documentation

◆ BLOCKSIZE

#define BLOCKSIZE   160

Definition at line 56 of file format_wav.c.

◆ WAV_BUF_SIZE

#define WAV_BUF_SIZE   320

Definition at line 44 of file format_wav.c.

◆ WAV_HEADER_SIZE

#define WAV_HEADER_SIZE   44

Definition at line 46 of file format_wav.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 572 of file format_wav.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 572 of file format_wav.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 572 of file format_wav.c.

◆ check_header()

static int check_header ( FILE *  f,
int  hz 
)
static

Definition at line 140 of file format_wav.c.

141{
142 int type, size, formtype;
143 int data;
144 if (fread(&type, 1, 4, f) != 4) {
145 ast_log(LOG_WARNING, "Read failed (type)\n");
146 return -1;
147 }
148 if (fread(&size, 1, 4, f) != 4) {
149 ast_log(LOG_WARNING, "Read failed (size)\n");
150 return -1;
151 }
152#if __BYTE_ORDER == __BIG_ENDIAN
153 size = ltohl(size);
154#endif
155 if (fread(&formtype, 1, 4, f) != 4) {
156 ast_log(LOG_WARNING, "Read failed (formtype)\n");
157 return -1;
158 }
159 if (memcmp(&type, "RIFF", 4)) {
160 ast_log(LOG_WARNING, "Does not begin with RIFF\n");
161 return -1;
162 }
163 if (memcmp(&formtype, "WAVE", 4)) {
164 ast_log(LOG_WARNING, "Does not contain WAVE\n");
165 return -1;
166 }
167 /* Skip any facts and get the first data block */
168 for(;;)
169 {
170 char buf[4];
171
172 /* Begin data chunk */
173 if (fread(&buf, 1, 4, f) != 4) {
174 ast_log(LOG_WARNING, "Read failed (block header format)\n");
175 return -1;
176 }
177 /* Data has the actual length of data in it */
178 if (fread(&data, 1, 4, f) != 4) {
179 ast_log(LOG_WARNING, "Read failed (block '%.4s' header length)\n", buf);
180 return -1;
181 }
182#if __BYTE_ORDER == __BIG_ENDIAN
183 data = ltohl(data);
184#endif
185 if (memcmp(&buf, "fmt ", 4) == 0) {
186 if (check_header_fmt(f, data, hz))
187 return -1;
188 continue;
189 }
190 if(memcmp(buf, "data", 4) == 0 )
191 break;
192 ast_debug(1, "Skipping unknown block '%.4s'\n", buf);
193 if (fseek(f,data,SEEK_CUR) == -1 ) {
194 ast_log(LOG_WARNING, "Failed to skip '%.4s' block: %d\n", buf, data);
195 return -1;
196 }
197 }
198#if 0
199 curpos = lseek(fd, 0, SEEK_CUR);
200 truelength = lseek(fd, 0, SEEK_END);
201 lseek(fd, curpos, SEEK_SET);
202 truelength -= curpos;
203#endif
204 return data;
205}
#define ast_log
Definition: astobj2.c:42
static const char type[]
Definition: chan_ooh323.c:109
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int check_header_fmt(FILE *f, int hsize, int hz)
Definition: format_wav.c:81
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING

References ast_debug, ast_log, buf, check_header_fmt(), LOG_WARNING, and type.

Referenced by wav_open().

◆ check_header_fmt()

static int check_header_fmt ( FILE *  f,
int  hsize,
int  hz 
)
static

Definition at line 81 of file format_wav.c.

82{
83 unsigned short format, chans, bysam, bisam;
84 unsigned int freq, bysec;
85 if (hsize < 16) {
86 ast_log(LOG_WARNING, "Unexpected header size %d\n", hsize);
87 return -1;
88 }
89 if (fread(&format, 1, 2, f) != 2) {
90 ast_log(LOG_WARNING, "Read failed (format)\n");
91 return -1;
92 }
93 if (ltohs(format) != 1) {
94 ast_log(LOG_WARNING, "Not a supported wav file format (%d). Only PCM encoded, 16 bit, mono, 8kHz/16kHz files are supported with a lowercase '.wav' extension.\n", ltohs(format));
95 return -1;
96 }
97 if (fread(&chans, 1, 2, f) != 2) {
98 ast_log(LOG_WARNING, "Read failed (format)\n");
99 return -1;
100 }
101 if (ltohs(chans) != 1) {
102 ast_log(LOG_WARNING, "Not in mono %d\n", ltohs(chans));
103 return -1;
104 }
105 if (fread(&freq, 1, 4, f) != 4) {
106 ast_log(LOG_WARNING, "Read failed (freq)\n");
107 return -1;
108 }
109 freq = ltohl(freq);
110 if ((freq != 8000 && freq != 16000) || freq != hz) {
111 ast_log(LOG_WARNING, "Unexpected frequency mismatch %d (expecting %d)\n", freq, hz);
112 return -1;
113 }
114 /* Ignore the byte frequency */
115 if (fread(&bysec, 1, 4, f) != 4) {
116 ast_log(LOG_WARNING, "Read failed (BYTES_PER_SECOND)\n");
117 return -1;
118 }
119 /* Check bytes per sample */
120 if (fread(&bysam, 1, 2, f) != 2) {
121 ast_log(LOG_WARNING, "Read failed (BYTES_PER_SAMPLE)\n");
122 return -1;
123 }
124 if (ltohs(bysam) != 2) {
125 ast_log(LOG_WARNING, "Can only handle 16bits per sample: %d\n", ltohs(bysam));
126 return -1;
127 }
128 if (fread(&bisam, 1, 2, f) != 2) {
129 ast_log(LOG_WARNING, "Read failed (Bits Per Sample): %d\n", ltohs(bisam));
130 return -1;
131 }
132 /* Skip any additional header */
133 if (fseek(f,hsize-16,SEEK_CUR) == -1 ) {
134 ast_log(LOG_WARNING, "Failed to skip remaining header bytes: %d\n", hsize-16 );
135 return -1;
136 }
137 return 0;
138}
static struct chans chans
Definition: astman.c:88

References ast_log, chans, and LOG_WARNING.

Referenced by check_header().

◆ load_module()

static int load_module ( void  )
static

Definition at line 555 of file format_wav.c.

556{
563 }
565}
struct ast_format * ast_format_slin16
Built-in cached signed linear 16kHz format.
Definition: format_cache.c:51
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
static struct ast_format_def wav_f
Definition: format_wav.c:533
static struct ast_format_def wav16_f
Definition: format_wav.c:517
static int unload_module(void)
Definition: format_wav.c:549
#define ast_format_def_register(f)
Definition: mod_format.h:136
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
struct ast_format * format
Definition: mod_format.h:48

References ast_format_def_register, ast_format_slin, ast_format_slin16, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_format_def::format, unload_module(), wav16_f, and wav_f.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 549 of file format_wav.c.

550{
553}
int ast_format_def_unregister(const char *name)
Unregisters a file format.
Definition: file.c:162
char name[80]
Definition: mod_format.h:44

References ast_format_def_unregister(), ast_format_def::name, wav16_f, and wav_f.

Referenced by load_module().

◆ update_header()

static int update_header ( FILE *  f)
static

Definition at line 207 of file format_wav.c.

208{
209 off_t cur,end;
210 int datalen,filelen,bytes;
211
212 cur = ftello(f);
213 fseek(f, 0, SEEK_END);
214 end = ftello(f);
215 /* data starts 44 bytes in */
216 bytes = end - 44;
217 datalen = htoll(bytes);
218 /* chunk size is bytes of data plus 36 bytes of header */
219 filelen = htoll(36 + bytes);
220
221 if (cur < 0) {
222 ast_log(LOG_WARNING, "Unable to find our position\n");
223 return -1;
224 }
225 if (fseek(f, 4, SEEK_SET)) {
226 ast_log(LOG_WARNING, "Unable to set our position\n");
227 return -1;
228 }
229 if (fwrite(&filelen, 1, 4, f) != 4) {
230 ast_log(LOG_WARNING, "Unable to set write file size\n");
231 return -1;
232 }
233 if (fseek(f, 40, SEEK_SET)) {
234 ast_log(LOG_WARNING, "Unable to set our position\n");
235 return -1;
236 }
237 if (fwrite(&datalen, 1, 4, f) != 4) {
238 ast_log(LOG_WARNING, "Unable to set write datalen\n");
239 return -1;
240 }
241 if (fseeko(f, cur, SEEK_SET)) {
242 ast_log(LOG_WARNING, "Unable to return to position\n");
243 return -1;
244 }
245 return 0;
246}
char * end
Definition: eagi_proxy.c:73

References ast_log, end, and LOG_WARNING.

Referenced by wav_close(), and wav_trunc().

◆ wav_close()

static void wav_close ( struct ast_filestream s)
static

Definition at line 349 of file format_wav.c.

350{
351 char zero = 0;
352 struct wav_desc *fs = (struct wav_desc *)s->_private;
353
354 if (s->mode == O_RDONLY) {
355 return;
356 }
357
358 if (s->filename) {
359 update_header(s->f);
360 }
361
362 /* Pad to even length */
363 if (fs->bytes & 0x1) {
364 if (fwrite(&zero, 1, 1, s->f) != 1) {
365 ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
366 }
367 }
368}
if(!yyg->yy_init)
Definition: ast_expr2f.c:854
static int update_header(FILE *f)
Definition: format_wav.c:207
int errno
void * _private
Definition: mod_format.h:124
char * filename
Definition: mod_format.h:107
int bytes
Definition: format_wav.c:50

References ast_filestream::_private, ast_log, wav_desc::bytes, errno, ast_filestream::f, ast_filestream::filename, if(), LOG_WARNING, ast_filestream::mode, and update_header().

◆ wav_open()

static int wav_open ( struct ast_filestream s)
static

Definition at line 319 of file format_wav.c.

320{
321 /* We don't have any header to read or anything really, but
322 if we did, it would go here. We also might want to check
323 and be sure it's a valid file. */
324 struct wav_desc *tmp = s->_private;
325 unsigned int sample_rate = ast_format_get_sample_rate(s->fmt->format);
326
327 tmp->maxlen = check_header(s->f, sample_rate);
328 if (tmp->maxlen < 0) {
329 return -1;
330 }
331
332 tmp->hz = sample_rate;
333 return 0;
334}
static int tmp()
Definition: bt_open.c:389
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
static int check_header(FILE *f, int hz)
Definition: format_wav.c:140
struct ast_format_def * fmt
Definition: mod_format.h:103

References ast_filestream::_private, ast_format_get_sample_rate(), check_header(), ast_filestream::f, ast_filestream::fmt, ast_format_def::format, and tmp().

◆ wav_read()

static struct ast_frame * wav_read ( struct ast_filestream s,
int *  whennext 
)
static

Definition at line 370 of file format_wav.c.

371{
372 size_t res;
373 int samples; /* actual samples read */
374#if __BYTE_ORDER == __BIG_ENDIAN
375 int x;
376 short *tmp;
377#endif
378 int bytes;
379 off_t here;
380 /* Send a frame from the file to the appropriate channel */
381 struct wav_desc *fs = (struct wav_desc *)s->_private;
382
383 bytes = (fs->hz == 16000 ? (WAV_BUF_SIZE * 2) : WAV_BUF_SIZE);
384
385 here = ftello(s->f);
386 if (fs->maxlen - here < bytes) /* truncate if necessary */
387 bytes = fs->maxlen - here;
388 if (bytes <= 0) {
389 return NULL;
390 }
391/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
393
394 if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) == 0) {
395 if (res) {
396 ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
398 strerror(errno));
399 }
400 return NULL;
401 }
402 s->fr.datalen = res;
403 s->fr.samples = samples = res / 2;
404
405#if __BYTE_ORDER == __BIG_ENDIAN
406 tmp = (short *)(s->fr.data.ptr);
407 /* file format is little endian so we need to swap */
408 for( x = 0; x < samples; x++)
409 tmp[x] = (tmp[x] << 8) | ((tmp[x] & 0xff00) >> 8);
410#endif
411
412 *whennext = samples;
413 return &s->fr;
414}
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
#define WAV_BUF_SIZE
Definition: format_wav.c:44
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define NULL
Definition: resample.c:96
struct ast_frame fr
frame produced by read, typically
Definition: mod_format.h:122
struct ast_format * format
struct ast_frame_subclass subclass
union ast_frame::@226 data
int maxlen
Definition: format_wav.c:52
int hz
Definition: format_wav.c:49

References ast_filestream::_private, ast_format_get_name(), AST_FRAME_SET_BUFFER, AST_FRIENDLY_OFFSET, ast_log, ast_filestream::buf, wav_desc::bytes, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_frame_subclass::format, ast_filestream::fr, wav_desc::hz, LOG_WARNING, wav_desc::maxlen, NULL, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, tmp(), and WAV_BUF_SIZE.

◆ wav_rewrite()

static int wav_rewrite ( struct ast_filestream s,
const char *  comment 
)
static

Definition at line 336 of file format_wav.c.

337{
338 /* We don't have any header to read or anything really, but
339 if we did, it would go here. We also might want to check
340 and be sure it's a valid file. */
341
342 struct wav_desc *tmp = (struct wav_desc *)s->_private;
344 if (write_header(s->f,tmp->hz))
345 return -1;
346 return 0;
347}
static int write_header(FILE *f, int writehz)
Definition: format_wav.c:248

References ast_filestream::_private, ast_format_get_sample_rate(), ast_filestream::f, ast_filestream::fmt, ast_format_def::format, tmp(), and write_header().

◆ wav_seek()

static int wav_seek ( struct ast_filestream fs,
off_t  sample_offset,
int  whence 
)
static

Definition at line 453 of file format_wav.c.

454{
455 off_t min = WAV_HEADER_SIZE, max, cur, offset = 0, samples;
456
457 samples = sample_offset * 2; /* SLINEAR is 16 bits mono, so sample_offset * 2 = bytes */
458
459 if ((cur = ftello(fs->f)) < 0) {
460 ast_log(AST_LOG_WARNING, "Unable to determine current position in wav filestream %p: %s\n", fs, strerror(errno));
461 return -1;
462 }
463
464 if (fseeko(fs->f, 0, SEEK_END) < 0) {
465 ast_log(AST_LOG_WARNING, "Unable to seek to end of wav filestream %p: %s\n", fs, strerror(errno));
466 return -1;
467 }
468
469 if ((max = ftello(fs->f)) < 0) {
470 ast_log(AST_LOG_WARNING, "Unable to determine max position in wav filestream %p: %s\n", fs, strerror(errno));
471 return -1;
472 }
473
474 if (whence == SEEK_SET) {
475 offset = samples + min;
476 } else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) {
477 offset = samples + cur;
478 } else if (whence == SEEK_END) {
479 offset = max - samples;
480 }
481 if (whence != SEEK_FORCECUR) {
482 offset = (offset > max)?max:offset;
483 }
484 /* always protect the header space. */
485 offset = (offset < min)?min:offset;
486 return fseeko(fs->f, offset, SEEK_SET);
487}
#define min(a, b)
Definition: f2c.h:197
#define max(a, b)
Definition: f2c.h:198
#define SEEK_FORCECUR
Definition: file.h:51
#define WAV_HEADER_SIZE
Definition: format_wav.c:46
#define AST_LOG_WARNING

References ast_log, AST_LOG_WARNING, errno, ast_filestream::f, max, min, SEEK_FORCECUR, and WAV_HEADER_SIZE.

◆ wav_tell()

static off_t wav_tell ( struct ast_filestream fs)
static

Definition at line 509 of file format_wav.c.

510{
511 off_t offset;
512 offset = ftello(fs->f);
513 /* subtract header size to get samples, then divide by 2 for 16 bit samples */
514 return (offset - 44)/2;
515}

References ast_filestream::f.

◆ wav_trunc()

static int wav_trunc ( struct ast_filestream fs)
static

Definition at line 489 of file format_wav.c.

490{
491 int fd;
492 off_t cur;
493
494 if ((fd = fileno(fs->f)) < 0) {
495 ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for wav filestream %p: %s\n", fs, strerror(errno));
496 return -1;
497 }
498 if ((cur = ftello(fs->f)) < 0) {
499 ast_log(AST_LOG_WARNING, "Unable to determine current position in wav filestream %p: %s\n", fs, strerror(errno));
500 return -1;
501 }
502 /* Truncate file to current length */
503 if (ftruncate(fd, cur)) {
504 return -1;
505 }
506 return update_header(fs->f);
507}

References ast_log, AST_LOG_WARNING, errno, ast_filestream::f, and update_header().

◆ wav_write()

static int wav_write ( struct ast_filestream fs,
struct ast_frame f 
)
static

Definition at line 416 of file format_wav.c.

417{
418#if __BYTE_ORDER == __BIG_ENDIAN
419 int x;
420 short tmp[16000], *tmpi;
421#endif
422 struct wav_desc *s = (struct wav_desc *)fs->_private;
423 int res;
424
425 if (!f->datalen)
426 return -1;
427
428#if __BYTE_ORDER == __BIG_ENDIAN
429 /* swap and write */
430 if (f->datalen > sizeof(tmp)) {
431 ast_log(LOG_WARNING, "Data length is too long\n");
432 return -1;
433 }
434 tmpi = f->data.ptr;
435 for (x=0; x < f->datalen/2; x++)
436 tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8);
437
438 if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) {
439#else
440 /* just write */
441 if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen ) {
442#endif
443 ast_log(LOG_WARNING, "Bad write (%d): %s\n", res, strerror(errno));
444 return -1;
445 }
446
447 s->bytes += f->datalen;
448
449 return 0;
450
451}

References ast_filestream::_private, ast_log, wav_desc::bytes, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, if(), LOG_WARNING, ast_frame::ptr, and tmp().

◆ write_header()

static int write_header ( FILE *  f,
int  writehz 
)
static

Definition at line 248 of file format_wav.c.

249{
250 unsigned int hz;
251 unsigned int bhz;
252 unsigned int hs = htoll(16);
253 unsigned short fmt = htols(1);
254 unsigned short chans = htols(1);
255 unsigned short bysam = htols(2);
256 unsigned short bisam = htols(16);
257 unsigned int size = htoll(0);
258
259 if (writehz == 16000) {
260 hz = htoll(16000);
261 bhz = htoll(32000);
262 } else {
263 hz = htoll(8000);
264 bhz = htoll(16000);
265 }
266 /* Write a wav header, ignoring sizes which will be filled in later */
267 fseek(f,0,SEEK_SET);
268 if (fwrite("RIFF", 1, 4, f) != 4) {
269 ast_log(LOG_WARNING, "Unable to write header\n");
270 return -1;
271 }
272 if (fwrite(&size, 1, 4, f) != 4) {
273 ast_log(LOG_WARNING, "Unable to write header\n");
274 return -1;
275 }
276 if (fwrite("WAVEfmt ", 1, 8, f) != 8) {
277 ast_log(LOG_WARNING, "Unable to write header\n");
278 return -1;
279 }
280 if (fwrite(&hs, 1, 4, f) != 4) {
281 ast_log(LOG_WARNING, "Unable to write header\n");
282 return -1;
283 }
284 if (fwrite(&fmt, 1, 2, f) != 2) {
285 ast_log(LOG_WARNING, "Unable to write header\n");
286 return -1;
287 }
288 if (fwrite(&chans, 1, 2, f) != 2) {
289 ast_log(LOG_WARNING, "Unable to write header\n");
290 return -1;
291 }
292 if (fwrite(&hz, 1, 4, f) != 4) {
293 ast_log(LOG_WARNING, "Unable to write header\n");
294 return -1;
295 }
296 if (fwrite(&bhz, 1, 4, f) != 4) {
297 ast_log(LOG_WARNING, "Unable to write header\n");
298 return -1;
299 }
300 if (fwrite(&bysam, 1, 2, f) != 2) {
301 ast_log(LOG_WARNING, "Unable to write header\n");
302 return -1;
303 }
304 if (fwrite(&bisam, 1, 2, f) != 2) {
305 ast_log(LOG_WARNING, "Unable to write header\n");
306 return -1;
307 }
308 if (fwrite("data", 1, 4, f) != 4) {
309 ast_log(LOG_WARNING, "Unable to write header\n");
310 return -1;
311 }
312 if (fwrite(&size, 1, 4, f) != 4) {
313 ast_log(LOG_WARNING, "Unable to write header\n");
314 return -1;
315 }
316 return 0;
317}

References ast_log, and LOG_WARNING.

Referenced by wav_rewrite().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Microsoft WAV/WAV16 format (8kHz/16kHz Signed Linear)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND }
static

Definition at line 572 of file format_wav.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 572 of file format_wav.c.

◆ wav16_f

struct ast_format_def wav16_f
static

Definition at line 517 of file format_wav.c.

Referenced by load_module(), and unload_module().

◆ wav_f

struct ast_format_def wav_f
static

Definition at line 533 of file format_wav.c.

Referenced by load_module(), and unload_module().