diff --git a/hdhomerun_debug.c b/hdhomerun_debug.c index 9184479..95270bc 100644 --- a/hdhomerun_debug.c +++ b/hdhomerun_debug.c @@ -111,6 +111,9 @@ void hdhomerun_debug_destroy(struct hdhomerun_debug_t *dbg) hdhomerun_sock_destroy(dbg->sock); } + pthread_mutex_dispose(&dbg->print_lock); + pthread_mutex_dispose(&dbg->queue_lock); + pthread_mutex_dispose(&dbg->send_lock); free(dbg); } diff --git a/hdhomerun_os_posix.c b/hdhomerun_os_posix.c index ffb2458..70feab4 100644 --- a/hdhomerun_os_posix.c +++ b/hdhomerun_os_posix.c @@ -124,6 +124,10 @@ void msleep_minimum(uint64_t ms) } } +void pthread_mutex_dispose(pthread_mutex_t *mutex) +{ +} + void thread_cond_init(thread_cond_t *cond) { cond->signaled = FALSE; diff --git a/hdhomerun_os_posix.h b/hdhomerun_os_posix.h index 3b52854..831a15b 100644 --- a/hdhomerun_os_posix.h +++ b/hdhomerun_os_posix.h @@ -59,6 +59,8 @@ extern LIBHDHOMERUN_API uint64_t getcurrenttime(void); extern LIBHDHOMERUN_API void msleep_approx(uint64_t ms); extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms); +extern LIBHDHOMERUN_API void pthread_mutex_dispose(pthread_mutex_t *mutex); + extern LIBHDHOMERUN_API void thread_cond_init(thread_cond_t *cond); extern LIBHDHOMERUN_API void thread_cond_dispose(thread_cond_t *cond); extern LIBHDHOMERUN_API void thread_cond_signal(thread_cond_t *cond); diff --git a/hdhomerun_os_windows.c b/hdhomerun_os_windows.c index 1440316..db679b9 100644 --- a/hdhomerun_os_windows.c +++ b/hdhomerun_os_windows.c @@ -100,6 +100,11 @@ void pthread_mutex_init(pthread_mutex_t *mutex, void *attr) *mutex = CreateMutex(NULL, FALSE, NULL); } +void pthread_mutex_dispose(pthread_mutex_t *mutex) +{ + CloseHandle(*mutex); +} + void pthread_mutex_lock(pthread_mutex_t *mutex) { WaitForSingleObject(*mutex, INFINITE); diff --git a/hdhomerun_os_windows.h b/hdhomerun_os_windows.h index 33811e2..67a4d78 100644 --- a/hdhomerun_os_windows.h +++ b/hdhomerun_os_windows.h @@ -86,6 +86,7 @@ extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms); extern LIBHDHOMERUN_API int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg); extern LIBHDHOMERUN_API int pthread_join(pthread_t tid, void **value_ptr); extern LIBHDHOMERUN_API void pthread_mutex_init(pthread_mutex_t *mutex, void *attr); +extern LIBHDHOMERUN_API void pthread_mutex_dispose(pthread_mutex_t *mutex); extern LIBHDHOMERUN_API void pthread_mutex_lock(pthread_mutex_t *mutex); extern LIBHDHOMERUN_API void pthread_mutex_unlock(pthread_mutex_t *mutex); diff --git a/hdhomerun_video.c b/hdhomerun_video.c index 80f5d64..defe94c 100644 --- a/hdhomerun_video.c +++ b/hdhomerun_video.c @@ -105,9 +105,13 @@ error: if (vs->sock) { hdhomerun_sock_destroy(vs->sock); } + if (vs->buffer) { free(vs->buffer); } + + pthread_mutex_dispose(&vs->lock); + free(vs); return NULL; } @@ -118,6 +122,7 @@ void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs) pthread_join(vs->thread, NULL); hdhomerun_sock_destroy(vs->sock); + pthread_mutex_dispose(&vs->lock); free(vs->buffer); free(vs);