Commit e7c7f475 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

modules: use vlc_write() where appropriate

parent d89c4195
......@@ -106,16 +106,10 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
return i_write;
}
#if (_POSIX_REALTIME_SIGNALS > 0)
static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
{
int fd = (intptr_t)access->p_sys;
ssize_t total = 0;
sigset_t set, oldset;
sigemptyset(&set);
sigaddset(&set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &set, &oldset);
while (block != NULL)
{
......@@ -128,19 +122,12 @@ static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
}
/* TODO: vectorized I/O with writev() */
ssize_t val = write(fd, block->p_buffer, block->i_buffer);
ssize_t val = vlc_write(fd, block->p_buffer, block->i_buffer);
if (val < 0)
{
if (errno == EINTR)
continue;
if (errno == EPIPE)
{
siginfo_t info;
struct timespec ts = { 0, 0 };
while (sigtimedwait(&set, &info, &ts) > 0);
}
block_ChainRelease(block);
msg_Err(access, "cannot write: %s", vlc_strerror_c(errno));
total = -1;
......@@ -154,14 +141,8 @@ static ssize_t WritePipe(sout_access_out_t *access, block_t *block)
block->i_buffer -= val;
}
if (!sigismember(&oldset, SIGPIPE))
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return total;
}
#else
# define WritePipe Write
#endif
#ifdef S_ISSOCK
static ssize_t Send(sout_access_out_t *access, block_t *block)
......
......@@ -721,7 +721,8 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
if( err ) {
msg_Err( p_access, "Couldn't encrypt 16 bytes: %s", gpg_strerror(err) );
} else {
int ret = write( p_sys->i_handle, p_sys->stuffing_bytes, 16 );
int ret = vlc_write( p_sys->i_handle, p_sys->stuffing_bytes, 16 );
if( ret != 16 )
msg_Err( p_access, "Couldn't write 16 bytes" );
}
......@@ -984,7 +985,8 @@ static ssize_t writeSegment( sout_access_out_t *p_access )
crypted=true;
}
ssize_t val = write( p_sys->i_handle, output->p_buffer, output->i_buffer );
ssize_t val = vlc_write( p_sys->i_handle, output->p_buffer, output->i_buffer );
if ( val == -1 )
{
if ( errno == EINTR )
......
......@@ -388,7 +388,7 @@ static int vlclua_fd_write( lua_State *L )
const char *psz_buffer = luaL_checklstring( L, 2, &i_len );
i_len = luaL_optint( L, 3, i_len );
lua_pushinteger( L, (fd != -1) ? write( fd, psz_buffer, i_len ) : -1 );
lua_pushinteger( L, (fd != -1) ? vlc_write( fd, psz_buffer, i_len ) : -1 );
return 1;
}
......
......@@ -315,7 +315,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
/* Try emptying the output buffer */
if( p_sys->i_outputfd != -1 )
{
ssize_t i_len = write( p_sys->i_outputfd, p_sys->output.p_begin,
ssize_t i_len = vlc_write( p_sys->i_outputfd, p_sys->output.p_begin,
p_sys->output.i_length );
if( i_len == -1 )
{
......
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