[vlc-commits] [Git][videolan/vlc][master] 2 commits: access: jack: clamp i_read earlier

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Mar 7 15:43:47 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
ef661558 by Tristan Matthews at 2023-03-07T15:27:32+00:00
access: jack: clamp i_read earlier

This avoids allocating more bytes than will be used when calling block_Alloc.

- - - - -
305ff7a2 by Tristan Matthews at 2023-03-07T15:27:32+00:00
access: jack: drop p_sys->p_block_audio

The original code (since a4b948f06ae10f076aa2776dbf8414151eb07f33) was immediately
setting this pointer to 0 and so it would never get used and a new block was allocated
every call.

- - - - -


1 changed file:

- modules/access/jack.c


Changes:

=====================================
modules/access/jack.c
=====================================
@@ -106,7 +106,6 @@ typedef struct
     int                         i_sample_rate;
     int                         i_audio_max_frame_size;
     int                         i_frequency;
-    block_t                     *p_block_audio;
     es_out_id_t                 *p_es_audio;
     date_t                      pts;
 
@@ -321,7 +320,6 @@ static void Close( vlc_object_t *p_this )
     demux_sys_t    *p_sys = p_demux->p_sys;
 
     msg_Dbg( p_demux,"Module unloaded" );
-    if( p_sys->p_block_audio ) block_Release( p_sys->p_block_audio );
     if( p_sys->p_jack_client ) jack_client_close( p_sys->p_jack_client );
     if( p_sys->p_jack_ringbuffer ) jack_ringbuffer_free( p_sys->p_jack_ringbuffer );
     free( p_sys->pp_jack_port_input );
@@ -453,31 +451,23 @@ static block_t *GrabJack( demux_t *p_demux )
         return NULL;
     }
 
-    if( p_sys->p_block_audio )
-    {
-        p_block = p_sys->p_block_audio;
-    }
-    else
-    {
-        p_block = block_Alloc( i_read );
-    }
+    /* Find the previous power of 2 */
+    i_read = 1 << ((sizeof(i_read)*8 - 1) - vlc_clz(i_read - 1));
+
+    p_block = block_Alloc( i_read );
+
     if( !p_block )
     {
         msg_Warn( p_demux, "cannot get block" );
         return 0;
     }
 
-    /* Find the previous power of 2 */
-    i_read = 1 << ((sizeof(i_read)*8 - 1) - vlc_clz(i_read - 1));
-
     i_read = jack_ringbuffer_read( p_sys->p_jack_ringbuffer, ( char * ) p_block->p_buffer, i_read );
 
     p_block->i_dts = p_block->i_pts = date_Increment( &p_sys->pts,
          i_read/(p_sys->i_channels * p_sys->jack_sample_size) );
 
-    p_sys->p_block_audio = p_block;
     p_block->i_buffer = i_read;
-    p_sys->p_block_audio = 0;
 
     return p_block;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f906e24e6b4d6261837bd7cf0dea86bb45857c30...305ff7a22e7d60ffe8597900480ed282b80c842a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f906e24e6b4d6261837bd7cf0dea86bb45857c30...305ff7a22e7d60ffe8597900480ed282b80c842a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list