mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
Version 0.1.9 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@323 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -177,10 +177,10 @@ static struct ast_frame *lintogsm_frameout(struct ast_translator_pvt *tmp)
|
|||||||
while(tmp->tail >= 160) {
|
while(tmp->tail >= 160) {
|
||||||
if ((x+1) * 33 >= sizeof(tmp->outbuf)) {
|
if ((x+1) * 33 >= sizeof(tmp->outbuf)) {
|
||||||
ast_log(LOG_WARNING, "Out of buffer space\n");
|
ast_log(LOG_WARNING, "Out of buffer space\n");
|
||||||
return NULL;
|
break;
|
||||||
}
|
}
|
||||||
/* Encode a frame of data */
|
/* Encode a frame of data */
|
||||||
gsm_encode(tmp->gsm, tmp->buf, (gsm_byte *) tmp->outbuf + (x * 33));
|
gsm_encode(tmp->gsm, tmp->buf, ((gsm_byte *) tmp->outbuf) + (x * 33));
|
||||||
/* Assume 8000 Hz -- 20 ms */
|
/* Assume 8000 Hz -- 20 ms */
|
||||||
tmp->tail -= 160;
|
tmp->tail -= 160;
|
||||||
/* Move the data at the end of the buffer to the front */
|
/* Move the data at the end of the buffer to the front */
|
||||||
|
@@ -504,6 +504,7 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
char msdata[66];
|
char msdata[66];
|
||||||
|
int len =0;
|
||||||
if (f->frametype != AST_FRAME_VOICE) {
|
if (f->frametype != AST_FRAME_VOICE) {
|
||||||
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
|
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -512,20 +513,23 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
|
|||||||
ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
|
ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (fs->secondhalf) {
|
while(len < f->datalen) {
|
||||||
memcpy(fs->gsm + 33, f->data, 33);
|
if (fs->secondhalf) {
|
||||||
conv66(fs->gsm, msdata);
|
memcpy(fs->gsm + 33, f->data + len, 33);
|
||||||
if ((res = write(fs->fd, msdata, 65)) != 65) {
|
conv66(fs->gsm, msdata);
|
||||||
ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));
|
if ((res = write(fs->fd, msdata, 65)) != 65) {
|
||||||
return -1;
|
ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fs->bytes += 65;
|
||||||
|
update_header(fs->fd, fs->bytes);
|
||||||
|
} else {
|
||||||
|
/* Copy the data and do nothing */
|
||||||
|
memcpy(fs->gsm, f->data + len, 33);
|
||||||
}
|
}
|
||||||
fs->bytes += 65;
|
fs->secondhalf = !fs->secondhalf;
|
||||||
update_header(fs->fd, fs->bytes);
|
len += 33;
|
||||||
} else {
|
|
||||||
/* Copy the data and do nothing */
|
|
||||||
memcpy(fs->gsm, f->data, 33);
|
|
||||||
}
|
}
|
||||||
fs->secondhalf = !fs->secondhalf;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user