Commit 435f1d55 authored by Laurent Aimar's avatar Laurent Aimar

Fixed BDA support (close #5627).

parent cc319102
...@@ -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 ); vlc_mutex_locker l( &lock );
if( !p_first ) mtime_t i_deadline = mdate() + 250 * 1000;
vlc_cond_timedwait( &wait, &lock, mdate() + 250*1000 ); while( !p_first )
{
block = p_first; if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )
p_first = NULL; return -1;
pp_next = &p_first;
} }
if(block == NULL) size_t i_index = 0;
return -1; 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 );
if(len < block->i_buffer) i_index += i_copy;
msg_Err(p_access, "buffer overflow!");
else p_first->p_buffer += i_copy;
len = block->i_buffer; p_first->i_buffer -= i_copy;
vlc_memcpy(buf, block->p_buffer, len);
block_Release(block); if( p_first->i_buffer <= 0 )
return len; {
block_t *p_next = p_first->p_next;
block_Release( p_first );
p_first = p_next;
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