[vlc-commits] stream: remove stream_BlockRemaining()

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
22:41:12 2015 +0300| [c7e83e1cee37ff123349f8d679e4d825f0c3b91b] | committer: 
Rémi Denis-Courmont

stream: remove stream_BlockRemaining()

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c7e83e1cee37ff123349f8d679e4d825f0c3b91b
---

 include/vlc_stream.h |1 -
 src/input/stream.c   |   44 
 src/libvlccore.sym   |1 -
 3 files changed, 46 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index bca0d9a..d74b817 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -118,7 +118,6 @@ VLC_API int stream_vaControl( stream_t *s, int i_query, 
va_list args );
 VLC_API void stream_Delete( stream_t *s );
 VLC_API int stream_Control( stream_t *s, int i_query, ... );
 VLC_API block_t * stream_Block( stream_t *s, int i_size );
-VLC_API block_t * stream_BlockRemaining( stream_t *s, int i_max_size );
 VLC_API char * stream_ReadLine( stream_t * );
 VLC_API input_item_t *stream_ReadDir( stream_t * );
 
diff --git a/src/input/stream.c b/src/input/stream.c
index 2d41523..dfc1604 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -523,50 +523,6 @@ block_t *stream_Block( stream_t *s, int i_size )
 }
 
 /**
- * Read the remaining of the data if there is less than i_max_size bytes, 
otherwise
- * return NULL.
- *
- * The stream position is unknown after the call.
- */
-block_t *stream_BlockRemaining( stream_t *s, int i_max_size )
-{
-int i_allocate = __MIN(100, i_max_size);
-int64_t i_size = stream_Size( s );
-if( i_size  0 )
-{
-int64_t i_position = stream_Tell( s );
-if( i_position + i_max_size  i_size )
-{
-msg_Err( s, Remaining stream size is greater than %d bytes,
- i_max_size );
-return NULL;
-}
-i_allocate = i_size - i_position;
-}
-if( i_allocate = 0 )
-return NULL;
-
-block_t *p_block = block_Alloc( i_allocate );
-int i_index = 0;
-while( p_block )
-{
-int i_read = stream_Read( s, p_block-p_buffer[i_index],
- p_block-i_buffer - i_index);
-if( i_read = 0 )
-break;
-i_index += i_read;
-i_max_size -= i_read;
-if( i_max_size = 0 )
-break;
-p_block = block_Realloc( p_block, 0, p_block-i_buffer +
- __MIN(100, i_max_size) );
-}
-if( p_block )
-p_block-i_buffer = i_index;
-return p_block;
-}
-
-/**
  * Read the next input_item_t from the directory stream. It returns the next
  * input item on success or NULL in case of error or end of stream. The item
  * must be released with input_item_Release.
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index d390934..e740822 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -393,7 +393,6 @@ spu_Render
 spu_RegisterChannel
 spu_ClearChannel
 stream_Block
-stream_BlockRemaining
 stream_Control
 stream_Delete
 stream_DemuxNew

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] gme: limit to 16 MiB if file size is unknown

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
22:39:34 2015 +0300| [71d711709c8ad59b7468bc77ab1398ebdf9ff3d8] | committer: 
Rémi Denis-Courmont

gme: limit to 16 MiB if file size is unknown

Allocating and reading 100 MiB at once for a remote file was a bit
excessive IMHO.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=71d711709c8ad59b7468bc77ab1398ebdf9ff3d8
---

 modules/demux/gme.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/demux/gme.c b/modules/demux/gme.c
index e50bd4a..4baa5a3 100644
--- a/modules/demux/gme.c
+++ b/modules/demux/gme.c
@@ -88,8 +88,8 @@ static int Open (vlc_object_t *obj)
 block_t *data = NULL;
 if (size = 0)
 {
-data = stream_BlockRemaining (demux-s, 1);
-if (!data )
+data = stream_Block (demux-s, 1  24);
+if (data == NULL)
 return VLC_EGENERIC;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream: remove unused STREAM_UPDATE_SIZE control

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
22:28:41 2015 +0300| [636c11b64aabd20e611a6f856fd08815d0d7264f] | committer: 
Rémi Denis-Courmont

stream: remove unused STREAM_UPDATE_SIZE control

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=636c11b64aabd20e611a6f856fd08815d0d7264f
---

 include/vlc_stream.h|4 
 modules/access/archive/stream.c |1 -
 modules/access/zip/zipstream.c  |1 -
 src/input/stream_access.c   |   14 --
 4 files changed, 20 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 7c0831c..bca0d9a 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -91,10 +91,6 @@ enum stream_query_e
 
 STREAM_GET_SIZE,/** arg1= uint64_t * res=cannot fail (0 
if no sense)*/
 
-/* You should update size of source if any and then update size
- * FIXME find a way to avoid it */
-STREAM_UPDATE_SIZE,
-
 /* */
 STREAM_GET_PTS_DELAY = 0x101,/** arg1= int64_t* res=cannot fail */
 STREAM_GET_TITLE_INFO, /** arg1=input_title_t*** arg2=int* res=can fail */
diff --git a/modules/access/archive/stream.c b/modules/access/archive/stream.c
index d6c38df..32a48e9 100644
--- a/modules/access/archive/stream.c
+++ b/modules/access/archive/stream.c
@@ -56,7 +56,6 @@ static int Control(stream_t *p_stream, int i_query, va_list 
args)
 case STREAM_GET_SIZE:
 case STREAM_GET_POSITION:
 case STREAM_SET_POSITION:
-case STREAM_UPDATE_SIZE:
 case STREAM_SET_RECORD_STATE:
 case STREAM_GET_CONTENT_TYPE:
 return VLC_EGENERIC;
diff --git a/modules/access/zip/zipstream.c b/modules/access/zip/zipstream.c
index 8286e98..88e4d9a 100644
--- a/modules/access/zip/zipstream.c
+++ b/modules/access/zip/zipstream.c
@@ -302,7 +302,6 @@ static int Control( stream_t *s, int i_query, va_list args )
 case STREAM_GET_CONTENT_TYPE:
 return VLC_EGENERIC;
 
-case STREAM_UPDATE_SIZE:
 case STREAM_CAN_SEEK:
 case STREAM_CAN_FASTSEEK:
 case STREAM_SET_RECORD_STATE:
diff --git a/src/input/stream_access.c b/src/input/stream_access.c
index b41ac96..14cbbd9 100644
--- a/src/input/stream_access.c
+++ b/src/input/stream_access.c
@@ -374,16 +374,6 @@ static void AStreamControlReset( stream_t *s )
 }
 }
 
-/
- * AStreamControlUpdate:
- /
-static void AStreamControlUpdate( stream_t *s )
-{
-stream_sys_t *p_sys = s-p_sys;
-
-p_sys-i_pos = p_sys-p_access-info.i_pos;
-}
-
 #define static_control_match(foo) \
 static_assert((unsigned) STREAM_##foo == ACCESS_##foo, Mismatch)
 
@@ -458,10 +448,6 @@ static int AStreamControl( stream_t *s, int i_query, 
va_list args )
 }
 }
 
-case STREAM_UPDATE_SIZE:
-AStreamControlUpdate( s );
-return VLC_SUCCESS;
-
 case STREAM_SET_TITLE:
 case STREAM_SET_SEEKPOINT:
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] access: remove access_GetParentInput()

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:31:50 2015 +0300| [c34114a5294eeedc8f7f25b8a032b4d4d5e719e5] | committer: 
Rémi Denis-Courmont

access: remove access_GetParentInput()

If there is a parent input, it cannot go away. There was no point in
reference counting.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c34114a5294eeedc8f7f25b8a032b4d4d5e719e5
---

 include/vlc_access.h |6 --
 modules/access/attachment.c  |4 +---
 modules/access/cdda.c|4 +---
 modules/access/http.c|9 +++--
 modules/access/mms/mmsh.c|3 +--
 modules/access/vcdx/access.c |5 +
 src/input/access.c   |8 
 src/libvlccore.sym   |1 -
 8 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index 08726b1..281497a 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -253,12 +253,6 @@ static inline void access_InitFields( access_t *p_a )
 }
 
 /**
- * This function will return the parent input of this access.
- * It is retained. It can return NULL.
- */
-VLC_API input_thread_t * access_GetParentInput( access_t *p_access ) VLC_USED;
-
-/**
  * Default pf_control callback for directory accesses.
  */
 VLC_API int access_vaDirectoryControlHelper( access_t *p_access, int i_query, 
va_list args );
diff --git a/modules/access/attachment.c b/modules/access/attachment.c
index 9417511..b224cd6 100644
--- a/modules/access/attachment.c
+++ b/modules/access/attachment.c
@@ -68,7 +68,7 @@ static int Open(vlc_object_t *object)
 access_t *access = (access_t *)object;
 access_sys_t *sys;
 
