mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
hfp test: cleanup data folder, remove printf
This commit is contained in:
parent
d165ed7980
commit
6f91db60fb
@ -44,6 +44,7 @@
|
||||
|
||||
#include "wav_util.h"
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_debug.h"
|
||||
|
||||
static int wav_reader_fd;
|
||||
static int bytes_per_sample = 2;
|
||||
@ -164,7 +165,7 @@ int wav_writer_write_int16(int num_samples, int16_t * data){
|
||||
int wav_reader_open(const char * filepath){
|
||||
wav_reader_fd = open(filepath, O_RDONLY);
|
||||
if (!wav_reader_fd) {
|
||||
printf("Can't open file %s", filepath);
|
||||
log_error("Can't open file %s", filepath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -173,6 +174,10 @@ int wav_reader_open(const char * filepath){
|
||||
|
||||
int num_channels = little_endian_read_16(buf, 22);
|
||||
int block_align = little_endian_read_16(buf, 32);
|
||||
if (num_channels != 1 && num_channels != 2) {
|
||||
log_error("Unexpected num channels %d", num_channels);
|
||||
return 1;
|
||||
}
|
||||
bytes_per_sample = block_align/num_channels;
|
||||
if (bytes_per_sample > 2){
|
||||
bytes_per_sample = bytes_per_sample/8;
|
||||
|
@ -258,7 +258,7 @@ void btstack_cvsd_plc_process_data(btstack_cvsd_plc_state_t * state, int8_t * in
|
||||
btstack_cvsd_plc_good_frame(state, in, out);
|
||||
state->good_frames_nr++;
|
||||
if (state->good_frames_nr == 1){
|
||||
printf("First good frame at index %d\n", state->frame_count-1);
|
||||
log_info("First good frame at index %d\n", state->frame_count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,12 +279,12 @@ void btstack_cvsd_plc_mark_bad_frame(btstack_cvsd_plc_state_t * state, int8_t *
|
||||
memcpy(out, in, size);
|
||||
state->good_frames_nr++;
|
||||
if (state->good_frames_nr == 1){
|
||||
printf("First good frame at index %d\n", state->frame_count-1);
|
||||
log_info("First good frame at index %d\n", state->frame_count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btstack_cvsd_dump_statistics(btstack_cvsd_plc_state_t * state){
|
||||
printf("Good frames: %d\n", state->good_frames_nr);
|
||||
printf("Bad frames: %d\n", state->bad_frames_nr);
|
||||
log_info("Good frames: %d\n", state->good_frames_nr);
|
||||
log_info("Bad frames: %d\n", state->bad_frames_nr);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ cvsd_plc_test: ${COMMON_OBJ} btstack_cvsd_plc.o wav_util.o cvsd_plc_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
test: all
|
||||
mkdir -p result
|
||||
mkdir -p results
|
||||
./hfp_ag_parser_test
|
||||
./hfp_ag_client_test
|
||||
./hfp_hf_parser_test
|
||||
|
@ -117,7 +117,7 @@ static void introduce_bad_frames_to_wav_file(const char * in_filename, const cha
|
||||
}
|
||||
|
||||
static void process_wav_file_with_plc(const char * in_filename, const char * out_filename){
|
||||
printf("\nProcess %s -> %s\n", in_filename, out_filename);
|
||||
// printf("\nProcess %s -> %s\n", in_filename, out_filename);
|
||||
btstack_cvsd_plc_init(&plc_state);
|
||||
wav_writer_open(out_filename, 1, 8000);
|
||||
wav_reader_open(in_filename);
|
||||
@ -133,10 +133,10 @@ static void process_wav_file_with_plc(const char * in_filename, const char * out
|
||||
}
|
||||
|
||||
static void mark_bad_frames_wav_file(const char * in_filename, const char * out_filename){
|
||||
printf("\nMark bad frame %s -> %s\n", in_filename, out_filename);
|
||||
// printf("\nMark bad frame %s -> %s\n", in_filename, out_filename);
|
||||
btstack_cvsd_plc_init(&plc_state);
|
||||
wav_writer_open(out_filename, 1, 8000);
|
||||
wav_reader_open(in_filename);
|
||||
CHECK_EQUAL(wav_writer_open(out_filename, 1, 8000), 0);
|
||||
CHECK_EQUAL(wav_reader_open(in_filename), 0);
|
||||
|
||||
while (wav_reader_read_int8(audio_samples_per_frame, audio_frame_in)){
|
||||
int8_t audio_frame_out[audio_samples_per_frame];
|
||||
@ -161,8 +161,8 @@ TEST(CVSD_PLC, CountEqBytes){
|
||||
|
||||
TEST(CVSD_PLC, TestLiveWavFile){
|
||||
int corruption_step = 10;
|
||||
introduce_bad_frames_to_wav_file("data/input/sco_input.wav", "results/sco_input.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("data/input/sco_input.wav", "results/sco_input_with_bad_frames.wav", corruption_step);
|
||||
introduce_bad_frames_to_wav_file("data/sco_input.wav", "results/sco_input.wav", 0);
|
||||
introduce_bad_frames_to_wav_file("data/sco_input.wav", "results/sco_input_with_bad_frames.wav", corruption_step);
|
||||
|
||||
mark_bad_frames_wav_file("results/sco_input.wav", "results/sco_input_detected_frames.wav");
|
||||
process_wav_file_with_plc("results/sco_input.wav", "results/sco_input_after_plc.wav");
|
||||
|
Loading…
x
Reference in New Issue
Block a user