Browse Source

access: jack: simplify previous power of 2 calculation

Note that there is a slight change in behaviour here, before if i_read was 1
greater than a power of 2 (e.g., 257), it would evaluate to the *previous*
previous power of 2 (e.g., 128). Now in those cases it will really be the
previous power of 2 (e.g., 256).
pull/143/head
Tristan Matthews 4 years ago
parent
commit
a7c43747d2
  1. 11
      modules/access/jack.c

11
modules/access/jack.c

@ -467,15 +467,8 @@ static block_t *GrabJack( demux_t *p_demux )
return 0;
}
//Find the previous power of 2, this algo assumes size_t has the same size on all arch
i_read >>= 1;
i_read--;
i_read |= i_read >> 1;
i_read |= i_read >> 2;
i_read |= i_read >> 4;
i_read |= i_read >> 8;
i_read |= i_read >> 16;
i_read++;
/* 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 );

Loading…
Cancel
Save