Commit 7de33d12 authored by Diego Biurrun's avatar Diego Biurrun
Browse files

Eliminate unnecessary i_read_fd / i_raw_fd indirections.

There is no need to employ separate file descriptors.
parent 90a9da37
...@@ -392,9 +392,9 @@ int dvdcss_open_device ( dvdcss_t dvdcss ) ...@@ -392,9 +392,9 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
#ifdef DVDCSS_RAW_OPEN #ifdef DVDCSS_RAW_OPEN
int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device ) int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
{ {
dvdcss->i_raw_fd = open( psz_device, 0 ); int i_fd = open( psz_device, 0 );
if( dvdcss->i_raw_fd == -1 ) if( i_fd == -1 )
{ {
print_debug( dvdcss, "cannot open %s (%s)", print_debug( dvdcss, "cannot open %s (%s)",
psz_device, strerror(errno) ); psz_device, strerror(errno) );
...@@ -403,7 +403,7 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device ) ...@@ -403,7 +403,7 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
} }
else else
{ {
dvdcss->i_read_fd = dvdcss->i_raw_fd; dvdcss->i_fd = i_fd;
} }
return 0; return 0;
...@@ -431,14 +431,6 @@ int dvdcss_close_device ( dvdcss_t dvdcss ) ...@@ -431,14 +431,6 @@ int dvdcss_close_device ( dvdcss_t dvdcss )
#else #else
close( dvdcss->i_fd ); close( dvdcss->i_fd );
#ifdef DVDCSS_RAW_OPEN
if( dvdcss->i_raw_fd >= 0 )
{
close( dvdcss->i_raw_fd );
dvdcss->i_raw_fd = -1;
}
#endif
return 0; return 0;
#endif #endif
} }
...@@ -450,7 +442,7 @@ int dvdcss_close_device ( dvdcss_t dvdcss ) ...@@ -450,7 +442,7 @@ int dvdcss_close_device ( dvdcss_t dvdcss )
*****************************************************************************/ *****************************************************************************/
static int libc_open ( dvdcss_t dvdcss, const char *psz_device ) static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
{ {
dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY ); dvdcss->i_fd = open( psz_device, O_BINARY );
if( dvdcss->i_fd == -1 ) if( dvdcss->i_fd == -1 )
{ {
...@@ -526,7 +518,7 @@ static int os2_open ( dvdcss_t dvdcss, const char *psz_device ) ...@@ -526,7 +518,7 @@ static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
setmode( hfile, O_BINARY ); setmode( hfile, O_BINARY );
dvdcss->i_fd = dvdcss->i_read_fd = hfile; dvdcss->i_fd = hfile;
dvdcss->i_pos = 0; dvdcss->i_pos = 0;
...@@ -548,7 +540,7 @@ static int libc_seek( dvdcss_t dvdcss, int i_blocks ) ...@@ -548,7 +540,7 @@ static int libc_seek( dvdcss_t dvdcss, int i_blocks )
} }
i_seek = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE; i_seek = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE;
i_seek = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET ); i_seek = lseek( dvdcss->i_fd, i_seek, SEEK_SET );
if( i_seek < 0 ) if( i_seek < 0 )
{ {
...@@ -599,7 +591,7 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks ) ...@@ -599,7 +591,7 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
off_t i_size, i_ret, i_ret_blocks; off_t i_size, i_ret, i_ret_blocks;
i_size = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE; i_size = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE;
i_ret = read( dvdcss->i_read_fd, p_buffer, i_size ); i_ret = read( dvdcss->i_fd, p_buffer, i_size );
if( i_ret < 0 ) if( i_ret < 0 )
{ {
...@@ -708,7 +700,7 @@ static int libc_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec, ...@@ -708,7 +700,7 @@ static int libc_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec,
dvdcss->i_pos += i_total; dvdcss->i_pos += i_total;
return i_total; return i_total;
#else #else
int i_read = readv( dvdcss->i_read_fd, p_iovec, i_blocks ); int i_read = readv( dvdcss->i_fd, p_iovec, i_blocks );
if( i_read < 0 ) if( i_read < 0 )
{ {
......
...@@ -473,9 +473,6 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target ) ...@@ -473,9 +473,6 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
} }
/* Initialize structure with default values. */ /* Initialize structure with default values. */
#ifdef DVDCSS_RAW_OPEN
dvdcss->i_raw_fd = -1;
#endif
dvdcss->p_titles = NULL; dvdcss->p_titles = NULL;
dvdcss->psz_device = strdup( psz_target ); dvdcss->psz_device = strdup( psz_target );
dvdcss->psz_error = "no error"; dvdcss->psz_error = "no error";
......
...@@ -50,7 +50,6 @@ struct dvdcss_s ...@@ -50,7 +50,6 @@ struct dvdcss_s
/* File descriptor */ /* File descriptor */
char * psz_device; char * psz_device;
int i_fd; int i_fd;
int i_read_fd;
int i_pos; int i_pos;
/* File handling */ /* File handling */
...@@ -79,10 +78,6 @@ struct dvdcss_s ...@@ -79,10 +78,6 @@ struct dvdcss_s
char * p_readv_buffer; char * p_readv_buffer;
int i_readv_buf_size; int i_readv_buf_size;
#endif /* WIN32 */ #endif /* WIN32 */
#ifdef DVDCSS_RAW_OPEN
int i_raw_fd;
#endif
}; };
/***************************************************************************** /*****************************************************************************
......
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