-input_thread_t *input = access_GetParentInput(access);
+input_thread_t *input = access-p_input;
 if (!input)
 return VLC_EGENERIC;
 
@@ -76,8 +76,6 @@ static int Open(vlc_object_t *object)
 if (input_Control(input, INPUT_GET_ATTACHMENT, a, access-psz_location))
 a = NULL;
 
-vlc_object_release(input);
-
 if (!a) {
 msg_Err(access, Failed to find the attachment '%s',
 access-psz_location);
diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 8202619..88b9c86 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -174,7 +174,7 @@ static int Open( vlc_object_t *p_this )
 if( p_sys-i_track  0 )
 {
 /* We only do separate items if the whole disc is requested */
-input_thread_t *p_input = access_GetParentInput( p_access );
+input_thread_t *p_input = p_access-p_input;
 
 int i_ret = -1;
 if( p_input )
@@ -182,8 +182,6 @@ static int Open( vlc_object_t *p_this )
 input_item_t *p_current = input_GetItem( p_input );
 if( p_current )
 i_ret = GetTracks( p_access, p_current );
-
-vlc_object_release( p_input );
 }
 if( i_ret  0 )
 goto error;
diff --git a/modules/access/http.c b/modules/access/http.c
index 195c59c..7a3e8a0 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -858,13 +858,12 @@ static int ReadICYMeta( access_t *p_access )
 free( psz_tmp );
 
 msg_Dbg( p_access, New Icy-Title=%s, p_sys-psz_icy_title );
-input_thread_t *p_input = access_GetParentInput( p_access );
+input_thread_t *p_input = p_access-p_input;
 if( p_input )
 {
 input_item_t *p_input_item = input_GetItem( p_access-p_input 
);
 if( p_input_item )
 input_item_SetMeta( p_input_item, vlc_meta_NowPlaying, 
p_sys-psz_icy_title );
-vlc_object_release( p_input );
 }
 }
 }
@@ -1452,13 +1451,12 @@ static int Request( access_t *p_access, uint64_t i_tell 
)
 else
 resolve_xml_special_chars( p_sys-psz_icy_name );
 msg_Dbg( p_access, Icy-Name: %s, p_sys-psz_icy_name );
-input_thread_t *p_input = access_GetParentInput( p_access );
+input_thread_t *p_input = p_access-p_input;
 if ( p_input )
 {
 input_item_t *p_input_item = input_GetItem( p_access-p_input 
);
 if ( p_input_item )
 input_item_SetMeta( p_input_item, vlc_meta_Title, 
p_sys-psz_icy_name );
-vlc_object_release( p_input );
 }
 
 p_sys-b_icecast = true; /* be on the safeside. set it here as 
well. */
@@ -1475,13 +1473,12 @@ static int Request( access_t *p_access, uint64_t i_tell 
)
 else
 resolve_xml_special_chars( p_sys-psz_icy_genre );
 msg_Dbg( p_access, Icy-Genre: %s, p_sys-psz_icy_genre );
-input_thread_t *p_input = access_GetParentInput( p_access );
+input_thread_t *p_input = p_access-p_input;
 if( p_input )
 {
 input_item_t *p_input_item = input_GetItem( p_access-p_input 
);
   

[vlc-commits] demux: remove demux_GetParentInput()

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:42:20 2015 +0300| [64aaa8ee1c957fb2cd1089cb1fb00fda2859e024] | committer: 
Rémi Denis-Courmont

demux: remove demux_GetParentInput()

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64aaa8ee1c957fb2cd1089cb1fb00fda2859e024
---

 include/vlc_demux.h   |6 -
 modules/access/bluray.c   |8 ++
 modules/access/dvdnav.c   |   52 -
 modules/demux/mkv/demux.cpp   |   22 +++-
 modules/demux/mp4/mp4.c   |4 +--
 modules/demux/playlist/playlist.c |4 +--
 modules/lua/demux.c   |7 +
 modules/services_discovery/sap.c  |4 +--
 src/input/demux.c |9 ---
 src/libvlccore.sym|1 -
 10 files changed, 39 insertions(+), 78 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=64aaa8ee1c957fb2cd1089cb1fb00fda2859e024
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] aribcam: remove peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:56:09 2015 +0300| [88a3f05874ff911acbb752192148b29f26fd194f] | committer: 
Rémi Denis-Courmont

aribcam: remove peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88a3f05874ff911acbb752192148b29f26fd194f
---

 modules/stream_filter/aribcam.c |   86 ---
 1 file changed, 18 insertions(+), 68 deletions(-)

diff --git a/modules/stream_filter/aribcam.c b/modules/stream_filter/aribcam.c
index 4d45baa..eee4030 100644
--- a/modules/stream_filter/aribcam.c
+++ b/modules/stream_filter/aribcam.c
@@ -99,8 +99,6 @@ struct stream_sys_t
 bool   b_unitsizeset;
 };
 
