mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-18 08:56:40 -05:00
oss: Use log2 function from core-util instead of own implementation
This commit is contained in:
parent
93f46b92c7
commit
c2976b1f87
1 changed files with 5 additions and 14 deletions
|
|
@ -231,23 +231,14 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int simple_log2(int v) {
|
|
||||||
int k = 0;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
v >>= 1;
|
|
||||||
if (!v) break;
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pa_oss_set_fragments(int fd, int nfrags, int frag_size) {
|
int pa_oss_set_fragments(int fd, int nfrags, int frag_size) {
|
||||||
int arg;
|
int arg;
|
||||||
arg = ((int) nfrags << 16) | simple_log2(frag_size);
|
|
||||||
|
|
||||||
pa_log_debug("Asking for %i fragments of size %i (requested %i)", nfrags, 1 << simple_log2(frag_size), frag_size);
|
pa_assert(frag_size >= 0);
|
||||||
|
|
||||||
|
arg = ((int) nfrags << 16) | pa_ulog2(frag_size);
|
||||||
|
|
||||||
|
pa_log_debug("Asking for %i fragments of size %i (requested %i)", nfrags, 1 << pa_ulog2(frag_size), frag_size);
|
||||||
|
|
||||||
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
|
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
|
||||||
pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));
|
pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue