Update of /usr/cvsroot/asterisk-addons/format_mp3
In directory mongoose.digium.com:/tmp/cvs-serv26947/format_mp3

Modified Files:
        format_mp3.c 
Log Message:
Update format mp3 for new streams based methods


Index: format_mp3.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/format_mp3/format_mp3.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- format_mp3.c        9 Jan 2005 09:06:33 -0000       1.3
+++ format_mp3.c        17 Oct 2005 03:42:26 -0000      1.4
@@ -46,7 +46,7 @@
 struct ast_filestream {
        void *reserved[AST_RESERVED_POINTERS];
        /* This is what a filestream means to us */
-       int fd; /* Descriptor */
+       FILE *f; /* Descriptor */
        struct ast_frame fr;                            /* Frame information */
        char waste[AST_FRIENDLY_OFFSET];        /* Buffer for sending frames, 
etc */
        char empty;                                                     /* 
Empty character */
@@ -103,7 +103,7 @@
 #endif
 
 
-static struct ast_filestream *mp3_open(int fd)
+static struct ast_filestream *mp3_open(FILE *f)
 {
        struct ast_filestream *tmp;
        if ((tmp = malloc(sizeof(struct ast_filestream)))) {
@@ -115,7 +115,7 @@
                }
                InitMP3(&tmp->mp, OUTSCALE);
                tmp->dbuflen = 0;
-               tmp->fd = fd;
+               tmp->f = f;
                tmp->fr.data = tmp->buf;
                tmp->fr.frametype = AST_FRAME_VOICE;
                tmp->fr.subclass = AST_FORMAT_SLINEAR;
@@ -143,7 +143,7 @@
        glistcnt--;
        ast_mutex_unlock(&mp3_lock);
        ast_update_use_count();
-       close(s->fd);
+       fclose(s->f);
        free(s);
        s = NULL;
 
@@ -152,8 +152,8 @@
 static int mp3_squeue(struct ast_filestream *s) 
 {
        int res=0;
-       s->lastseek = lseek(s->fd, 0, SEEK_CUR);
-       s->sbuflen = read(s->fd, s->sbuf, MP3_SCACHE);
+       s->lastseek = ftell(s->f);
+       s->sbuflen = fread(s->sbuf, 1, MP3_SCACHE, s->f);
        if(s->sbuflen < 0) {
                ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", s->sbuflen, 
strerror(errno));
                return -1;
@@ -179,7 +179,7 @@
        if(s->seek) {
                ExitMP3(&s->mp);
                InitMP3(&s->mp, OUTSCALE);
-               lseek(s->fd, 0, SEEK_SET);
+               fseek(s->f, 0, SEEK_SET);
                s->sbuflen = s->dbuflen = s->offset = 0;
                while(s->offset < s->seek) {
                        if(mp3_squeue(s))
@@ -279,7 +279,8 @@
        samples = sample_offset * 2;
 
        min = 0;
-       max = lseek(fs->fd, 0, SEEK_END) * 100;
+       fseek(fs->f, 0, SEEK_END);
+       max = ftell(fs->f) * 100;
        cur = fs->offset;
 
        if (whence == SEEK_SET)
@@ -297,7 +298,7 @@
        
 }
 
-static struct ast_filestream *mp3_rewrite(int fd, const char *comment) 
+static struct ast_filestream *mp3_rewrite(FILE *f, const char *comment) 
 {
        ast_log(LOG_ERROR,"I Can't write MP3 only read them.\n");
        return NULL;

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to