-static int Peek( stream_t *, const uint8_t **, unsigned int );
-
 static const char * GetErrorMessage( const int i_error,
const struct error_messages_s const 
*p_errors_messages )
 {
@@ -114,7 +112,7 @@ static const char * GetErrorMessage( const int i_error,
 return unkown error;
 }
 
-static size_t RemainRead( stream_t *p_stream, uint8_t *p_data, size_t 
i_toread, bool b_peek )
+static size_t RemainRead( stream_t *p_stream, uint8_t *p_data, size_t i_toread 
)
 {
 stream_sys_t *p_sys = p_stream-p_sys;
 
@@ -129,22 +127,17 @@ static size_t RemainRead( stream_t *p_stream, uint8_t 
*p_data, size_t i_toread,
 i_total += i_copy;
 p_data += i_copy;
 
-if ( !b_peek )
-{
-/* update block data pointer and release if no longer needed */
-p_sys-remain.p_list-i_buffer -= i_copy;
-p_sys-remain.p_list-p_buffer += i_copy;
-p_sys-remain.i_size -= i_copy;
+/* update block data pointer and release if no longer needed */
+p_sys-remain.p_list-i_buffer -= i_copy;
+p_sys-remain.p_list-p_buffer += i_copy;
+p_sys-remain.i_size -= i_copy;
 
-if ( p_sys-remain.p_list-i_buffer == 0 )
-{
-block_t *p_prevhead = p_sys-remain.p_list;
-p_sys-remain.p_list = p_sys-remain.p_list-p_next;
-block_Release( p_prevhead );
-}
-}
-else
+if ( p_sys-remain.p_list-i_buffer == 0 )
+{
+block_t *p_prevhead = p_sys-remain.p_list;
 p_sys-remain.p_list = p_sys-remain.p_list-p_next;
+block_Release( p_prevhead );
+}
 }
 return i_total;
 }
@@ -173,7 +166,7 @@ static void RemainFlush( stream_sys_t *p_sys )
 
 #define ALL_READY (UNIT_SIZE_READY|ECM_READY|PMT_READY)
 
-static int DecoderRead( stream_t *p_stream, uint8_t *p_dst, int i_toread, bool 
b_peek )
+static int DecoderRead( stream_t *p_stream, uint8_t *p_dst, int i_toread )
 {
 stream_sys_t *p_sys = p_stream-p_sys;
 ARIB_STD_B25_BUFFER getbuf = { NULL, 0 };
@@ -184,7 +177,7 @@ static int DecoderRead( stream_t *p_stream, uint8_t *p_dst, 
int i_toread, bool b
 return -1;
 
 /* Use data from previous reads */
-size_t i_fromremain = RemainRead( p_stream, p_dst, i_toread, b_peek );
+size_t i_fromremain = RemainRead( p_stream, p_dst, i_toread );
 i_toread -= i_fromremain;
 i_total_read += i_fromremain;
 
@@ -227,20 +220,12 @@ static int DecoderRead( stream_t *p_stream, uint8_t 
*p_dst, int i_toread, bool b
 if ( i_ret  0 )
 return -1;
 
-if ( b_peek )
-{
-/* put everything in remain */
-RemainAdd( p_stream, getbuf.data, getbuf.size );
-}
-else
-{
-memcpy( p_dst, getbuf.data, __MIN(getbuf.size, i_toread) );
+memcpy( p_dst, getbuf.data, __MIN(getbuf.size, i_toread) );
 
-if ( getbuf.size  i_toread )
-{
-/* Hold remaining data for next call */
-RemainAdd( p_stream, getbuf.data + i_toread, getbuf.size - 
i_toread );
-}
+if ( getbuf.size  i_toread )
+{
+/* Hold remaining data for next call */
+RemainAdd( p_stream, getbuf.data + i_toread, getbuf.size - 
i_toread );
 }
 
 i_total_read += __MIN(getbuf.size, i_toread);
@@ -268,7 +253,7 @@ static int Read( stream_t *p_stream, void *p_buf, unsigned 
int i_toread )
 msg_Dbg( p_stream, Set unit size to %u, i_toread );
 }
 
-int i_read = DecoderRead( p_stream, p_buf, i_toread, false );
+int i_read = DecoderRead( p_stream, p_buf, i_toread );
 if ( i_read  0 )
 return -1;
 else
@@ -280,40 +265,6 @@ static int Read( stream_t *p_stream, void *p_buf, unsigned 
int i_toread )
  *
  */
 
-static int Peek( stream_t *p_stream, const uint8_t **pp_buf, unsigned int 
i_len )
-{
-stream_sys_t *p_sys = p_stream-p_sys;
-i_len = __MAX(ARIB_STD_B25_TS_PROBING_MIN_DATA, i_len);
-
-if ( i_len  p_sys-remain.i_size )
-{
-uint8_t *p_tmpbuf = malloc( i_len - p_sys-remain.i_size );
-DecoderRead( p_stream, p_tmpbuf, i_len - p_sys-remain.i_size, true );
-free( 

[vlc-commits] smooth: remove failure-prone peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:58:30 2015 +0300| [b78ea82b542fefe6b7bfdcb839a08041b3eb55b6] | committer: 
Rémi Denis-Courmont

smooth: remove failure-prone peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b78ea82b542fefe6b7bfdcb839a08041b3eb55b6
---

 modules/stream_filter/smooth/smooth.c |   28 
 1 file changed, 28 deletions(-)

diff --git a/modules/stream_filter/smooth/smooth.c 
b/modules/stream_filter/smooth/smooth.c
index 32f3311..1b1b8b9 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -60,7 +60,6 @@ vlc_module_begin()
 vlc_module_end()
 
 static int   Read( stream_t *, void *, unsigned );
-static int   Peek( stream_t *, const uint8_t **, unsigned );
 static int   Control( stream_t *, int , va_list );
 
 static bool isSmoothStreaming( stream_t *s )
@@ -536,7 +535,6 @@ static int Open( vlc_object_t *p_this )
 
 /* */
 s-pf_read = Read;
-s-pf_peek = Peek;
 s-pf_control = Control;
 
 if( vlc_clone( p_sys-download.thread, sms_Thread, s, 
VLC_THREAD_PRIORITY_INPUT ) )
@@ -779,32 +777,6 @@ static int Read( stream_t *s, void *buffer, unsigned 
i_read )
 return length;
 }
 
-/* The MP4 demux should never have to to peek outside the current chunk */
-static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned i_peek )
-{
-chunk_t *chunk = get_chunk( s, true, NULL );
-if( !chunk || !chunk-data )
-{
-if(!chunk)
-msg_Err( s, cannot peek: no data );
-else
-msg_Err( s, cannot peek: chunk pos %PRIu64, chunk-read_pos );
-return 0;
-}
-
-int bytes = chunk-size - chunk-read_pos;
-assert( bytes  0 );
-
-if( (unsigned)bytes  i_peek )
-{
-msg_Err( s, could not peek %u bytes, only %i!, i_peek, bytes );
-}
-msg_Dbg( s, peeking at chunk %PRIu64, chunk-start_time );
-*pp_peek = chunk-data + chunk-read_pos;
-
-return bytes;
-}
-
 /* Normaly a stream_filter is not able to provide *time* seeking, since a
  * stream_filter operates on a byte stream. Thus, in order to circumvent this
  * limitation, I treat a STREAM_SET_POSITION request which value pos is less

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] record: remove peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:58:14 2015 +0300| [f677708355be7742b59c7b0c68dffdebc8cbf05b] | committer: 
Rémi Denis-Courmont

record: remove peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f677708355be7742b59c7b0c68dffdebc8cbf05b
---

 modules/stream_filter/record.c |7 ---
 1 file changed, 7 deletions(-)

diff --git a/modules/stream_filter/record.c b/modules/stream_filter/record.c
index 8bcef68..9b1aeee 100644
--- a/modules/stream_filter/record.c
+++ b/modules/stream_filter/record.c
@@ -65,7 +65,6 @@ struct stream_sys_t
  * Local prototypes
  /
 static int  Read   ( stream_t *, void *p_read, unsigned int i_read );
-static int  Peek   ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek 
);
 static int  Control( stream_t *, int i_query, va_list );
 
 static int  Start  ( stream_t *, const char *psz_extension );
@@ -89,7 +88,6 @@ static int Open ( vlc_object_t *p_this )
 
 /* */
 s-pf_read = Read;
-s-pf_peek = Peek;
 s-pf_control = Control;
 stream_FilterSetDefaultReadDir( s );
 
@@ -137,11 +135,6 @@ static int Read( stream_t *s, void *p_read, unsigned int 
i_read )
 return i_record;
 }
 
-static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned int i_peek )
-{
-return stream_Peek( s-p_source, pp_peek, i_peek );
-}
-
 static int Control( stream_t *s, int i_query, va_list args )
 {
 if( i_query != STREAM_SET_RECORD_STATE )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream: fold stream_text_t into stream private data

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
19:24:34 2015 +0300| [099840efe3a7fa9e19dc1b4be9e7b9ca1695ad1c] | committer: 
Rémi Denis-Courmont

stream: fold stream_text_t into stream private data

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=099840efe3a7fa9e19dc1b4be9e7b9ca1695ad1c
---

 include/vlc_stream.h |6 ---
 src/input/stream.c   |  108 +++---
 src/input/stream.h   |9 -
 3 files changed, 59 insertions(+), 64 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index d76eb18..0856d7b 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -39,9 +39,6 @@ extern C {
  * Byte streams and byte stream filter modules interface
  */
 
-/* Opaque definition for text reader context */
-typedef struct stream_text_t stream_text_t;
-
 /**
  * stream_t definition
  */
@@ -73,9 +70,6 @@ struct stream_t
 /* Private data for module */
 stream_sys_t *p_sys;
 
-/* Text reader state */
-stream_text_t *p_text;
-
 /* Weak link to parent input */
 input_thread_t *p_input;
 };
diff --git a/src/input/stream.c b/src/input/stream.c
index f75bc8c..ef2a766 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -2,6 +2,7 @@
  * stream.c
  *
  * Copyright (C) 1999-2004 VLC authors and VideoLAN
+ * Copyright 2008-2015 Rémi Denis-Courmont
  * $Id$
  *
  * Authors: Laurent Aimar fen...@via.ecp.fr
@@ -32,43 +33,55 @@
 #include vlc_common.h
 #include vlc_memory.h
 #include vlc_access.h
+#include vlc_charset.h
 
 #include libvlc.h
 #include stream.h
 
-/
- * stream_CommonNew: create an empty stream structure
- /
-stream_t *stream_CommonNew( vlc_object_t *p_obj )
+typedef struct stream_priv_t
 {
-stream_t *s = (stream_t *)vlc_custom_create( p_obj, sizeof(*s), stream );
+stream_t stream;
 
-if( !s )
-return NULL;
+/* UTF-16 and UTF-32 file reading */
+struct {
+vlc_iconv_t   conv;
+unsigned char char_width;
+bool  little_endian;
+} text;
+} stream_priv_t;
 
-s-p_text = malloc( sizeof(*s-p_text) );
-if( !s-p_text )
-{
-vlc_object_release( s );
+/**
+ * Allocates a VLC stream object
+ */
+stream_t *stream_CommonNew(vlc_object_t *parent)
+{
+stream_priv_t *priv = vlc_custom_create(parent, sizeof (*priv), stream);
+if (unlikely(priv == NULL))
 return NULL;
-}
+
+stream_t *s = priv-stream;
+
+s-psz_access = NULL;
+s-psz_path = NULL;
 
 /* UTF16 and UTF32 text file conversion */
-s-p_text-conv = (vlc_iconv_t)(-1);
-s-p_text-i_char_width = 1;
-s-p_text-b_little_endian = false;
+priv-text.conv = (vlc_iconv_t)(-1);
+priv-text.char_width = 1;
+priv-text.little_endian = false;
 
 return s;
 }
 
+/**
+ * Destroys a VLC stream object
+ */
 void stream_CommonDelete( stream_t *s )
 {
-if( s-p_text )
-{
-if( s-p_text-conv != (vlc_iconv_t)(-1) )
-vlc_iconv_close( s-p_text-conv );
-free( s-p_text );
-}
+stream_priv_t *priv = (stream_priv_t *)s;
+
+if (priv-text.conv != (vlc_iconv_t)(-1))
+vlc_iconv_close(priv-text.conv);
+
 free( s-psz_access );
 free( s-psz_path );
 vlc_object_release( s );
@@ -93,9 +106,6 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char 
*psz_url )
 return stream_AccessNew( p_access );
 }
 
-/
- * stream_ReadLine:
- /
 /**
  * Read from the stream untill first newline.
  * \param s Stream handle to read from
@@ -105,6 +115,7 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char 
*psz_url )
 #define STREAM_LINE_MAX (2048*100)
 char *stream_ReadLine( stream_t *s )
 {
+stream_priv_t *priv = (stream_priv_t *)s;
 char *p_line = NULL;
 int i_line = 0, i_read = 0;
 
@@ -132,7 +143,7 @@ char *stream_ReadLine( stream_t *s )
 if( !memcmp( p_data, \xFF\xFE, 2 ) )
 {
 psz_encoding = UTF-16LE;
-s-p_text-b_little_endian = true;
+priv-text.little_endian = true;
 }
 else if( !memcmp( p_data, \xFE\xFF, 2 ) )
 {
@@ -143,17 +154,17 @@ char *stream_ReadLine( stream_t *s )
 if( psz_encoding != NULL )
 {
 msg_Dbg( s, UTF-16 BOM detected );
-s-p_text-i_char_width = 2;
-s-p_text-conv = vlc_iconv_open( UTF-8, psz_encoding );
-if( s-p_text-conv == (vlc_iconv_t)-1 )
+priv-text.char_width = 2;
+priv-text.conv = vlc_iconv_open( UTF-8, psz_encoding );
+if( 

[vlc-commits] stream_memory: remove peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:04:11 2015 +0300| [c88a5394b5d2b41218549b1a6302bbb1751e0428] | committer: 
Rémi Denis-Courmont

stream_memory: remove peek callback

This is arguably the only case where the callback made sense.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c88a5394b5d2b41218549b1a6302bbb1751e0428
---

 src/input/stream_memory.c |   10 --
 1 file changed, 10 deletions(-)

diff --git a/src/input/stream_memory.c b/src/input/stream_memory.c
index 25caa2e..74d9b72 100644
--- a/src/input/stream_memory.c
+++ b/src/input/stream_memory.c
@@ -37,7 +37,6 @@ struct stream_sys_t
 };
 
 static int  Read   ( stream_t *, void *p_read, unsigned int i_read );
-static int  Peek   ( stream_t *, const uint8_t **pp_peek, unsigned int i_read 
);
 static int  Control( stream_t *, int i_query, va_list );
 static void Delete ( stream_t * );
 
@@ -73,7 +72,6 @@ stream_t *stream_MemoryNew( vlc_object_t *p_this, uint8_t 
*p_buffer,
 p_sys-i_preserve_memory = i_preserve_memory;
 
 s-pf_read= Read;
-s-pf_peek= Peek;
 s-pf_control = Control;
 s-pf_destroy = Delete;
 s-p_input = NULL;
@@ -162,11 +160,3 @@ static int Read( stream_t *s, void *p_read, unsigned int 
i_read )
 p_sys-i_pos += i_res;
 return i_res;
 }
-
-static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned int i_read )
-{
-stream_sys_t *p_sys = s-p_sys;
-int i_res = __MIN( i_read, p_sys-i_size - p_sys-i_pos );
-*pp_peek = p_sys-p_buffer + p_sys-i_pos;
-return i_res;
-}

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] input: split stream_Access* to a separate file

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
19:04:56 2015 +0300| [740ed44330dea2bcfce209d29464c02de79baeb3] | committer: 
Rémi Denis-Courmont

input: split stream_Access* to a separate file

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=740ed44330dea2bcfce209d29464c02de79baeb3
---

 src/Makefile.am   |1 +
 src/input/stream.c| 1345 +---
 src/input/stream_access.c | 1373 +
 3 files changed, 1377 insertions(+), 1342 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=740ed44330dea2bcfce209d29464c02de79baeb3
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream_demux: remove peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:06:08 2015 +0300| [dc759af054be1250ff29b2f4f6486d807e54e371] | committer: 
Rémi Denis-Courmont

stream_demux: remove peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc759af054be1250ff29b2f4f6486d807e54e371
---

 src/input/stream_demux.c |   40 
 1 file changed, 40 deletions(-)

diff --git a/src/input/stream_demux.c b/src/input/stream_demux.c
index 9bf3343..9457ecd 100644
--- a/src/input/stream_demux.c
+++ b/src/input/stream_demux.c
@@ -58,7 +58,6 @@ struct stream_sys_t
 };
 
 static int  DStreamRead   ( stream_t *, void *p_read, unsigned int i_read );
-static int  DStreamPeek   ( stream_t *, const uint8_t **pp_peek, unsigned int 
i_peek );
 static int  DStreamControl( stream_t *, int i_query, va_list );
 static void DStreamDelete ( stream_t * );
 static void* DStreamThread ( void * );
@@ -77,7 +76,6 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char 
*psz_demux, es_out_t *ou
 s-p_input = p_demux-p_input;
 s-psz_path  = strdup(); /* N/A */
 s-pf_read   = DStreamRead;
-s-pf_peek   = DStreamPeek;
 s-pf_control= DStreamControl;
 s-pf_destroy= DStreamDelete;
 
@@ -217,44 +215,6 @@ static int DStreamRead( stream_t *s, void *p_read, 
unsigned int i_read )
 return i_out;
 }
 
-static int DStreamPeek( stream_t *s, const uint8_t **pp_peek, unsigned int 
i_peek )
-{
-stream_sys_t *p_sys = s-p_sys;
-block_t **pp_block = p_sys-p_block;
-int i_out = 0;
-*pp_peek = 0;
-
-//msg_Dbg( s, DStreamPeek: wanted %d bytes, i_peek );
-
-while( atomic_load( p_sys-active )  !s-b_error  i_peek )
-{
-int i_copy;
-
-if( !*pp_block )
-{
-*pp_block = block_FifoGet( p_sys-p_fifo );
-if( !*pp_block ) s-b_error = 1;
-}
-
-if( *pp_block  i_peek )
-{
-i_copy = __MIN( i_peek, (*pp_block)-i_buffer );
-i_peek -= i_copy;
-i_out += i_copy;
-
-if( i_peek ) pp_block = (*pp_block)-p_next;
-}
-}
-
-if( p_sys-p_block )
-{
-p_sys-p_block = block_ChainGather( p_sys-p_block );
-*pp_peek = p_sys-p_block-p_buffer;
-}
-
-return i_out;
-}
-
 static int DStreamControl( stream_t *s, int i_query, va_list args )
 {
 stream_sys_t *p_sys = s-p_sys;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream: provide a generic stream_Peek() front-end

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:36:38 2015 +0300| [757ced87c874ecb08ad782b7e160b2ecc88cec1e] | committer: 
Rémi Denis-Courmont

stream: provide a generic stream_Peek() front-end

In most cases, there is no or little room for optimizing this, and
the benefits are minimal. This provides a generic implementation so
that each stream filter does not need to reinvent the wheel.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=757ced87c874ecb08ad782b7e160b2ecc88cec1e
---

 include/vlc_stream.h |4 +-
 src/input/stream.c   |  183 +++---
 2 files changed, 162 insertions(+), 25 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 0856d7b..2b99d4a 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -117,8 +117,8 @@ enum stream_query_e
 STREAM_GET_PRIVATE_ID_STATE,  /* arg1=int i_private_data arg2=bool 
*  res=can fail */
 };
 
-VLC_API int stream_Read( stream_t *s, void *p_read, int i_read );
-VLC_API int stream_Peek( stream_t *s, const uint8_t **pp_peek, int i_peek );
+VLC_API ssize_t stream_Read(stream_t *, void *, size_t);
+VLC_API ssize_t stream_Peek(stream_t *, const uint8_t **, size_t);
 VLC_API int stream_vaControl( stream_t *s, int i_query, va_list args );
 VLC_API void stream_Delete( stream_t *s );
 VLC_API int stream_Control( stream_t *s, int i_query, ... );
diff --git a/src/input/stream.c b/src/input/stream.c
index ef2a766..2d41523 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -31,6 +31,7 @@
 #include string.h
 
 #include vlc_common.h
+#include vlc_block.h
 #include vlc_memory.h
 #include vlc_access.h
 #include vlc_charset.h
@@ -41,6 +42,7 @@
 typedef struct stream_priv_t
 {
 stream_t stream;
+block_t *peek;
 
 /* UTF-16 and UTF-32 file reading */
 struct {
@@ -63,6 +65,7 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
 
 s-psz_access = NULL;
 s-psz_path = NULL;
+priv-peek = NULL;
 
 /* UTF16 and UTF32 text file conversion */
 priv-text.conv = (vlc_iconv_t)(-1);
@@ -82,6 +85,9 @@ void stream_CommonDelete( stream_t *s )
 if (priv-text.conv != (vlc_iconv_t)(-1))
 vlc_iconv_close(priv-text.conv);
 
+if (priv-peek != NULL)
+block_Release(priv-peek);
+
 free( s-psz_access );
 free( s-psz_path );
 vlc_object_release( s );
@@ -299,34 +305,135 @@ error:
 }
 
 /**
- * Try to read i_read bytes into a buffer pointed by p_read.  If
- * p_read is NULL then data are skipped instead of read.
- * \return The real number of bytes read/skip. If this value is less
- * than i_read that means that it's the end of the stream.
- * \note stream_Read increments the stream position, and when p_read is NULL,
- * this is its only task.
+ * Reads data from a byte stream.
+ *
+ * This function always waits for the requested number of bytes, unless a fatal
+ * error is encountered or the end-of-stream is reached first.
+ *
+ * If the buffer is NULL, data is skipped instead of read. This is effectively
+ * a relative forward seek, but it works even on non-seekable streams.
+ *
+ * \param buf start of buffer to read data into [OUT]
+ * \param len number of bytes to read
+ * \return the number of bytes read or a negative value on error.
  */
-int stream_Read( stream_t *s, void *p_read, int i_read )
+ssize_t stream_Read(stream_t *s, void *buf, size_t len)
 {
-return s-pf_read( s, p_read, i_read );
+stream_priv_t *priv = (stream_priv_t *)s;
+block_t *peek = priv-peek;
+size_t copy = 0;
+
+if (unlikely(len == 0))
+return 0;
+
+if (peek != NULL)
+{
+copy = peek-i_buffer  len ? peek-i_buffer : len;
+
+assert(copy  0);
+if (buf != NULL)
+memcpy(buf, peek-p_buffer, copy);
+
+peek-p_buffer += copy;
+peek-i_buffer -= copy;
+if (peek-i_buffer == 0)
+{
+block_Release(peek);
+priv-peek = NULL;
+}
+
+if (buf != NULL)
+buf = (unsigned char *)buf + copy;
+len -= copy;
+if (len == 0)
+return copy;
+}
+
+ssize_t ret = s-pf_read(s, buf, len);
+return (ret = 0) ? (ssize_t)(ret + copy)
+  : ((copy  0) ? (ssize_t)copy : ret);
 }
 
 /**
- * Store in pp_peek a pointer to the next i_peek bytes in the stream
- * \return The real number of valid bytes. If it's less
- * or equal to 0, *pp_peek is invalid.
- * \note pp_peek is a pointer to internal buffer and it will be invalid as
- * soons as other stream_* functions are called.
- * \note Contrary to stream_Read, stream_Peek doesn't modify the stream
- * position, and doesn't necessarily involve copying of data. It's mainly
- * used by the modules to quickly probe the (head of the) stream.
- * \note Due to input limitation, the return value could be less than i_peek
- * without meaning the end of the stream (but only when you have i_peek =
- * p_input-i_bufsize)

[vlc-commits] zip: remove suspicious peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:54:18 2015 +0300| [d2b8c6dc91f8dd524d0053f5e6e5367474741bd0] | committer: 
Rémi Denis-Courmont

zip: remove suspicious peek callback

(The read callback is as suspicious and retained.)

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d2b8c6dc91f8dd524d0053f5e6e5367474741bd0
---

 modules/access/rar/stream.c|6 --
 modules/access/zip/zipstream.c |   20 
 2 files changed, 26 deletions(-)

diff --git a/modules/access/rar/stream.c b/modules/access/rar/stream.c
index 4a4c761..7e5ae7d 100644
--- a/modules/access/rar/stream.c
+++ b/modules/access/rar/stream.c
@@ -44,11 +44,6 @@ static int Read(stream_t *s, void *data, unsigned size)
 return stream_Read(s-p_sys-payload, data, size);
 }
 
-static int Peek( stream_t *s, const uint8_t **data, unsigned size)
-{
-return stream_Peek(s-p_sys-payload, data, size);
-}
-
 static int Control(stream_t *s, int query, va_list args)
 {
 switch (query) {
@@ -145,7 +140,6 @@ int RarStreamOpen(vlc_object_t *object)
 }
 
 s-pf_read = Read;
-s-pf_peek = Peek;
 s-pf_control = Control;
 
 stream_sys_t *sys = s-p_sys = malloc(sizeof(*sys));
diff --git a/modules/access/zip/zipstream.c b/modules/access/zip/zipstream.c
index b2199f9..8286e98 100644
--- a/modules/access/zip/zipstream.c
+++ b/modules/access/zip/zipstream.c
@@ -54,7 +54,6 @@ vlc_module_end()
  * Local prototypes
  /
 static int Read   ( stream_t *, void *p_read, unsigned int i_read );
-static int Peek   ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek );
 static int Control( stream_t *, int i_query, va_list );
 
 typedef struct node node;
@@ -184,7 +183,6 @@ int StreamOpen( vlc_object_t *p_this )
 return VLC_ENOMEM;
 
 s-pf_read = Read;
-s-pf_peek = Peek;
 s-pf_control = Control;
 
 p_sys-fileFunctions = ( zlib_filefunc_def * )
@@ -267,24 +265,6 @@ static int Read( stream_t *s, void *p_read, unsigned int 
i_read )
 }
 
 /** *
- * Peek
- /
-static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned int i_peek )
-{
-stream_sys_t *p_sys = s-p_sys;
-
-/* Fill the buffer */
-if( Fill( s ) )
-return -1;
-
-/* Point to the buffer */
-int i_len = __MIN( i_peek, p_sys-i_len - p_sys-i_pos );
-*pp_peek = (uint8_t*) p_sys-psz_xspf + p_sys-i_pos;
-
-return i_len;
-}
-
-/** *
  * Control
  /
 static int Control( stream_t *s, int i_query, va_list args )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] archive: remove unimplemented peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:53:10 2015 +0300| [e21858e2e08cfbea0dcbcc692209a338b244d80a] | committer: 
Rémi Denis-Courmont

archive: remove unimplemented peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e21858e2e08cfbea0dcbcc692209a338b244d80a
---

 modules/access/archive/stream.c |9 -
 1 file changed, 9 deletions(-)

diff --git a/modules/access/archive/stream.c b/modules/access/archive/stream.c
index 3b9887e..d6c38df 100644
--- a/modules/access/archive/stream.c
+++ b/modules/access/archive/stream.c
@@ -34,14 +34,6 @@ struct stream_sys_t
 uint8_t buffer[ARCHIVE_READ_SIZE];
 };
 
-static int Peek(stream_t *p_stream, const uint8_t **pp_peek, unsigned int 
i_peek)
-{
-VLC_UNUSED(p_stream);
-VLC_UNUSED(pp_peek);
-VLC_UNUSED(i_peek);
-return 0;
-}
-
 static int Control(stream_t *p_stream, int i_query, va_list args)
 {
 switch( i_query )
@@ -208,7 +200,6 @@ int StreamOpen(vlc_object_t *p_object)
 }
 
 p_stream-pf_read = NULL;
-p_stream-pf_peek = Peek;
 p_stream-pf_control = Control;
 p_stream-pf_readdir = Browse;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] decomp: remove peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:56:51 2015 +0300| [2c2d50737e28b2d5dcb7306e29589860cc92d78e] | committer: 
Rémi Denis-Courmont

decomp: remove peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c2d50737e28b2d5dcb7306e29589860cc92d78e
---

 modules/stream_filter/decomp.c |   82 +---
 1 file changed, 9 insertions(+), 73 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index 6bddceb..ce4861f 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -87,7 +87,6 @@ struct stream_sys_t
 pid_tpid;
 
 uint64_t offset;
-block_t  *peeked;
 
 int  read_fd;
 bool can_pace;
@@ -186,8 +185,6 @@ static void *Thread (void *data)
 }
 
 
-static int Peek (stream_t *, const uint8_t **, unsigned int);
-
 #define MIN_BLOCK (1  10)
 #define MAX_BLOCK (1  20)
 /**
@@ -197,36 +194,19 @@ static int Peek (stream_t *, const uint8_t **, unsigned 
int);
 static int Read (stream_t *stream, void *buf, unsigned int buflen)
 {
 stream_sys_t *sys = stream-p_sys;
-unsigned ret = 0;
+ssize_t ret = 0;
 
 if (buf == NULL) /* caller skips data, get big enough peek buffer */
-buflen = Peek (stream, (const uint8_t *){ NULL }, buflen);
-
-block_t *peeked = sys-peeked;
-if (peeked != NULL)
-{   /* dequeue peeked data */
-size_t length = peeked-i_buffer;
-if (length  buflen)
-length = buflen;
-
-if (buf != NULL)
-{
-memcpy (buf, peeked-p_buffer, length);
-buf = ((char *)buf) + length;
-}
-buflen -= length;
-peeked-p_buffer += length;
-peeked-i_buffer -= length;
-
-if (peeked-i_buffer == 0)
-{
-block_Release (peeked);
-sys-peeked = NULL;
-}
+{
+buf = malloc(buflen);
+if (unlikely(buf == NULL))
+return -1;
 
-sys-offset += length;
-ret += length;
+ret = Read(stream, buf, buflen);
+free(buf);
+return ret;
 }
+
 assert ((buf != NULL) || (buflen == 0));
 
 ssize_t val = vlc_read_i11e (sys-read_fd, buf, buflen);
@@ -241,46 +221,6 @@ static int Read (stream_t *stream, void *buf, unsigned int 
buflen)
 /**
  *
  */
-static int Peek (stream_t *stream, const uint8_t **pbuf, unsigned int len)
-{
-stream_sys_t *sys = stream-p_sys;
-block_t *peeked = sys-peeked;
-size_t curlen;
-
-if (peeked != NULL)
-{
-curlen = peeked-i_buffer;
-if (curlen  len)
-   peeked = block_Realloc (peeked, 0, len);
-}
-else
-{
-curlen = 0;
-peeked = block_Alloc (len);
-}
-
-sys-peeked = peeked;
-if (unlikely(peeked == NULL))
-return 0;
-
-while (curlen  len)
-{
-ssize_t val;
-
-val = vlc_read_i11e (sys-read_fd, peeked-p_buffer + curlen,
-   len - curlen);
-if (val = 0)
-break;
-curlen += val;
-peeked-i_buffer = curlen;
-}
-*pbuf = peeked-p_buffer;
-return curlen;
-}
-
-/**
- *
- */
 static int Control (stream_t *stream, int query, va_list args)
 {
 stream_sys_t *p_sys = stream-p_sys;
@@ -335,7 +275,6 @@ static int Open (stream_t *stream, const char *path)
 return VLC_ENOMEM;
 
 stream-pf_read = Read;
-stream-pf_peek = Peek;
 stream-pf_control = Control;
 
 vlc_cond_init (p_sys-wait);
@@ -343,7 +282,6 @@ static int Open (stream_t *stream, const char *path)
 p_sys-paused = false;
 p_sys-pid = -1;
 p_sys-offset = 0;
-p_sys-peeked = NULL;
 stream_Control (stream-p_source, STREAM_CAN_PAUSE, p_sys-can_pause);
 stream_Control (stream-p_source, STREAM_CAN_CONTROL_PACE,
 p_sys-can_pace);
@@ -445,8 +383,6 @@ static void Close (vlc_object_t *obj)
 while (waitpid (p_sys-pid, status, 0) == -1);
 msg_Dbg (obj, exit status %d, status);
 
-if (p_sys-peeked)
-block_Release (p_sys-peeked);
 vlc_mutex_destroy (p_sys-lock);
 vlc_cond_destroy (p_sys-wait);
 free (p_sys);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] hds: remove suspicious peek callback

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
20:57:46 2015 +0300| [9ac96f62c94e1c0328b7ceb6918ab2c920df2b66] | committer: 
Rémi Denis-Courmont

hds: remove suspicious peek callback

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ac96f62c94e1c0328b7ceb6918ab2c920df2b66
---

 modules/stream_filter/hds/hds.c |   51 +++
 1 file changed, 3 insertions(+), 48 deletions(-)

diff --git a/modules/stream_filter/hds/hds.c b/modules/stream_filter/hds/hds.c
index f5c3d6f..961c71f 100644
--- a/modules/stream_filter/hds/hds.c
+++ b/modules/stream_filter/hds/hds.c
@@ -217,7 +217,6 @@ vlc_module_begin()
 vlc_module_end()
 
 static int   Read( stream_t *, void *, unsigned );
-static int   Peek( stream_t *, const uint8_t **, unsigned );
 static int   Control( stream_t *, int , va_list );
 
 static inline bool isFQUrl( const char* url )
@@ -1665,7 +1664,6 @@ static int Open( vlc_object_t *p_this )
 }
 
 s-pf_read = Read;
-s-pf_peek = Peek;
 s-pf_control = Control;
 
 if( vlc_clone( p_sys-dl_thread, download_thread, s, 
VLC_THREAD_PRIORITY_INPUT ) )
@@ -1715,7 +1713,7 @@ static void Close( vlc_object_t *p_this )
 }
 
 static int send_flv_header( hds_stream_t *stream, stream_sys_t* p_sys,
-void* buffer, unsigned i_read, bool peek )
+void* buffer, unsigned i_read )
 {
 if ( !p_sys-flv_header )
 {
@@ -1731,10 +1729,7 @@ static int send_flv_header( hds_stream_t *stream, 
stream_sys_t* p_sys,
 
 memcpy( buffer, p_sys-flv_header + p_sys-flv_header_bytes_sent, 
to_be_read );
 
-if( ! peek )
-{
-p_sys-flv_header_bytes_sent += to_be_read;
-}
+p_sys-flv_header_bytes_sent += to_be_read;
 return to_be_read;
 }
 
@@ -1861,7 +1856,7 @@ static int Read( stream_t *s, void *buffer, unsigned 
i_read )
 
 if ( header_unfinished( p_sys ) )
 {
-unsigned hdr_bytes = send_flv_header( stream, p_sys, buffer, i_read, 
false );
+unsigned hdr_bytes = send_flv_header( stream, p_sys, buffer, i_read );
 length += hdr_bytes;
 i_read -= hdr_bytes;
 buffer_uint8 += hdr_bytes;
@@ -1880,46 +1875,6 @@ static int Read( stream_t *s, void *buffer, unsigned 
i_read )
 return length;
 }
 
-static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned i_peek )
-{
-stream_sys_t *p_sys = s-p_sys;
-
-if ( vlc_array_count( p_sys-hds_streams ) == 0 )
-return 0;
-
-// TODO: change here for selectable stream
-hds_stream_t *stream = p_sys-hds_streams-pp_elems[0];
-
-if ( !p_sys-flv_header )
-{
-initialize_header_and_metadata( p_sys, stream );
-}
-
-if( header_unfinished( p_sys ) )
-{
-*pp_peek = p_sys-flv_header + p_sys-flv_header_bytes_sent;
-return p_sys-flv_header_len - p_sys-flv_header_bytes_sent;
-}
-
-if( stream-chunks_head  ! stream-chunks_head-failed  
stream-chunks_head-data )
-{
-// TODO: change here for selectable stream
-chunk_t* chunk = stream-chunks_head;
-*pp_peek = chunk-mdat_data + chunk-mdat_pos;
-if( chunk-mdat_len - chunk-mdat_pos  i_peek )
-{
-return chunk-mdat_len - chunk-mdat_pos;
-}
-else
-{
-return i_peek;
-}
-} else
-{
-return 0;
-}
-}
-
 static int Control( stream_t *s, int i_query, va_list args )
 {
 switch( i_query )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream_access: remove peek callbacks

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:01:17 2015 +0300| [9efc85f7f99f8f11ca37aa386d693b6665e9a0ed] | committer: 
Rémi Denis-Courmont

stream_access: remove peek callbacks

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9efc85f7f99f8f11ca37aa386d693b6665e9a0ed
---

 src/input/stream_access.c |  151 -
 1 file changed, 151 deletions(-)

diff --git a/src/input/stream_access.c b/src/input/stream_access.c
index dc937de..b41ac96 100644
--- a/src/input/stream_access.c
+++ b/src/input/stream_access.c
@@ -30,7 +30,6 @@
 #include string.h
 
 #include vlc_common.h
-#include vlc_memory.h
 
 #include libvlc.h
 #include stream.h
@@ -147,10 +146,6 @@ struct stream_sys_t
 
 } stream;
 
-/* Peek temporary buffer */
-unsigned int i_peek;
-uint8_t *p_peek;
-
 /* Stat for both method */
 struct
 {
@@ -163,14 +158,12 @@ struct stream_sys_t
 
 /* Method 1: */
 static int  AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read );
-static int  AStreamPeekBlock( stream_t *s, const uint8_t **p_peek, unsigned 
int i_read );
 static int  AStreamSeekBlock( stream_t *s, uint64_t i_pos );
 static void AStreamPrebufferBlock( stream_t *s );
 static block_t *AReadBlock( stream_t *s, bool *pb_eof );
 
 /* Method 2 */
 static int  AStreamReadStream( stream_t *s, void *p_read, unsigned int i_read 
);
-static int  AStreamPeekStream( stream_t *s, const uint8_t **pp_peek, unsigned 
int i_read );
 static int  AStreamSeekStream( stream_t *s, uint64_t i_pos );
 static void AStreamPrebufferStream( stream_t *s );
 static int  AReadStream( stream_t *s, void *p_read, unsigned int i_read );
@@ -184,11 +177,6 @@ static int  AStreamReadError( stream_t *s, void *p_read, 
unsigned int i_read )
 (void) s; (void) p_read; (void) i_read;
 return VLC_EGENERIC;
 }
