45 #define G729A_SAMPLES 160
55 if (res && res != 10) {
56 ast_log(LOG_WARNING,
"Short read of %s data (expected %d bytes, read %zu): %s\n",
71 ast_log(LOG_WARNING,
"Invalid data length, %d, should be multiple of 10\n", f->
datalen);
75 ast_log(LOG_WARNING,
"Bad write (%d/10): %s\n", res, strerror(errno));
81 static int g729_seek(
struct ast_filestream *fs, off_t sample_offset,
int whence)
84 off_t min,cur,max,
offset=0;
87 fseeko(fs->f, 0, SEEK_END);
90 bytes = BUF_SIZE * (sample_offset / G729A_SAMPLES);
91 if (whence == SEEK_SET)
93 else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
95 else if (whence == SEEK_END)
97 if (whence != SEEK_FORCECUR) {
98 offset = (offset > max)?max:offset;
101 offset = (offset < min)?min:offset;
102 if (fseeko(fs->f, offset, SEEK_SET) < 0)
112 if ((fd = fileno(fs->f)) < 0) {
113 ast_log(AST_LOG_WARNING,
"Unable to determine file descriptor for g729 filestream %p: %s\n", fs, strerror(errno));
116 if ((cur = ftello(fs->f)) < 0) {
117 ast_log(AST_LOG_WARNING,
"Unable to determine current position in g729 filestream %p: %s\n", fs, strerror(errno));
121 return ftruncate(fd, cur);
126 off_t offset = ftello(fs->f);
127 return (offset/BUF_SIZE)*G729A_SAMPLES;
141 static int load_module(
void)
144 if (ast_format_def_register(&g729_f))
149 static int unload_module(
void)
155 .support_level = AST_MODULE_SUPPORT_CORE,
157 .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.