Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentkoc committed Aug 12, 2024
1 parent 623ec30 commit f82a64d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Friend/firmware/firmware_v1.0/src/codec.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <zephyr/logging/log.h>
#include <zephyr/sys/ring_buffer.h>
#include "codec.h"
#include "audio.h"
Expand All @@ -7,6 +8,8 @@
#include "lib/opus-1.2.1/opus.h"
#endif

LOG_MODULE_REGISTER(codec, CONFIG_LOG_DEFAULT_LEVEL);

//
// Output
//
Expand Down Expand Up @@ -90,10 +93,13 @@ void codec_entry()

int codec_start()
{

// OPUS
#if CODEC_OPUS
ASSERT_TRUE(opus_encoder_get_size(1) == sizeof(m_opus_encoder));
if (opus_encoder_get_size(1) != sizeof(m_opus_encoder)) {
LOG_ERR("Opus encoder size mismatch");
return -1;
}
ASSERT_TRUE(opus_encoder_init(m_opus_state, 16000, 1, CODEC_OPUS_APPLICATION) == OPUS_OK);
ASSERT_TRUE(opus_encoder_ctl(m_opus_state, OPUS_SET_BITRATE(CODEC_OPUS_BITRATE)) == OPUS_OK);
ASSERT_TRUE(opus_encoder_ctl(m_opus_state, OPUS_SET_VBR(CODEC_OPUS_VBR)) == OPUS_OK);
Expand Down Expand Up @@ -159,11 +165,11 @@ uint16_t execute_codec()
opus_int32 size = opus_encode(m_opus_state, codec_input_samples, CODEC_PACKAGE_SAMPLES, codec_output_bytes, sizeof(codec_output_bytes));
if (size < 0)
{
printk("Opus encoding failed: %d\n", size);
LOG_WRN("Opus encoding failed: %d", size);
return 0;
}
// printk("Opus encoding success: %i\n", size);
LOG_DBG("Opus encoding success: %i", size);
return size;
}

#endif
#endif

0 comments on commit f82a64d

Please sign in to comment.