43 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 slinear_seek(
struct ast_filestream *fs, off_t sample_offset,
int whence)
72 off_t
offset=0, min = 0, cur, max;
76 if ((cur = ftello(fs->f)) < 0) {
77 ast_log(AST_LOG_WARNING,
"Unable to determine current position in sln filestream %p: %s\n", fs, strerror(errno));
81 if (fseeko(fs->f, 0, SEEK_END) < 0) {
82 ast_log(AST_LOG_WARNING,
"Unable to seek to end of sln filestream %p: %s\n", fs, strerror(errno));
86 if ((max = ftello(fs->f)) < 0) {
87 ast_log(AST_LOG_WARNING,
"Unable to determine max position in sln filestream %p: %s\n", fs, strerror(errno));
91 if (whence == SEEK_SET)
92 offset = sample_offset;
93 else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
94 offset = sample_offset + cur;
95 else if (whence == SEEK_END)
96 offset = max - sample_offset;
97 if (whence != SEEK_FORCECUR) {
98 offset = (offset > max)?max:offset;
101 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 sln 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 sln filestream %p: %s\n", fs, strerror(errno));
119 return ftruncate(fd, cur);
124 return ftello(fs->f) / 2;
127 static struct ast_frame *slinear_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 320);}
130 .exts =
"sln|slin|raw",
131 .write = slinear_write,
132 .seek = slinear_seek,
133 .trunc = slinear_trunc,
134 .tell = slinear_tell,
135 .read = slinear_read,
139 static struct ast_frame *slinear12_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 480);}
143 .write = slinear_write,
144 .seek = slinear_seek,
145 .trunc = slinear_trunc,
146 .tell = slinear_tell,
147 .read = slinear12_read,
151 static struct ast_frame *slinear16_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 640);}
155 .write = slinear_write,
156 .seek = slinear_seek,
157 .trunc = slinear_trunc,
158 .tell = slinear_tell,
159 .read = slinear16_read,
163 static struct ast_frame *slinear24_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 960);}
167 .write = slinear_write,
168 .seek = slinear_seek,
169 .trunc = slinear_trunc,
170 .tell = slinear_tell,
171 .read = slinear24_read,
175 static struct ast_frame *slinear32_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 1280);}
179 .write = slinear_write,
180 .seek = slinear_seek,
181 .trunc = slinear_trunc,
182 .tell = slinear_tell,
183 .read = slinear32_read,
187 static struct ast_frame *slinear44_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 1764);}
191 .write = slinear_write,
192 .seek = slinear_seek,
193 .trunc = slinear_trunc,
194 .tell = slinear_tell,
195 .read = slinear44_read,
199 static struct ast_frame *slinear48_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 1920);}
203 .write = slinear_write,
204 .seek = slinear_seek,
205 .trunc = slinear_trunc,
206 .tell = slinear_tell,
207 .read = slinear48_read,
211 static struct ast_frame *slinear96_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 3840);}
215 .write = slinear_write,
216 .seek = slinear_seek,
217 .trunc = slinear_trunc,
218 .tell = slinear_tell,
219 .read = slinear96_read,
223 static struct ast_frame *slinear192_read(
struct ast_filestream *s,
int *whennext){
return generic_read(s, whennext, 7680);}
227 .write = slinear_write,
228 .seek = slinear_seek,
229 .trunc = slinear_trunc,
230 .tell = slinear_tell,
231 .read = slinear192_read,
247 static int unload_module(
void)
252 for (i = 0; i < ARRAY_LEN(slin_list); i++) {
260 static int load_module(
void)
274 for (i = 0; i < ARRAY_LEN(slin_list); i++) {
275 if (ast_format_def_register(slin_list[i])) {
284 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"Raw Signed Linear Audio support (SLN) 8khz-192khz",
285 .support_level = AST_MODULE_SUPPORT_CORE,
287 .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.