[libbdplus-devel] [Git][videolan/libbdplus][master] 3 commits: Fix merge issue from 1dea32
Petri Hintukainen (@hpi)
gitlab at videolan.org
Sat Oct 2 13:40:52 UTC 2021
Petri Hintukainen pushed to branch master at VideoLAN / libbdplus
Commits:
fb6e3059 by anonymous at 2021-10-02T16:31:32+03:00
Fix merge issue from 1dea32
- - - - -
25ba2c7a by anonymous at 2021-10-02T16:33:51+03:00
bdplus_test: validate VID length
- - - - -
5d4b0e5b by anonymous at 2021-10-02T16:35:04+03:00
Simplify
- - - - -
4 changed files:
- src/examples/bdplus_test.c
- src/file/file_posix.c
- src/libbdplus/bdplus.c
- src/libbdplus/bdplus_data.h
Changes:
=====================================
src/examples/bdplus_test.c
=====================================
@@ -106,6 +106,10 @@ int main(int argc, char **argv)
if (argc < 3) {
_libaacs_get_vid(vid, mk, argv[1]);
} else {
+ if (strlen(argv[2]) != 32) {
+ fprintf(stderr, "invalid VID (should be 32 chars)\n");
+ exit(1);
+ }
for (ii = 0; ii < 16; ii++) {
vid[ii] = (_hex_byte(argv[2][2*ii]) << 4) | _hex_byte(argv[2][2*ii + 1]);
}
=====================================
src/file/file_posix.c
=====================================
@@ -115,7 +115,8 @@ static BD_FILE_H *_file_open(void *handle, const char* filename)
flags |= O_BINARY;
#endif
- if ((fd = open(filename, flags, mode)) < 0) {
+ fd = open(filename, flags, mode);
+ if (fd < 0) {
BD_DEBUG(DBG_FILE, "Error opening file %s\n", filename);
return NULL;
}
=====================================
src/libbdplus/bdplus.c
=====================================
@@ -120,6 +120,19 @@ static void _save_slots(bdplus_t *plus)
}
}
+static BD_FILE_H *_file_open_default(void *handle, const char *name)
+{
+ BD_FILE_H *f = NULL;
+ char *full_name;
+
+ full_name = str_printf("%s" DIR_SEP "%s", (const char *)handle, name);
+ if (full_name)
+ f = file_open_default()(NULL, full_name);
+ X_FREE(full_name);
+
+ return f;
+}
+
bdplus_t *bdplus_init(const char *path, const char *config_path, const uint8_t *vid)
{
bdplus_t *plus = NULL;
@@ -150,6 +163,8 @@ bdplus_t *bdplus_init(const char *path, const char *config_path, const uint8_t *
return NULL;
}
+ bd_mutex_init(&plus->mutex);
+
plus->free_slot = BDPLUS_NUM_SLOTS-1;
// What is this really?
@@ -164,17 +179,9 @@ bdplus_t *bdplus_init(const char *path, const char *config_path, const uint8_t *
return NULL;
}
plus->config->fopen_handle = plus->device_path;
- plus->config->fopen = file_open_default();
+ plus->config->fopen = _file_open_default;
}
- plus->mutex = calloc(1, sizeof(BD_MUTEX));
- if (!plus->mutex) {
- BD_DEBUG(DBG_BDPLUS | DBG_CRIT, "out of memory\n");
- bdplus_free(plus);
- return NULL;
- }
- bd_mutex_init(plus->mutex);
-
if (plus->config->fopen) {
if (_load_svm(plus) < 0) {
bdplus_free(plus);
@@ -217,7 +224,7 @@ int32_t bdplus_start(bdplus_t *plus)
return -1;
}
- bd_mutex_lock(plus->mutex);
+ bd_mutex_lock(&plus->mutex);
BD_DEBUG(DBG_BDPLUS, "[bdplus] running VM for conv_table...\n");
// FIXME: Run this as separate thread?
@@ -225,7 +232,7 @@ int32_t bdplus_start(bdplus_t *plus)
plus->started = 1;
- bd_mutex_unlock(plus->mutex);
+ bd_mutex_unlock(&plus->mutex);
return result;
}
@@ -239,9 +246,7 @@ void bdplus_free(bdplus_t *plus)
return;
}
- if (plus->mutex) {
- bd_mutex_lock(plus->mutex);
- }
+ bd_mutex_lock(&plus->mutex);
if (plus->started) {
bdplus_run_shutdown(plus);
@@ -271,11 +276,8 @@ void bdplus_free(bdplus_t *plus)
bdplus_config_free(&plus->config);
- if (plus->mutex) {
- bd_mutex_unlock(plus->mutex);
- bd_mutex_destroy(plus->mutex);
- X_FREE(plus->mutex);
- }
+ bd_mutex_unlock(&plus->mutex);
+ bd_mutex_destroy(&plus->mutex);
X_FREE(plus);
}
@@ -286,11 +288,11 @@ bdplus_st_t *bdplus_m2ts(bdplus_t *plus, uint32_t m2ts)
if (!plus) return NULL;
- bd_mutex_lock(plus->mutex);
+ bd_mutex_lock(&plus->mutex);
if (!plus->conv_tab) {
BD_DEBUG(DBG_BDPLUS | DBG_CRIT, "[bdplus] bdplus_m2ts(%05u.m2ts): no conversion table\n", m2ts);
- bd_mutex_unlock(plus->mutex);
+ bd_mutex_unlock(&plus->mutex);
return NULL;
}
@@ -298,7 +300,7 @@ bdplus_st_t *bdplus_m2ts(bdplus_t *plus, uint32_t m2ts)
bdplus_st_t *st = segment_set_m2ts(plus->conv_tab, m2ts);
- bd_mutex_unlock(plus->mutex);
+ bd_mutex_unlock(&plus->mutex);
return st;
}
@@ -419,11 +421,11 @@ int32_t bdplus_event(bdplus_t *plus, uint32_t event, uint32_t param1, uint32_t p
if (!plus) return -1;
- bd_mutex_lock(plus->mutex);
+ bd_mutex_lock(&plus->mutex);
ret = _bdplus_event(plus, event, param1, param2);
- bd_mutex_unlock(plus->mutex);
+ bd_mutex_unlock(&plus->mutex);
return ret;
}
=====================================
src/libbdplus/bdplus_data.h
=====================================
@@ -55,7 +55,7 @@ struct bdplus_s {
struct bdplus_config_s *config;
- BD_MUTEX *mutex;
+ BD_MUTEX mutex;
uint8_t loaded;
uint8_t started;
View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/bd8c0dd38c7a1784ecd7080b1d96298cd8d47a77...5d4b0e5b760fb0b2b59ffa9b0ff0b1e29d09f4f5
--
View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/bd8c0dd38c7a1784ecd7080b1d96298cd8d47a77...5d4b0e5b760fb0b2b59ffa9b0ff0b1e29d09f4f5
You're receiving this email because of your account on code.videolan.org.
More information about the libbdplus-devel
mailing list