@ -59,7 +59,7 @@ struct media_player_cache_packet {
static mutex_t media_player_cache_lock ;
static mutex_t media_player_cache_lock ;
static GHashTable * media_player_cache ; / / keys and values only ever freed at shutdown
static GHashTable * media_player_cache ; / / keys and values only ever freed at shutdown
static void media_player_read_packet ( struct media_player * mp ) ;
static bool media_player_read_packet ( struct media_player * mp ) ;
# endif
# endif
static struct timerthread send_timer_thread ;
static struct timerthread send_timer_thread ;
@ -357,7 +357,7 @@ static void media_player_coder_add_packet(struct media_player_coder *c,
}
}
static void media_player_read_decoded_packet ( struct media_player * mp ) {
static bool media_player_read_decoded_packet ( struct media_player * mp ) {
struct media_player_cache_entry * entry = mp - > cache_entry ;
struct media_player_cache_entry * entry = mp - > cache_entry ;
if ( ! entry )
if ( ! entry )
return ;
return ;
@ -392,7 +392,7 @@ retry:;
if ( mp - > repeat < = 1 ) {
if ( mp - > repeat < = 1 ) {
ilog ( LOG_DEBUG , " EOF reading from media buffer (%s), stopping playback " ,
ilog ( LOG_DEBUG , " EOF reading from media buffer (%s), stopping playback " ,
entry - > info_str ) ;
entry - > info_str ) ;
return ;
return true ;
}
}
ilog ( LOG_DEBUG , " EOF reading from media buffer (%s) but will repeat %li time " ,
ilog ( LOG_DEBUG , " EOF reading from media buffer (%s) but will repeat %li time " ,
@ -443,6 +443,8 @@ retry:;
/ / schedule our next run
/ / schedule our next run
timeval_add_usec ( & mp - > next_run , us_dur ) ;
timeval_add_usec ( & mp - > next_run , us_dur ) ;
timerthread_obj_schedule_abs ( & mp - > tt_obj , & mp - > next_run ) ;
timerthread_obj_schedule_abs ( & mp - > tt_obj , & mp - > next_run ) ;
return false ;
}
}
static void media_player_cached_reader_start ( struct media_player * mp , const struct rtp_payload_type * dst_pt ,
static void media_player_cached_reader_start ( struct media_player * mp , const struct rtp_payload_type * dst_pt ,
@ -816,9 +818,9 @@ void media_player_add_packet(struct media_player *mp, char *buf, size_t len,
/ / appropriate lock must be held
/ / appropriate lock must be held
static void media_player_read_packet ( struct media_player * mp ) {
static bool media_player_read_packet ( struct media_player * mp ) {
if ( ! mp - > coder . fmtctx )
if ( ! mp - > coder . fmtctx )
return ;
return true ;
int ret = av_read_frame ( mp - > coder . fmtctx , mp - > coder . pkt ) ;
int ret = av_read_frame ( mp - > coder . fmtctx , mp - > coder . pkt ) ;
if ( ret < 0 ) {
if ( ret < 0 ) {
@ -835,14 +837,14 @@ static void media_player_read_packet(struct media_player *mp) {
ret = av_read_frame ( mp - > coder . fmtctx , mp - > coder . pkt ) ;
ret = av_read_frame ( mp - > coder . fmtctx , mp - > coder . pkt ) ;
} else {
} else {
ilog ( LOG_DEBUG , " EOF reading from media stream " ) ;
ilog ( LOG_DEBUG , " EOF reading from media stream " ) ;
return ;
return true ;
}
}
}
}
if ( ret < 0 & & ret ! = AVERROR_EOF ) {
if ( ret < 0 & & ret ! = AVERROR_EOF ) {
ilog ( LOG_ERR , " Error while reading from media stream " ) ;
ilog ( LOG_ERR , " Error while reading from media stream " ) ;
return ;
return true ;
}
}
}
}
@ -852,6 +854,8 @@ static void media_player_read_packet(struct media_player *mp) {
media_player_coder_add_packet ( & mp - > coder , ( void * ) media_player_add_packet , mp ) ;
media_player_coder_add_packet ( & mp - > coder , ( void * ) media_player_add_packet , mp ) ;
av_packet_unref ( mp - > coder . pkt ) ;
av_packet_unref ( mp - > coder . pkt ) ;
return false ;
}
}
@ -1180,11 +1184,22 @@ static void media_player_run(void *ptr) {
rwlock_lock_r ( & call - > master_lock ) ;
rwlock_lock_r ( & call - > master_lock ) ;
mutex_lock ( & mp - > lock ) ;
mutex_lock ( & mp - > lock ) ;
mp - > run_func ( mp ) ;
bool finished = mp - > run_func ( mp ) ;
mutex_unlock ( & mp - > lock ) ;
mutex_unlock ( & mp - > lock ) ;
rwlock_unlock_r ( & call - > master_lock ) ;
rwlock_unlock_r ( & call - > master_lock ) ;
if ( finished ) {
rwlock_lock_w ( & call - > master_lock ) ;
mp - > next_run . tv_sec = 0 ;
codec_update_all_source_handlers ( mp - > media - > monologue , NULL ) ;
update_init_subscribers ( mp - > media - > monologue , OP_OTHER ) ;
rwlock_unlock_w ( & call - > master_lock ) ;
}
log_info_pop ( ) ;
log_info_pop ( ) ;
}
}