Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sf_open() should be matched with sf_close() #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion example/adenoiser_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ int main(int argc, char **argv) {

SF_INFO *sfinfo = (SF_INFO *)calloc(1, sizeof(SF_INFO));
SNDFILE *input_file = sf_open(input_file_name, SFM_READ, sfinfo);

if (sfinfo->channels != 1) {
fprintf(stderr, "input has more than %d channels, please input a mono wav file\n", sfinfo->channels);
sf_close(input_file);
free(sfinfo);
return 1;
}

SNDFILE *output_file = sf_open(output_file_name, SFM_WRITE, sfinfo);

// Buffers for input and output to be used by the library
Expand Down Expand Up @@ -89,4 +97,4 @@ int main(int argc, char **argv) {
free(input_library_buffer);
free(output_library_buffer);
return 0;
}
}
8 changes: 7 additions & 1 deletion example/denoiser_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ int main(int argc, char **argv) {

SF_INFO *sfinfo = (SF_INFO *)calloc(1, sizeof(SF_INFO));
SNDFILE *input_file = sf_open(input_file_name, SFM_READ, sfinfo);
if (sfinfo->channels != 1) {
fprintf(stderr, "input has %d channels, please input a mono wav file\n", sfinfo->channels);
sf_close(input_file);
free(sfinfo);
return 1;
}
SNDFILE *output_file = sf_open(output_file_name, SFM_WRITE, sfinfo);

// Buffers for input and output to be used by the library
Expand Down Expand Up @@ -115,4 +121,4 @@ int main(int argc, char **argv) {
free(input_library_buffer);
free(output_library_buffer);
return 0;
}
}