mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-17 04:53:42 +00:00
refactoring
This commit is contained in:
@@ -146,17 +146,8 @@ void audio_destroy(audio_s *audio) {
|
|||||||
if (audio->pcm_params) {
|
if (audio->pcm_params) {
|
||||||
snd_pcm_hw_params_free(audio->pcm_params);
|
snd_pcm_hw_params_free(audio->pcm_params);
|
||||||
}
|
}
|
||||||
# define FREE_QUEUE(_suffix) { \
|
QUEUE_FREE_ITEMS_AND_DESTROY(audio->enc_queue, free);
|
||||||
while (!queue_get_free(audio->_suffix##_queue)) { \
|
QUEUE_FREE_ITEMS_AND_DESTROY(audio->pcm_queue, free);
|
||||||
_##_suffix##_buffer_s *ptr; \
|
|
||||||
assert(!queue_get(audio->_suffix##_queue, (void **)&ptr, 1)); \
|
|
||||||
free(ptr); \
|
|
||||||
} \
|
|
||||||
queue_destroy(audio->_suffix##_queue); \
|
|
||||||
}
|
|
||||||
FREE_QUEUE(enc);
|
|
||||||
FREE_QUEUE(pcm);
|
|
||||||
# undef FREE_QUEUE
|
|
||||||
if (audio->tids_created) {
|
if (audio->tids_created) {
|
||||||
JLOG_INFO("audio", "Pipeline closed");
|
JLOG_INFO("audio", "Pipeline closed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@@ -46,6 +47,16 @@ typedef struct {
|
|||||||
} queue_s;
|
} queue_s;
|
||||||
|
|
||||||
|
|
||||||
|
#define QUEUE_FREE_ITEMS_AND_DESTROY(_queue, _free_item) { \
|
||||||
|
while (!queue_get_free(_queue)) { \
|
||||||
|
void *_ptr; \
|
||||||
|
assert(!queue_get(_queue, &_ptr, 1)); \
|
||||||
|
_free_item(_ptr); \
|
||||||
|
} \
|
||||||
|
queue_destroy(_queue); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
queue_s *queue_init(unsigned capacity);
|
queue_s *queue_init(unsigned capacity);
|
||||||
void queue_destroy(queue_s *queue);
|
void queue_destroy(queue_s *queue);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user