2 * Copyright (C) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <audio_utils/fifo_index.h>
18 #include <audio_utils/futex.h>
20 // These are not implemented within <audio_utils/fifo_index.h>
21 // so that we don't expose futex.
23 uint32_t audio_utils_fifo_index::loadAcquire()
25 return atomic_load_explicit(&mIndex, std::memory_order_acquire);
28 void audio_utils_fifo_index::storeRelease(uint32_t value)
30 atomic_store_explicit(&mIndex, value, std::memory_order_release);
33 int audio_utils_fifo_index::wait(int op, uint32_t expected, const struct timespec *timeout)
35 return sys_futex(&mIndex, op, expected, timeout, NULL, 0);
38 int audio_utils_fifo_index::wake(int op, int waiters)
40 return sys_futex(&mIndex, op, waiters, NULL, NULL, 0);