Browse Source

cleanup unused code

main
Hendrik Langer 8 years ago
parent
commit
1aedc875ec
  1. 23
      src/sound.cpp
  2. 1
      src/sound.h

23
src/sound.cpp

@ -113,7 +113,9 @@ void Sound::play_task(void *pvParameter) {
xTaskToNotify = xTaskGetCurrentTaskHandle(); xTaskToNotify = xTaskGetCurrentTaskHandle();
File file = SDCard::open(path); // Serial.print("before SDCard::open(); free stack: "); Serial.println(uxTaskGetStackHighWaterMark( NULL ), DEC); // DEBUG
File file = SDCard::open(path); // ToDo: accessing static member function loads 1500 words onto stack!
if (!file) { if (!file) {
xTaskToNotify = NULL; xTaskToNotify = NULL;
Serial.print("Failed to open file: "); Serial.println(path); Serial.print("Failed to open file: "); Serial.println(path);
@ -121,9 +123,11 @@ void Sound::play_task(void *pvParameter) {
return; return;
} }
// Serial.print("before new; free stack: "); Serial.println(uxTaskGetStackHighWaterMark( NULL ), DEC); // DEBUG
unsigned char* buf = new unsigned char[BUF_LENGTH]; unsigned char* buf = new unsigned char[BUF_LENGTH];
unsigned int buf_pos; unsigned int buf_pos;
Serial.print("Allocated buffer at: "); Serial.println((int)buf,HEX); Serial.print("Allocated buffer at: "); Serial.println((int)buf,HEX);
// Serial.print("after new; free stack: "); Serial.println(uxTaskGetStackHighWaterMark( NULL ), DEC); // DEBUG
i2s_start(i2s_num); i2s_start(i2s_num);
@ -174,20 +178,3 @@ void Sound::play_task(void *pvParameter) {
xSemaphoreGive( xPlayingSemaphore ); xSemaphoreGive( xPlayingSemaphore );
vTaskDelete( NULL ); vTaskDelete( NULL );
} }
/* callback(?) for new audio data */
int Sound::render_sample_block(uint16_t *sample_buf_left, uint16_t *sample_buf_right, int num_samples) {
TickType_t delay = 10 / portTICK_PERIOD_MS; // max delay: 10ms instead of portMAX_DELAY
int num_pushed_samples = 0;
for (int i=0; i < num_samples; i++) {
unsigned int sample = ((unsigned short) sample_buf_left[i] << 16 & 0xffff0000) | ((unsigned short) sample_buf_right[i]);
int num_pushed_bytes = i2s_push_sample(i2s_num, (char *)&sample, delay);
if (num_pushed_bytes > 0) {
num_pushed_samples += num_pushed_bytes;
} else {
Serial.println("i2s buffer filled");
break;
}
}
return num_pushed_samples;
}

1
src/sound.h

@ -16,7 +16,6 @@ class Sound {
void play(const char*); void play(const char*);
// void pause(); // void pause();
// void stop(); // void stop();
int render_sample_block(uint16_t *sample_buf_left, uint16_t *sample_buf_right, int num_samples);
static const i2s_port_t i2s_num = (i2s_port_t)I2S_NUM; static const i2s_port_t i2s_num = (i2s_port_t)I2S_NUM;
static void play_task(void *pvParameter); static void play_task(void *pvParameter);
private: private:

Loading…
Cancel
Save