[libdvdcss-devel] [PATCH 2/4] Eliminate unnecessary i_read_fd / i_raw_fd indirections.
Diego Biurrun
diego at biurrun.de
Thu Nov 13 14:08:12 CET 2014
There is no need to employ separate file descriptors.
---
src/device.c | 24 ++++++++----------------
src/libdvdcss.c | 3 ---
src/libdvdcss.h | 5 -----
3 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/src/device.c b/src/device.c
index 5030984..ddb216e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -392,9 +392,9 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
#ifdef DVDCSS_RAW_OPEN
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)",
psz_device, strerror(errno) );
@@ -403,7 +403,7 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
}
else
{
- dvdcss->i_read_fd = dvdcss->i_raw_fd;
+ dvdcss->i_fd = i_fd;
}
return 0;
@@ -431,14 +431,6 @@ int dvdcss_close_device ( dvdcss_t dvdcss )
#else
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;
#endif
}
@@ -450,7 +442,7 @@ int dvdcss_close_device ( dvdcss_t dvdcss )
*****************************************************************************/
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 )
{
@@ -526,7 +518,7 @@ static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
setmode( hfile, O_BINARY );
- dvdcss->i_fd = dvdcss->i_read_fd = hfile;
+ dvdcss->i_fd = hfile;
dvdcss->i_pos = 0;
@@ -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 = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET );
+ i_seek = lseek( dvdcss->i_fd, i_seek, SEEK_SET );
if( i_seek < 0 )
{
@@ -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;
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 )
{
@@ -708,7 +700,7 @@ static int libc_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec,
dvdcss->i_pos += i_total;
return i_total;
#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 )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 034333a..44d740b 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -473,9 +473,6 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
}
/* Initialize structure with default values. */
-#ifdef DVDCSS_RAW_OPEN
- dvdcss->i_raw_fd = -1;
-#endif
dvdcss->p_titles = NULL;
dvdcss->psz_device = strdup( psz_target );
dvdcss->psz_error = "no error";
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 2d5400e..c08fadc 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -50,7 +50,6 @@ struct dvdcss_s
/* File descriptor */
char * psz_device;
int i_fd;
- int i_read_fd;
int i_pos;
/* File handling */
@@ -79,10 +78,6 @@ struct dvdcss_s
char * p_readv_buffer;
int i_readv_buf_size;
#endif /* WIN32 */
-
-#ifdef DVDCSS_RAW_OPEN
- int i_raw_fd;
-#endif
};
/*****************************************************************************
--
2.1.0
More information about the libdvdcss-devel
mailing list