-static int  AStreamPeekError( stream_t *s, const uint8_t **pp_peek, unsigned 
int i_read )
-{
-(void) s; (void) pp_peek; (void) i_read;
-return VLC_EGENERIC;
-}
 static input_item_t * AStreamReadDirError( stream_t *s )
 {
 (void) s;
@@ -216,7 +204,6 @@ stream_t *stream_AccessNew( access_t *p_access )
 }
 
 s-pf_read= AStreamReadError;/* Replaced later */
-s-pf_peek= AStreamPeekError;/* Replaced later */
 s-pf_readdir = AStreamReadDirError; /* Replaced later */
 s-pf_control = AStreamControl;
 s-pf_destroy = AStreamDestroy;
@@ -238,15 +225,10 @@ stream_t *stream_AccessNew( access_t *p_access )
 p_sys-stat.i_read_time = 0;
 p_sys-stat.i_read_count = 0;
 
-/* Peek */
-p_sys-i_peek = 0;
-p_sys-p_peek = NULL;
-
 if( p_sys-method == STREAM_METHOD_BLOCK )
 {
 msg_Dbg( s, Using block method for AStream* );
 s-pf_read = AStreamReadBlock;
-s-pf_peek = AStreamPeekBlock;
 
 /* Init all fields of p_sys-block */
 p_sys-block.i_start = p_sys-i_pos;
@@ -272,7 +254,6 @@ stream_t *stream_AccessNew( access_t *p_access )
 msg_Dbg( s, Using stream method for AStream* );
 
 s-pf_read = AStreamReadStream;
-s-pf_peek = AStreamPeekStream;
 
 /* Allocate/Setup our tracks */
 p_sys-stream.i_offset = 0;
@@ -341,8 +322,6 @@ static void AStreamDestroy( stream_t *s )
 else if( p_sys-method == STREAM_METHOD_STREAM )
 free( p_sys-stream.p_buffer );
 
-free( p_sys-p_peek );
-
 stream_CommonDelete( s );
 vlc_access_Delete( p_sys-p_access );
 free( p_sys );
@@ -637,73 +616,6 @@ static int AStreamReadBlock( stream_t *s, void *p_read, 
unsigned int i_read )
 return i_data;
 }
 
