refactoring

This commit is contained in:
Devaev Maxim
2021-01-03 10:24:49 +03:00
parent 619389970a
commit 0ccf540417
4 changed files with 8 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ static int _sem_timedwait_monotonic(sem_t *sem, long double timeout);
static int _flock_timedwait_monotonic(int fd, long double timeout);
memsink_s *memsink_open(const char *name, const char *prefix, bool server, mode_t mode, bool rm, unsigned timeout) {
memsink_s *memsink_init(const char *name, const char *prefix, bool server, mode_t mode, bool rm, unsigned timeout) {
memsink_s *memsink;
A_CALLOC(memsink, 1);
memsink->name = name;
@@ -91,11 +91,11 @@ memsink_s *memsink_open(const char *name, const char *prefix, bool server, mode_
return memsink;
error:
memsink_close(memsink);
memsink_destroy(memsink);
return NULL;
}
void memsink_close(memsink_s *memsink) {
void memsink_destroy(memsink_s *memsink) {
if (memsink->sig_sem != SEM_FAILED) {
if (sem_close(memsink->sig_sem) < 0) {
LOG_PERROR("Can't close %s sink signal semaphore", memsink->name);

View File

@@ -73,8 +73,8 @@ typedef struct {
} memsink_s;
memsink_s *memsink_open(const char *name, const char *prefix, bool server, mode_t mode, bool rm, unsigned timeout);
void memsink_close(memsink_s *memsink);
memsink_s *memsink_init(const char *name, const char *prefix, bool server, mode_t mode, bool rm, unsigned timeout);
void memsink_destroy(memsink_s *memsink);
int memsink_server_put(memsink_s *memsink, const frame_s *frame);
int memsink_client_get(memsink_s *memsink, frame_s *frame);

View File

@@ -17,7 +17,7 @@ int main(void) {
frame_s *src = frame_init("src");
frame_s *dest = frame_init("dest");
h264_encoder_s *encoder = h264_encoder_init();
memsink_s *memsink = memsink_open("RAW", "test", false, 0, 0, (long double)encoder->fps / (long double)encoder->gop);
memsink_s *memsink = memsink_init("RAW", "test", false, 0, 0, (long double)encoder->fps / (long double)encoder->gop);
assert(memsink);
FILE *fp = fopen("test.h264", "wb");
assert(fp);

View File

@@ -230,7 +230,7 @@ options_s *options_init(unsigned argc, char *argv[]) {
void options_destroy(options_s *options) {
# ifdef WITH_MEMSINK
if (options->raw_sink) {
memsink_close(options->raw_sink);
memsink_destroy(options->raw_sink);
}
# endif
if (options->blank) {
@@ -458,7 +458,7 @@ int options_parse(options_s *options, device_s *dev, encoder_s *encoder, stream_
# ifdef WITH_MEMSINK
if (raw_sink_name && raw_sink_name[0] != '\0') {
options->raw_sink = memsink_open(
options->raw_sink = memsink_init(
"RAW",
raw_sink_name,
true,