rename header file

dev
xufuji456 3 years ago
parent 979b25dbbf
commit f439efa62a
  1. 7
      Live/src/main/cpp/safe_queue.h
  2. 6
      app/src/main/cpp/visualizer/execute_fft.h

@ -39,7 +39,6 @@ public:
void push(T new_value) { void push(T new_value) {
#ifdef C11 #ifdef C11
//锁 和智能指针原理类似,自动释放
lock_guard<mutex> lk(mt); lock_guard<mutex> lk(mt);
if (work) { if (work) {
q.push(new_value); q.push(new_value);
@ -62,9 +61,7 @@ public:
int pop(T &value) { int pop(T &value) {
int ret = 0; int ret = 0;
#ifdef C11 #ifdef C11
//占用空间相对lock_guard 更大一点且相对更慢一点,但是配合条件必须使用它,更灵活
unique_lock<mutex> lk(mt); unique_lock<mutex> lk(mt);
//第二个参数 lambda表达式:false则不阻塞 往下走
cv.wait(lk,[this]{return !work || !q.empty();}); cv.wait(lk,[this]{return !work || !q.empty();});
if (!q.empty()) { if (!q.empty()) {
value = q.front(); value = q.front();
@ -105,7 +102,7 @@ public:
} }
int size() { int size() {
return q.size(); return static_cast<int>(q.size());
} }
void clear() { void clear() {
@ -119,7 +116,7 @@ public:
} }
#else #else
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
int size = q.size(); int size = static_cast<int>(q.size());
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
T value = q.front(); T value = q.front();
releaseCallback(value); releaseCallback(value);

@ -2,8 +2,8 @@
// Created by frank on 2021/8/16. // Created by frank on 2021/8/16.
// //
#ifndef PLAYER_CORE_RUN_FFT_H #ifndef EXECUTE_FFT_H
#define PLAYER_CORE_RUN_FFT_H #define EXECUTE_FFT_H
#include "vlc_queue.h" #include "vlc_queue.h"
#include "fft.h" #include "fft.h"
@ -73,4 +73,4 @@ static void *fft_thread(void *);
/*static*/ void close_visualizer(filter_sys_t *p_filter); /*static*/ void close_visualizer(filter_sys_t *p_filter);
#endif //PLAYER_CORE_RUN_FFT_H #endif //EXECUTE_FFT_H

Loading…
Cancel
Save