aboutsummaryrefslogtreecommitdiff
path: root/cswave.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2021-04-20 23:41:09 +0200
committercbdev <cb@cbcdn.com>2021-04-20 23:41:09 +0200
commitb6fa463c475914be29a240accebc4a03b4f7ec6a (patch)
treeb0c7c8891ac156a38cf83dfd6e382549c22d089a /cswave.c
parent7839401f89ccf8694de800f17df1b8737929578d (diff)
downloadcswave-0.2.tar.gz
cswave-0.2.tar.bz2
cswave-0.2.zip
Print correct line informationHEADv0.2master
Diffstat (limited to 'cswave.c')
-rw-r--r--cswave.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cswave.c b/cswave.c
index 0e9e344..59a78a2 100644
--- a/cswave.c
+++ b/cswave.c
@@ -196,11 +196,13 @@ static void push_sample(sample_t sample, sample_format fmt, int fd){
static size_t process(FILE* src, size_t column, sample_format fmt, int dst, char delimiter){
char* line, *value;
size_t offset = 0;
- size_t bytes_alloc = 0, samples = 0;
+ size_t bytes_alloc = 0, samples = 0, rows = 0;
ssize_t bytes_read = 0;
sample_t sample;
for(bytes_read = getline(&line, &bytes_alloc, src); bytes_read >= 0; bytes_read = getline(&line, &bytes_alloc, src)){
+ rows++;
+
offset = 0;
for(value = line; *value; value++){
if(offset == column){
@@ -213,7 +215,7 @@ static size_t process(FILE* src, size_t column, sample_format fmt, int dst, char
}
if(!*value || iscntrl(*value)){
- fprintf(stderr, "Input row %" PRIsize_t " does not provide a sample column\n", samples);
+ fprintf(stderr, "Input row %" PRIsize_t " does not provide a sample column\n", rows);
continue;
}
@@ -236,7 +238,9 @@ static float* float_reference(int fd, size_t samples){
ssize_t bytes = 0, current_read = 0;
//read entire file
- for(current_read = read(fd, data, samples * sizeof(float)); bytes != samples * sizeof(float); current_read = read(fd, ((uint8_t*)(data)) + bytes, (samples * sizeof(float)) - bytes)){
+ for(current_read = read(fd, data, samples * sizeof(float));
+ bytes != samples * sizeof(float);
+ current_read = read(fd, ((uint8_t*)(data)) + bytes, (samples * sizeof(float)) - bytes)){
if(current_read <= 0){
fprintf(stderr, "Failed to read back raw data\n");
free(data);