Commit ca3b58b2 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Use stream_UrlNew for vobsub loading instead of fopen. closes #567

parent 576a7246
...@@ -94,7 +94,7 @@ struct demux_sys_t ...@@ -94,7 +94,7 @@ struct demux_sys_t
int64_t i_length; int64_t i_length;
text_t txt; text_t txt;
FILE *p_vobsub_file; stream_t *p_vobsub_stream;
/* all tracks */ /* all tracks */
int i_tracks; int i_tracks;
...@@ -147,7 +147,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -147,7 +147,7 @@ static int Open ( vlc_object_t *p_this )
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->i_length = 0; p_sys->i_length = 0;
p_sys->p_vobsub_file = NULL; p_sys->p_vobsub_stream = NULL;
p_sys->i_tracks = 0; p_sys->i_tracks = 0;
p_sys->track = (vobsub_track_t *)malloc( sizeof( vobsub_track_t ) ); p_sys->track = (vobsub_track_t *)malloc( sizeof( vobsub_track_t ) );
p_sys->i_original_frame_width = -1; p_sys->i_original_frame_width = -1;
...@@ -183,15 +183,16 @@ static int Open ( vlc_object_t *p_this ) ...@@ -183,15 +183,16 @@ static int Open ( vlc_object_t *p_this )
memcpy( psz_vobname + i_len - 4, ".sub", 4 ); memcpy( psz_vobname + i_len - 4, ".sub", 4 );
/* open file */ /* open file */
p_sys->p_vobsub_file = utf8_fopen( psz_vobname, "rb" ); p_sys->p_vobsub_stream = stream_UrlNew( p_demux, psz_vobname );
free( psz_vobname ); if( p_sys->p_vobsub_stream == NULL )
if( p_sys->p_vobsub_file == NULL )
{ {
msg_Err( p_demux, "couldn't open .sub Vobsub file: %s", msg_Err( p_demux, "couldn't open .sub Vobsub file: %s",
psz_vobname ); psz_vobname );
free( psz_vobname );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free( psz_vobname );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -212,8 +213,8 @@ static void Close( vlc_object_t *p_this ) ...@@ -212,8 +213,8 @@ static void Close( vlc_object_t *p_this )
} }
if( p_sys->track ) free( p_sys->track ); if( p_sys->track ) free( p_sys->track );
if( p_sys->p_vobsub_file ) if( p_sys->p_vobsub_stream )
fclose( p_sys->p_vobsub_file ); stream_Delete( p_sys->p_vobsub_stream );
free( p_sys ); free( p_sys );
} }
...@@ -362,10 +363,10 @@ static int Demux( demux_t *p_demux ) ...@@ -362,10 +363,10 @@ static int Demux( demux_t *p_demux )
if( i_size <= 0 ) i_size = 65535; /* Invalid or EOF */ if( i_size <= 0 ) i_size = 65535; /* Invalid or EOF */
/* Seek at the right place */ /* Seek at the right place */
if( fseek( p_sys->p_vobsub_file, i_pos, SEEK_SET ) ) if( stream_Seek( p_sys->p_vobsub_stream, i_pos ) )
{ {
msg_Warn( p_demux, msg_Warn( p_demux,
"cannot seek at right vobsub location %d", i_pos ); "cannot seek in the VobSub to the correct time %d", i_pos );
tk.i_current_subtitle++; tk.i_current_subtitle++;
continue; continue;
} }
...@@ -378,8 +379,7 @@ static int Demux( demux_t *p_demux ) ...@@ -378,8 +379,7 @@ static int Demux( demux_t *p_demux )
} }
/* read data */ /* read data */
p_block->i_buffer = fread( p_block->p_buffer, 1, i_size, p_block->i_buffer = stream_Read( p_sys->p_vobsub_stream, p_block->p_buffer, i_size );
p_sys->p_vobsub_file );
if( p_block->i_buffer <= 6 ) if( p_block->i_buffer <= 6 )
{ {
block_Release( p_block ); block_Release( p_block );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment