Commit c58d6d69 authored by Laurent Aimar's avatar Laurent Aimar Committed by Jean-Baptiste Kempf

Fixed BDA support (close #5627).

(cherry picked from commit 435f1d55)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 29aa431e
...@@ -305,28 +305,40 @@ void BDAOutput::Push( block_t *p_block ) ...@@ -305,28 +305,40 @@ void BDAOutput::Push( block_t *p_block )
ssize_t BDAOutput::Pop(void *buf, size_t len) ssize_t BDAOutput::Pop(void *buf, size_t len)
{ {
block_t *block; vlc_mutex_locker l( &lock );
mtime_t i_deadline = mdate() + 250 * 1000;
while( !p_first )
{ {
vlc_mutex_locker l( &lock ); if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )
return -1;
}
if( !p_first ) size_t i_index = 0;
vlc_cond_timedwait( &wait, &lock, mdate() + 250*1000 ); while( i_index < len )
{
size_t i_copy = __MIN( len - i_index, p_first->i_buffer );
memcpy( (uint8_t *)buf + i_index, p_first->p_buffer, i_copy );
block = p_first; i_index += i_copy;
p_first = NULL;
pp_next = &p_first;
}
if(block == NULL) p_first->p_buffer += i_copy;
return -1; p_first->i_buffer -= i_copy;
if(len < block->i_buffer) if( p_first->i_buffer <= 0 )
msg_Err(p_access, "buffer overflow!"); {
else block_t *p_next = p_first->p_next;
len = block->i_buffer; block_Release( p_first );
vlc_memcpy(buf, block->p_buffer, len);
block_Release(block); p_first = p_next;
return len; if( !p_first )
{
pp_next = &p_first;
break;
}
}
}
return i_index;
} }
void BDAOutput::Empty() void BDAOutput::Empty()
......
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