@ -635,11 +635,13 @@ static int read_key(void)
return - 1 ;
return - 1 ;
}
}
static int decode_interrupt_cb ( void )
static int decode_interrupt_cb ( void * ctx )
{
{
return received_nb_signals > 1 ;
return received_nb_signals > 1 ;
}
}
static const AVIOInterruptCB int_cb = { decode_interrupt_cb , NULL } ;
void av_noreturn exit_program ( int ret )
void av_noreturn exit_program ( int ret )
{
{
int i ;
int i ;
@ -2403,6 +2405,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
/* open files and write file headers */
/* open files and write file headers */
for ( i = 0 ; i < nb_output_files ; i + + ) {
for ( i = 0 ; i < nb_output_files ; i + + ) {
os = output_files [ i ] . ctx ;
os = output_files [ i ] . ctx ;
os - > interrupt_callback = int_cb ;
if ( avformat_write_header ( os , & output_files [ i ] . opts ) < 0 ) {
if ( avformat_write_header ( os , & output_files [ i ] . opts ) < 0 ) {
snprintf ( error , sizeof ( error ) , " Could not write header for output file #%d (incorrect codec parameters ?) " , i ) ;
snprintf ( error , sizeof ( error ) , " Could not write header for output file #%d (incorrect codec parameters ?) " , i ) ;
ret = AVERROR ( EINVAL ) ;
ret = AVERROR ( EINVAL ) ;
@ -2495,7 +2498,6 @@ static int transcode(OutputFile *output_files, int nb_output_files,
if ( ! using_stdin ) {
if ( ! using_stdin ) {
av_log ( NULL , AV_LOG_INFO , " Press [q] to stop, [?] for help \n " ) ;
av_log ( NULL , AV_LOG_INFO , " Press [q] to stop, [?] for help \n " ) ;
avio_set_interrupt_cb ( decode_interrupt_cb ) ;
}
}
timer_start = av_gettime ( ) ;
timer_start = av_gettime ( ) ;
@ -3243,7 +3245,7 @@ static void dump_attachment(AVStream *st, const char *filename)
assert_file_overwrite ( filename ) ;
assert_file_overwrite ( filename ) ;
if ( ( ret = avio_open ( & out , filename , AVIO_FLAG_WRITE ) ) < 0 ) {
if ( ( ret = avio_open2 ( & out , filename , AVIO_FLAG_WRITE , & int_cb , NULL ) ) < 0 ) {
av_log ( NULL , AV_LOG_FATAL , " Could not open file %s for writing. \n " ,
av_log ( NULL , AV_LOG_FATAL , " Could not open file %s for writing. \n " ,
filename ) ;
filename ) ;
exit_program ( 1 ) ;
exit_program ( 1 ) ;
@ -3307,6 +3309,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena
ic - > subtitle_codec_id = subtitle_codec_name ?
ic - > subtitle_codec_id = subtitle_codec_name ?
find_codec_or_die ( subtitle_codec_name , AVMEDIA_TYPE_SUBTITLE , 0 ) - > id : CODEC_ID_NONE ;
find_codec_or_die ( subtitle_codec_name , AVMEDIA_TYPE_SUBTITLE , 0 ) - > id : CODEC_ID_NONE ;
ic - > flags | = AVFMT_FLAG_NONBLOCK ;
ic - > flags | = AVFMT_FLAG_NONBLOCK ;
ic - > interrupt_callback = int_cb ;
if ( loop_input ) {
if ( loop_input ) {
av_log ( NULL , AV_LOG_WARNING , " -loop_input is deprecated, use -loop 1 \n " ) ;
av_log ( NULL , AV_LOG_WARNING , " -loop_input is deprecated, use -loop 1 \n " ) ;
@ -3438,12 +3441,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV
if ( codec_name ) {
if ( codec_name ) {
snprintf ( filename , sizeof ( filename ) , " %s%s/%s-%s.avpreset " , base [ i ] ,
snprintf ( filename , sizeof ( filename ) , " %s%s/%s-%s.avpreset " , base [ i ] ,
i ! = 1 ? " " : " /.avconv " , codec_name , preset_name ) ;
i ! = 1 ? " " : " /.avconv " , codec_name , preset_name ) ;
ret = avio_open ( s , filename , AVIO_FLAG_READ ) ;
ret = avio_open2 ( s , filename , AVIO_FLAG_READ , & int_cb , NULL ) ;
}
}
if ( ret ) {
if ( ret ) {
snprintf ( filename , sizeof ( filename ) , " %s%s/%s.avpreset " , base [ i ] ,
snprintf ( filename , sizeof ( filename ) , " %s%s/%s.avpreset " , base [ i ] ,
i ! = 1 ? " " : " /.avconv " , preset_name ) ;
i ! = 1 ? " " : " /.avconv " , preset_name ) ;
ret = avio_open ( s , filename , AVIO_FLAG_READ ) ;
ret = avio_open2 ( s , filename , AVIO_FLAG_READ , & int_cb , NULL ) ;
}
}
}
}
return ret ;
return ret ;
@ -3856,8 +3859,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata)
static int read_ffserver_streams ( OptionsContext * o , AVFormatContext * s , const char * filename )
static int read_ffserver_streams ( OptionsContext * o , AVFormatContext * s , const char * filename )
{
{
int i , err ;
int i , err ;
AVFormatContext * ic = NULL ;
AVFormatContext * ic = avformat_alloc_context ( ) ;
ic - > interrupt_callback = int_cb ;
err = avformat_open_input ( & ic , filename , NULL , NULL ) ;
err = avformat_open_input ( & ic , filename , NULL , NULL ) ;
if ( err < 0 )
if ( err < 0 )
return err ;
return err ;
@ -3908,6 +3912,7 @@ static void opt_output_file(void *optctx, const char *filename)
exit_program ( 1 ) ;
exit_program ( 1 ) ;
}
}
file_oformat = oc - > oformat ;
file_oformat = oc - > oformat ;
oc - > interrupt_callback = int_cb ;
if ( ! strcmp ( file_oformat - > name , " ffm " ) & &
if ( ! strcmp ( file_oformat - > name , " ffm " ) & &
av_strstart ( filename , " http: " , NULL ) ) {
av_strstart ( filename , " http: " , NULL ) ) {
@ -4019,7 +4024,7 @@ static void opt_output_file(void *optctx, const char *filename)
const char * p ;
const char * p ;
int64_t len ;
int64_t len ;
if ( ( err = avio_open ( & pb , o - > attachments [ i ] , AVIO_FLAG_READ ) ) < 0 ) {
if ( ( err = avio_open2 ( & pb , o - > attachments [ i ] , AVIO_FLAG_READ , & int_cb , NULL ) ) < 0 ) {
av_log ( NULL , AV_LOG_FATAL , " Could not open attachment file %s. \n " ,
av_log ( NULL , AV_LOG_FATAL , " Could not open attachment file %s. \n " ,
o - > attachments [ i ] ) ;
o - > attachments [ i ] ) ;
exit_program ( 1 ) ;
exit_program ( 1 ) ;
@ -4069,7 +4074,9 @@ static void opt_output_file(void *optctx, const char *filename)
assert_file_overwrite ( filename ) ;
assert_file_overwrite ( filename ) ;
/* open the file */
/* open the file */
if ( ( err = avio_open ( & oc - > pb , filename , AVIO_FLAG_WRITE ) ) < 0 ) {
if ( ( err = avio_open2 ( & oc - > pb , filename , AVIO_FLAG_WRITE ,
& oc - > interrupt_callback ,
& output_files [ nb_output_files - 1 ] . opts ) ) < 0 ) {
print_error ( filename , err ) ;
print_error ( filename , err ) ;
exit_program ( 1 ) ;
exit_program ( 1 ) ;
}
}
@ -4725,12 +4732,6 @@ int main(int argc, char **argv)
av_register_all ( ) ;
av_register_all ( ) ;
avformat_network_init ( ) ;
avformat_network_init ( ) ;
# if HAVE_ISATTY
if ( isatty ( STDIN_FILENO ) )
avio_set_interrupt_cb ( decode_interrupt_cb ) ;
# endif
show_banner ( ) ;
term_init ( ) ;
term_init ( ) ;