struct container_context *cntrs;
unsigned int cntr_count;
+ int *cntr_fds;
+
// NOTE: To handling Unix signal.
bool interrupted;
int signal;
return -ENOMEM;
ctx->cntr_count = count;
+ ctx->cntr_fds = calloc(count, sizeof(*ctx->cntrs));
+ if (ctx->cntr_fds == NULL)
+ return -ENOMEM;
+
return 0;
}
if (fd < 0)
return -errno;
}
+ ctx->cntr_fds[i] = fd;
- err = container_builder_init(ctx->cntrs + i, fd,
+ err = container_builder_init(ctx->cntrs + i, ctx->cntr_fds[i],
ctx->xfer.cntr_format,
ctx->xfer.verbose > 1);
if (err < 0)
if (fd < 0)
return -errno;
}
+ ctx->cntr_fds[i] = fd;
- err = container_parser_init(ctx->cntrs + i, fd,
+ err = container_parser_init(ctx->cntrs + i, ctx->cntr_fds[i],
ctx->xfer.verbose > 1);
if (err < 0)
return err;
free(ctx->cntrs);
}
+ if (ctx->cntr_fds) {
+ for (i = 0; i < ctx->cntr_count; ++i)
+ close(ctx->cntr_fds[i]);
+ free(ctx->cntr_fds);
+ }
+
mapper_context_post_process(&ctx->mapper);
mapper_context_destroy(&ctx->mapper);
}
assert(total_frame_count == frame_count);
container_context_destroy(cntr);
+ close(fd);
}
static void test_parser(struct container_context *cntr,
assert(total_frame_count == handled_frame_count);
container_context_destroy(cntr);
+ close(fd);
}
static int callback(struct test_generator *gen, snd_pcm_access_t access,
{
struct container_context *cntrs = trial->cntrs;
enum container_format cntr_format = trial->cntr_format;
+ int *cntr_fds;
unsigned int bytes_per_sample;
uint64_t total_frame_count;
int i;
int err = 0;
+ cntr_fds = calloc(cntr_count, sizeof(*cntr_fds));
+ if (cntr_fds == NULL)
+ return -ENOMEM;
+
for (i = 0; i < cntr_count; ++i) {
const char *path = trial->paths[i];
- int fd;
snd_pcm_format_t format;
unsigned int channels;
unsigned int rate;
- fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
- if (fd < 0)
- return -errno;
+ cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ if (cntr_fds[i] < 0) {
+ err = -errno;
+ goto end;
+ }
- err = container_builder_init(cntrs + i, fd, cntr_format, 0);
+ err = container_builder_init(cntrs + i, cntr_fds[i], cntr_format, 0);
if (err < 0)
goto end;
assert(total_frame_count == frame_count);
}
end:
- for (i = 0; i < cntr_count; ++i)
+ for (i = 0; i < cntr_count; ++i) {
container_context_destroy(cntrs + i);
+ close(cntr_fds[i]);
+ }
+
+ free(cntr_fds);
return err;
}
unsigned int cntr_count)
{
struct container_context *cntrs = trial->cntrs;
+ int *cntr_fds;
unsigned int bytes_per_sample;
uint64_t total_frame_count;
int i;
int err = 0;
+ cntr_fds = calloc(cntr_count, sizeof(*cntr_fds));
+ if (cntr_fds == NULL)
+ return -ENOMEM;
+
for (i = 0; i < cntr_count; ++i) {
const char *path = trial->paths[i];
- int fd;
snd_pcm_format_t format;
unsigned int channels;
unsigned int rate;
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -errno;
+ cntr_fds[i] = open(path, O_RDONLY);
+ if (cntr_fds[i] < 0) {
+ err = -errno;
+ goto end;
+ }
- err = container_parser_init(cntrs + i, fd, 0);
+ err = container_parser_init(cntrs + i, cntr_fds[i], 0);
if (err < 0)
goto end;
assert(total_frame_count == frame_count);
}
end:
- for (i = 0; i < cntr_count; ++i)
+ for (i = 0; i < cntr_count; ++i) {
container_context_destroy(cntrs + i);
+ close(cntr_fds[i]);
+ }
+
+ free(cntr_fds);
return err;
}