39 #define VOX_SAMPLES 160
49 ast_log(LOG_WARNING,
"Short read of %s data (expected %d bytes, read %zu): %s\n",
64 ast_log(LOG_WARNING,
"Bad write (%d/%d): %s\n", res, f->
datalen, strerror(errno));
70 static int vox_seek(
struct ast_filestream *fs, off_t sample_offset,
int whence)
72 off_t
offset = 0, min = 0, cur, max, distance;
74 if ((cur = ftello(fs->f)) < 0) {
75 ast_log(AST_LOG_WARNING,
"Unable to determine current position in g719 filestream %p: %s\n", fs, strerror(errno));
79 if (fseeko(fs->f, 0, SEEK_END) < 0) {
80 ast_log(AST_LOG_WARNING,
"Unable to seek to end of g719 filestream %p: %s\n", fs, strerror(errno));
84 if ((max = ftello(fs->f)) < 0) {
85 ast_log(AST_LOG_WARNING,
"Unable to determine max position in g719 filestream %p: %s\n", fs, strerror(errno));
90 distance = sample_offset/2;
91 if (whence == SEEK_SET) {
93 }
else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) {
94 offset = distance + cur;
95 }
else if (whence == SEEK_END) {
96 offset = max - distance;
98 if (whence != SEEK_FORCECUR) {
99 offset = (offset > max)?max:offset;
100 offset = (offset < min)?min:offset;
102 return fseeko(fs->f, offset, SEEK_SET);
110 if ((fd = fileno(fs->f)) < 0) {
111 ast_log(AST_LOG_WARNING,
"Unable to determine file descriptor for vox filestream %p: %s\n", fs, strerror(errno));
114 if ((cur = ftello(fs->f)) < 0) {
115 ast_log(AST_LOG_WARNING,
"Unable to determine current position in vox filestream %p: %s\n", fs, strerror(errno));
119 return ftruncate(fd, cur);}
124 offset = ftello(fs->f) << 1;
131 .mime_types =
"audio/x-vox",
140 static int load_module(
void)
143 if (ast_format_def_register(&vox_f))
148 static int unload_module(
void)
153 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"Dialogic VOX (ADPCM) File Format",
154 .support_level = AST_MODULE_SUPPORT_EXTENDED,
156 .unload = unload_module,
Asterisk main include file. File version handling, generic pbx functions.
struct ast_frame_subclass subclass
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk architecture endianess compatibility definitions.
struct ast_frame fr
frame produced by read, typically
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
union ast_frame::@224 data
Module has failed to load, may be in an inconsistent state.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Data structure associated with a single frame of data.
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.