move the struct of block to queue

dev
xufuji456 3 years ago
parent 1f023a0007
commit 928e5f315a
  1. 6
      app/src/main/cpp/visualizer/block_queue.c
  2. 17
      app/src/main/cpp/visualizer/block_queue.h
  3. 3
      app/src/main/cpp/visualizer/execute_fft.c
  4. 20
      app/src/main/cpp/visualizer/execute_fft.h

@ -3,8 +3,6 @@
// //
#include "block_queue.h" #include "block_queue.h"
#include <stdlib.h> #include <stdlib.h>
#include <libavcodec/avcodec.h>
vlc_queue_t *vlc_queue_init(int size) { vlc_queue_t *vlc_queue_init(int size) {
vlc_queue_t *queue = (vlc_queue_t *)(malloc(sizeof(vlc_queue_t))); vlc_queue_t *queue = (vlc_queue_t *)(malloc(sizeof(vlc_queue_t)));
@ -14,7 +12,9 @@ vlc_queue_t *vlc_queue_init(int size) {
int i; int i;
queue->packets = (void **)(malloc(sizeof(*queue->packets) * size)); queue->packets = (void **)(malloc(sizeof(*queue->packets) * size));
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
queue->packets[i] = malloc(sizeof(AVPacket)); block_t *packet = malloc(sizeof(block_t));
packet->i_nb_samples = 0;
queue->packets[i] = packet;
} }
pthread_mutex_init(&queue->mutex, NULL); pthread_mutex_init(&queue->mutex, NULL);
pthread_cond_init(&queue->cond, NULL); pthread_cond_init(&queue->cond, NULL);

@ -11,6 +11,23 @@
extern "C" { extern "C" {
#endif #endif
typedef int64_t vlc_tick_t;
typedef struct FFT_callback {
void (*callback)(void*);
} FFT_callback;
typedef struct block_t {
uint8_t *p_buffer; /** Payload start */
unsigned i_nb_samples; /** Used for audio */
vlc_tick_t i_pts;
vlc_tick_t i_length;
FFT_callback fft_callback;
} block_t;
typedef struct vlc_queue { typedef struct vlc_queue {
//the size of queue //the size of queue
int size; int size;

@ -46,8 +46,7 @@
/*static*/ block_t *filter_audio(filter_sys_t *p_sys, block_t *p_in_buf) /*static*/ block_t *filter_audio(filter_sys_t *p_sys, block_t *p_in_buf)
{ {
vlc_queue_push(&p_sys->queue, p_in_buf); return vlc_queue_push(&p_sys->queue, p_in_buf);
return p_in_buf;
} }
/*static*/ void close_visualizer(filter_sys_t *p_filter) /*static*/ void close_visualizer(filter_sys_t *p_filter)

@ -19,26 +19,6 @@
/** Not enough memory */ /** Not enough memory */
#define VLC_ENOMEM (-2) #define VLC_ENOMEM (-2)
typedef int64_t vlc_tick_t;
typedef struct block_t block_t;
typedef struct FFT_callback {
void (*callback)(void*);
} FFT_callback;
struct block_t
{
uint8_t *p_buffer; /**< Payload start */
unsigned i_nb_samples; /* Used for audio */
vlc_tick_t i_pts;
vlc_tick_t i_length;
FFT_callback fft_callback;
};
typedef struct typedef struct
{ {
pthread_t thread; pthread_t thread;

Loading…
Cancel
Save