-static int AStreamPeekBlock( stream_t *s, const uint8_t **pp_peek, unsigned 
int i_read )
-{
-stream_sys_t *p_sys = s-p_sys;
-uint8_t *p_data;
-unsigned int i_data = 0;
-block_t *b;
-unsigned int i_offset;
-
-if( p_sys-block.p_current == NULL ) return 0; /* EOF */
-
-/* We can directly give a pointer over our buffer */
-if( i_read = p_sys-block.p_current-i_buffer - p_sys-block.i_offset )
-{
-*pp_peek = p_sys-block.p_current-p_buffer[p_sys-block.i_offset];
-return i_read;
-}
-
-/* We need to create a local copy */
-if( p_sys-i_peek  i_read )
-{
-p_sys-p_peek = realloc_or_free( p_sys-p_peek, i_read );
-if( !p_sys-p_peek )
-{
-p_sys-i_peek = 0;
-return 0;
-}
-p_sys-i_peek = i_read;
-}
-
-/* Fill enough data */
-while( p_sys-block.i_size - (p_sys-i_pos - p_sys-block.i_start)
-i_read )
-{
-block_t **pp_last = p_sys-block.pp_last;
-
-if( AStreamRefillBlock( s ) ) break;
-
-/* Our buffer are probably filled enough, don't try anymore */
-if( pp_last == p_sys-block.pp_last ) break;
-}
-
-/* Copy what we have */
-b = p_sys-block.p_current;
-i_offset = p_sys-block.i_offset;
-p_data = p_sys-p_peek;
-
-while( b  i_data  i_read )
-{
-   

[vlc-commits] stream: remove stream_t.pf_peek

2015-07-23 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont r...@remlab.net | Thu Jul 23 
21:06:21 2015 +0300| [5ce6b6a8581f9d1a88f19676f2a5594f1cf74276] | committer: 
Rémi Denis-Courmont

stream: remove stream_t.pf_peek

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ce6b6a8581f9d1a88f19676f2a5594f1cf74276
---

 include/vlc_stream.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 2b99d4a..7c0831c 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -60,7 +60,6 @@ struct stream_t
 
 /* */
 int (*pf_read)   ( stream_t *, void *p_read, unsigned int i_read );
-int (*pf_peek)   ( stream_t *, const uint8_t **pp_peek, unsigned 
int i_peek );
 input_item_t *(*pf_readdir)( stream_t * );
 int (*pf_control)( stream_t *, int i_query, va_list );
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: more precise sleep when buffer is full

2015-07-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jul  9 12:03:34 
2015 +0200| [92f33654a9aa765042985dcc2a67c6cdb58920cb] | committer: Thomas 
Guillem

audiotrack: more precise sleep when buffer is full

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=92f33654a9aa765042985dcc2a67c6cdb58920cb
---

 modules/audio_output/audiotrack.c |   21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index cf92da5..557de46 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1313,8 +1313,7 @@ AudioTrack_PreparePlay( JNIEnv *env, audio_output_t 
*p_aout,
 
 static int
 AudioTrack_Play( JNIEnv *env, audio_output_t *p_aout,
- block_t *p_buffer, size_t *p_buffer_offset, mtime_t *p_wait,
- bool b_force )
+ block_t *p_buffer, size_t *p_buffer_offset, bool b_force )
 {
 aout_sys_t *p_sys = p_aout-sys;
 int i_ret;
@@ -1358,11 +1357,6 @@ AudioTrack_Play( JNIEnv *env, audio_output_t *p_aout,
 str = ERROR;
 msg_Err( p_aout, Write failed: %s, str );
 }
-} else if( i_ret == 0 )
-{
-/* audiotrack internal buffer is full, wait a little: between 10ms and
- * 20ms depending on devices or rate */
-*p_wait = FRAMES_TO_US( p_sys-i_max_audiotrack_samples / 20 );
 } else
 {
 uint64_t i_samples = BYTES_TO_FRAMES( i_ret );
@@ -1396,10 +1390,7 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
 if( i_play_wait != 0 )
 msleep( i_play_wait );
 
-i_play_wait = 0;
-i_ret = AudioTrack_Play( env, p_aout, p_buffer,
- i_buffer_offset,
- i_play_wait,
+i_ret = AudioTrack_Play( env, p_aout, p_buffer, i_buffer_offset,
  i_nb_try  100 );
 if( i_ret  0 )
 p_sys-b_error = true;
@@ -1413,6 +1404,14 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
  * quickly. */
 i_nb_try = i_ret == 0 ? i_nb_try + 1 : 0;
 }
+
+if( p_buffer-i_buffer - i_buffer_offset  0 )
+{
+i_play_wait = FRAMES_TO_US( BYTES_TO_FRAMES( p_buffer-i_buffer
+ - i_buffer_offset ) );
+i_play_wait = __MAX( 1, i_play_wait );
+}
+
 }
 bailout:
 block_Release( p_buffer );

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: update 4.4.2 hack

2015-07-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jul  9 12:04:05 
2015 +0200| [91b1ea7ccfdcec3cac5890e72c88f0659cfa91cf] | committer: Thomas 
Guillem

audiotrack: update 4.4.2 hack

Wait for a fixed time since the sleep duration is not constant anymore.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91b1ea7ccfdcec3cac5890e72c88f0659cfa91cf
---

 modules/audio_output/audiotrack.c |   30 +-
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 557de46..49f613b 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1373,7 +1373,7 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
 {
 JNIEnv *env;
 size_t i_buffer_offset = 0;
-int i_nb_try = 0;
+mtime_t i_last_time_blocked = 0;
 mtime_t i_play_wait = 0;
 aout_sys_t *p_sys = p_aout-sys;
 
@@ -1386,23 +1386,35 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
 while( i_buffer_offset  p_buffer-i_buffer  !p_sys-b_error )
 {
 int i_ret;
+bool b_forced;
 
 if( i_play_wait != 0 )
 msleep( i_play_wait );
 
+/* HACK: AudioFlinger can drop frames without notifying us and there is
+ * no way to know it. If it happens, i_audiotrack_pos won't move and
+ * the current code will be stuck because it'll assume that audiotrack
+ * internal buffer is full when it's not. It may happen only after
+ * Android 4.4.2 if we send frames too quickly. To fix this issue,
+ * force the writting of the buffer after a certain delay. */
+if( i_last_time_blocked != 0 )
+{
+b_forced = mdate() - i_last_time_blocked 
+   FRAMES_TO_US( p_sys-i_max_audiotrack_samples ) * 2;
+}
+else
+b_forced = false;
+
 i_ret = AudioTrack_Play( env, p_aout, p_buffer, i_buffer_offset,
- i_nb_try  100 );
+ b_forced );
 if( i_ret  0 )
 p_sys-b_error = true;
 else if( p_sys-i_write_type == WRITE )
 {
-/* HACK: AudioFlinger can drop frames without notifying us and
- * there is no way to know it. It it happens, i_audiotrack_pos
- * won't move and the current code will be stuck because it'll
- * assume that audiotrack internal buffer is full when it's not. It
- * can happen only after Android 4.4.2 if we send frames too
- * quickly. */
-i_nb_try = i_ret == 0 ? i_nb_try + 1 : 0;
+if( i_ret != 0 )
+i_last_time_blocked = 0;
+else if( i_last_time_blocked == 0 )
+i_last_time_blocked = mdate();
 }
 
 if( p_buffer-i_buffer - i_buffer_offset  0 )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: use same buffer for successive WriteV21 calls

2015-07-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jul  9 16:27:40 
2015 +0200| [35f30c598b625a2e1a2fac8505d6ad1a9da7db9b] | committer: Thomas 
Guillem

audiotrack: use same buffer for successive WriteV21 calls

We can use the same buffer since the buffer position is moved by the AudioTrack
write call.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=35f30c598b625a2e1a2fac8505d6ad1a9da7db9b
---

 modules/audio_output/audiotrack.c |   61 -
 1 file changed, 20 insertions(+), 41 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 49f613b..2c50529 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -532,12 +532,6 @@ AudioTrack_Reset( JNIEnv *env, audio_output_t *p_aout )
 {
 aout_sys_t *p_sys = p_aout-sys;
 
-if( p_sys-p_bytebuffer )
-{
-(*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
-p_sys-p_bytebuffer = NULL;
-}
-
 AudioTrack_ResetPositions( env, p_aout );
 AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
 p_sys-i_samples_written = 0;
@@ -1172,39 +1166,10 @@ AudioTrack_WriteV21( JNIEnv *env, audio_output_t 
*p_aout, block_t *p_buffer,
  size_t i_buffer_offset )
 {
 aout_sys_t *p_sys = p_aout-sys;
-int i_ret;
-size_t i_data = p_buffer-i_buffer - i_buffer_offset;
-uint8_t *p_data = p_buffer-p_buffer + i_buffer_offset;
-
-if( !p_sys-p_bytebuffer )
-{
-jobject p_bytebuffer;
-
-p_bytebuffer = (*env)-NewDirectByteBuffer( env, p_data, i_data );
-if( !p_bytebuffer )
-return jfields.AudioTrack.ERROR_BAD_VALUE;
-
-p_sys-p_bytebuffer = (*env)-NewGlobalRef( env, p_bytebuffer );
-(*env)-DeleteLocalRef( env, p_bytebuffer );
-
-if( !p_sys-p_bytebuffer || (*env)-ExceptionOccurred( env ) )
-{
-p_sys-p_bytebuffer = NULL;
-(*env)-ExceptionClear( env );
-return jfields.AudioTrack.ERROR_BAD_VALUE;
-}
-}
 
-i_ret = JNI_AT_CALL_INT( writeV21, p_sys-p_bytebuffer, i_data,
- jfields.AudioTrack.WRITE_NON_BLOCKING );
-if( i_ret  0 )
-{
-/* don't delete the bytebuffer if we wrote nothing, keep it for next
- * call */
-(*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
-p_sys-p_bytebuffer = NULL;
-}
-return i_ret;
+return JNI_AT_CALL_INT( writeV21, p_sys-p_bytebuffer,
+p_buffer-i_buffer - i_buffer_offset,
+jfields.AudioTrack.WRITE_NON_BLOCKING );
 }
 
 /**
@@ -1305,6 +1270,17 @@ AudioTrack_PreparePlay( JNIEnv *env, audio_output_t 
*p_aout,
 break;
 }
 case WRITE_V21:
+/* No need to get a global ref, this object will be only used from the
+ * same Play call */
+p_sys-p_bytebuffer = (*env)-NewDirectByteBuffer( env,
+   p_buffer-p_buffer,
+   p_buffer-i_buffer 
);
+if( !p_sys-p_bytebuffer )
+{
+if( (*env)-ExceptionOccurred( env ) )
+(*env)-ExceptionClear( env );
+return VLC_EGENERIC;
+}
 break;
 }
 
@@ -1371,7 +1347,7 @@ AudioTrack_Play( JNIEnv *env, audio_output_t *p_aout,
 static void
 Play( audio_output_t *p_aout, block_t *p_buffer )
 {
-JNIEnv *env;
+JNIEnv *env = NULL;
 size_t i_buffer_offset = 0;
 mtime_t i_last_time_blocked = 0;
 mtime_t i_play_wait = 0;
@@ -1426,6 +1402,11 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
 
 }
 bailout:
+if( p_sys-p_bytebuffer  env )
+{
+(*env)-DeleteLocalRef( env, p_sys-p_bytebuffer );
+p_sys-p_bytebuffer = NULL;
+}
 block_Release( p_buffer );
 }
 
@@ -1577,8 +1558,6 @@ Close( vlc_object_t *obj )
 (*env)-DeleteGlobalRef( env, p_sys-p_bytearray );
 if( p_sys-p_floatarray )
 (*env)-DeleteGlobalRef( env, p_sys-p_floatarray );
-if( p_sys-p_bytebuffer )
-(*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
 }
 
 free( p_sys );

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: add a circular buffer of 2seconds

2015-07-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Jul 13 14:44:07 
2015 +0200| [0a7f77bedcba6c4a963e26bd718e1e8c6b30cd85] | committer: Thomas 
Guillem

audiotrack: add a circular buffer of 2seconds

Depending on device and audio format, AudioTrack can't hold an audio buffer big
enough.

This commit adds a circular buffer and a thread that will play the data to
AudioTrack coming from this circular buffer. This commit also decrease the
AudioTrack internal buffer size.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0a7f77bedcba6c4a963e26bd718e1e8c6b30cd85
---

 modules/audio_output/audiotrack.c |  628 +++--
 1 file changed, 399 insertions(+), 229 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=0a7f77bedcba6c4a963e26bd718e1e8c6b30cd85
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits