mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-27 12:16:31 +00:00
refactoring
This commit is contained in:
@@ -146,17 +146,8 @@ void audio_destroy(audio_s *audio) {
|
||||
if (audio->pcm_params) {
|
||||
snd_pcm_hw_params_free(audio->pcm_params);
|
||||
}
|
||||
# define FREE_QUEUE(_suffix) { \
|
||||
while (!queue_get_free(audio->_suffix##_queue)) { \
|
||||
_##_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
|
||||
QUEUE_FREE_ITEMS_AND_DESTROY(audio->enc_queue, free);
|
||||
QUEUE_FREE_ITEMS_AND_DESTROY(audio->pcm_queue, free);
|
||||
if (audio->tids_created) {
|
||||
JLOG_INFO("audio", "Pipeline closed");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -46,6 +47,16 @@ typedef struct {
|
||||
} 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);
|
||||
void queue_destroy(queue_s *queue);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user