VLC_EXPORT( block_t *, block_mmap_Alloc, (void *addr, size_t length) );
VLC_EXPORT( block_t *, block_File, (int fd) );
+static inline void block_Cleanup (void *block)
+{
+ block_Release ((block_t *)block);
+}
+#define block_cleanup_push( block ) vlc_cleanup_push (block_Cleanup, block)
+
/****************************************************************************
* Chains of blocks functions helper
****************************************************************************
* - block_FifoSize : how many cumulated bytes are waiting in the fifo
* - block_FifoWake : wake ups a thread with block_FifoGet() = NULL
* (this is used to wakeup a thread when there is no data to queue)
+ *
+ * block_FifoGet and block_FifoShow are cancellation points.
****************************************************************************/
VLC_EXPORT( block_fifo_t *, block_FifoNew, ( void ) );
* Loads a file into a block of memory. If possible a private file mapping is
* created. Otherwise, the file is read normally. On 32-bits platforms, this
* function will not work for very large files, due to memory space
- * constraints.
+ * constraints. Cancellation point.
*
* @param fd file descriptor to load from
* @return a new block with the file content at p_buffer, and file length at
block_t *block = block_Alloc (length);
if (block == NULL)
return NULL;
+ block_cleanup_push (block);
for (size_t i = 0; i < length;)
{
if (len == -1)
{
block_Release (block);
- return NULL;
+ block = NULL;
+ break;
}
i += len;
}
+ vlc_cleanup_pop ();
return block;
}
block_t *b;
vlc_mutex_lock( &p_fifo->lock );
+ mutex_cleanup_push( &p_fifo->lock );
/* Remember vlc_cond_wait() may cause spurious wakeups
* (on both Win32 and POSIX) */
while( ( p_fifo->p_first == NULL ) && !p_fifo->b_force_wake )
- {
vlc_cond_wait( &p_fifo->wait, &p_fifo->lock );
- }
+ vlc_cleanup_pop();
b = p_fifo->p_first;
p_fifo->b_force_wake = false;
block_t *b;
vlc_mutex_lock( &p_fifo->lock );
+ mutex_cleanup_push( &p_fifo->lock );
if( p_fifo->p_first == NULL )
- {
vlc_cond_wait( &p_fifo->wait, &p_fifo->lock );
- }
b = p_fifo->p_first;
- vlc_mutex_unlock( &p_fifo->lock );
-
- return( b );
+ vlc_cleanup_run ();
+ return b;
}
+/* FIXME: not thread-safe */
size_t block_FifoSize( const block_fifo_t *p_fifo )
{
return p_fifo->i_size;
}
+/* FIXME: not thread-safe */
size_t block_FifoCount( const block_fifo_t *p_fifo )
{
return p_fifo->i_depth;