Changeset 1690


Ignore:
Timestamp:
Jan 14, 2008 4:12:41 PM (11 years ago)
Author:
bennylp
Message:

Related to ticket #447: the WAV player should consistently return non-PJ_SUCCESS after it has returned one

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/wav_player.c

    r1685 r1690  
    5353#endif 
    5454 
    55 struct file_port 
     55struct file_reader_port 
    5656{ 
    5757    pjmedia_port     base; 
     
    7575static pj_status_t file_on_destroy(pjmedia_port *this_port); 
    7676 
    77 static struct file_port *create_file_port(pj_pool_t *pool) 
     77static struct file_reader_port *create_file_port(pj_pool_t *pool) 
    7878{ 
    7979    const pj_str_t name = pj_str("file"); 
    80     struct file_port *port; 
    81  
    82     port = PJ_POOL_ZALLOC_T(pool, struct file_port); 
     80    struct file_reader_port *port; 
     81 
     82    port = PJ_POOL_ZALLOC_T(pool, struct file_reader_port); 
    8383    if (!port) 
    8484        return NULL; 
     
    100100 * Fill buffer. 
    101101 */ 
    102 static pj_status_t fill_buffer(struct file_port *fport) 
     102static pj_status_t fill_buffer(struct file_reader_port *fport) 
    103103{ 
    104104    pj_ssize_t size_left = fport->bufsize; 
     
    193193    pjmedia_wave_hdr wave_hdr; 
    194194    pj_ssize_t size_to_read, size_read; 
    195     struct file_port *fport; 
     195    struct file_reader_port *fport; 
    196196    pj_off_t pos; 
    197197    pj_status_t status; 
     
    410410PJ_DEF(pj_ssize_t) pjmedia_wav_player_get_len(pjmedia_port *port) 
    411411{ 
    412     struct file_port *fport; 
     412    struct file_reader_port *fport; 
    413413    pj_ssize_t size; 
    414414 
     
    419419    PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, -PJ_EINVALIDOP); 
    420420 
    421     fport = (struct file_port*) port; 
     421    fport = (struct file_reader_port*) port; 
    422422 
    423423    size = (pj_ssize_t) fport->fsize; 
     
    432432                                                    pj_uint32_t bytes ) 
    433433{ 
    434     struct file_port *fport; 
     434    struct file_reader_port *fport; 
    435435 
    436436    /* Sanity check */ 
     
    441441 
    442442 
    443     fport = (struct file_port*) port; 
     443    fport = (struct file_reader_port*) port; 
    444444 
    445445    PJ_ASSERT_RETURN(bytes < fport->fsize - fport->start_data, PJ_EINVAL); 
     
    458458PJ_DEF(pj_ssize_t) pjmedia_wav_player_port_get_pos( pjmedia_port *port ) 
    459459{ 
    460     struct file_port *fport; 
     460    struct file_reader_port *fport; 
    461461    pj_size_t payload_pos; 
    462462 
     
    467467    PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, -PJ_EINVALIDOP); 
    468468 
    469     fport = (struct file_port*) port; 
     469    fport = (struct file_reader_port*) port; 
    470470 
    471471    payload_pos = (pj_size_t)(fport->fpos - fport->start_data); 
     
    487487                                                 void *usr_data)) 
    488488{ 
    489     struct file_port *fport; 
     489    struct file_reader_port *fport; 
    490490 
    491491    /* Sanity check */ 
     
    495495    PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, -PJ_EINVALIDOP); 
    496496 
    497     fport = (struct file_port*) port; 
     497    fport = (struct file_reader_port*) port; 
    498498 
    499499    fport->base.port_data.pdata = user_data; 
     
    510510                                  pjmedia_frame *frame) 
    511511{ 
    512     struct file_port *fport = (struct file_port*)this_port; 
     512    struct file_reader_port *fport = (struct file_reader_port*)this_port; 
    513513    unsigned frame_size; 
    514514    pj_status_t status; 
     
    539539                frame->type = PJMEDIA_FRAME_TYPE_NONE; 
    540540                frame->size = 0; 
     541                fport->readpos = fport->buf + fport->bufsize; 
    541542                return status; 
    542543            } 
     
    563564            } 
    564565            fport->readpos = fport->buf + fport->bufsize; 
    565             return PJ_SUCCESS; 
     566            return (endread? PJ_SUCCESS : status); 
    566567        } 
    567568 
     
    578579static pj_status_t file_on_destroy(pjmedia_port *this_port) 
    579580{ 
    580     struct file_port *fport = (struct file_port*) this_port; 
     581    struct file_reader_port *fport = (struct file_reader_port*) this_port; 
    581582 
    582583    pj_assert(this_port->info.signature == SIGNATURE); 
Note: See TracChangeset for help on using the changeset viewer.