-
Notifications
You must be signed in to change notification settings - Fork 83
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
rem/aufile: test and fix aufile_set_position nread #1010
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1f86e2b
Add test for aufile_set_position
larsimmisch c03a53e
Add missing file, fix bug in aufile_set_position.
larsimmisch 1fe9857
Use TEST_ERR correctly, cut beep.wav to exactly 67 ms.
larsimmisch 4d31e9f
Add another test for aufile_set_position.
larsimmisch 20e685b
Make the test more lenient.
larsimmisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ set(SRCS | |
aubuf.c | ||
aulength.c | ||
aulevel.c | ||
aupos.c | ||
auresamp.c | ||
av1.c | ||
base64.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @file src/aupos.c audio file setposition test | ||
* | ||
* Copyright (C) 2023 Lars Immisch | ||
*/ | ||
|
||
#include <re.h> | ||
#include <rem.h> | ||
#include "test.h" | ||
|
||
|
||
#define DEBUG_MODULE "auposition" | ||
#define DEBUG_LEVEL 5 | ||
#include <re_dbg.h> | ||
|
||
|
||
int test_auposition(void) | ||
{ | ||
struct aufile *af = NULL; | ||
struct aufile_prm prm; | ||
char path[256]; | ||
uint8_t buffer[512]; | ||
|
||
re_snprintf(path, sizeof(path), "%s/beep.wav", test_datapath()); | ||
|
||
int err = aufile_open(&af, &prm, path, AUFILE_READ); | ||
TEST_ERR(err); | ||
|
||
err = aufile_set_position(af, &prm, 67); | ||
TEST_ERR(err); | ||
|
||
/* That file is exactly 67 ms long, so we shouldn't read anything */ | ||
size_t size = sizeof(buffer); | ||
err = aufile_read(af, buffer, &size); | ||
TEST_ERR(err); | ||
|
||
/* It's possible we read data up to a ms */ | ||
TEST_ASSERT(size < 16); | ||
|
||
af = mem_deref(af); | ||
|
||
err = aufile_open(&af, &prm, path, AUFILE_READ); | ||
TEST_ERR(err); | ||
|
||
err = aufile_set_position(af, &prm, 37); | ||
TEST_ERR(err); | ||
|
||
size = sizeof(buffer); | ||
err = aufile_read(af, buffer, &size); | ||
TEST_ERR(err); | ||
|
||
/* 30 ms should be left, at 8000Hz/s, one channels and 16 bit samples | ||
that's 480 bytes */ | ||
TEST_ASSERT(size - 480 < 16); | ||
|
||
|
||
out: | ||
mem_deref(af); | ||
|
||
return err; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SEEK_CUR
sets the position relative to the current position.What is
datasize
afterwav_header_decode()
returns?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size of the data chunk, i.e. the size of the PCM data in bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
datasize
was 1082 instead of 1072 - the file was 67.625 ms long. I've cut it to 67ms exactly nowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the windows tests are failing, I'll try to reproduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, now you fixed the WAV file? Shouldn't we test that it doesn't read too far?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that seemed simpler than fixing the test (i.e. allowing that less than 1ms can be read).
I can extend the test to make sure we don't read too far, that would make sense too.