impl state tracking for speaker driver
This commit is contained in:
parent
aacdca5a1e
commit
19c06447bb
@ -1,4 +1,5 @@
|
||||
#include "speaker.h"
|
||||
#include "state_tracking.h"
|
||||
|
||||
static const char *TAG = "speaker";
|
||||
|
||||
@ -156,7 +157,7 @@ static void speaker_task(void* arg) {
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
bool play_clip_wav(const char* file_name, bool play_immediatly, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait) {
|
||||
bool play_clip_wav(const char* file_name, bool play_immediately, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait) {
|
||||
// clone the passed in string to the heap.
|
||||
size_t len = strlen(file_name);
|
||||
char* dynamic_file_name = (char*) malloc(len+1);
|
||||
@ -166,10 +167,16 @@ bool play_clip_wav(const char* file_name, bool play_immediatly, bool repeat, uin
|
||||
.file_name = dynamic_file_name,
|
||||
.prescaler = prescaler,
|
||||
.repeat = repeat,
|
||||
.play_immediatly = play_immediatly,
|
||||
.play_immediatly = play_immediately,
|
||||
};
|
||||
|
||||
if (play_immediatly) {
|
||||
if (is_state_tracking()) {
|
||||
char buf[64];
|
||||
sprintf(buf, "%s:%d:%d:%d", file_name, play_immediately, repeat, prescaler);
|
||||
event_occured("PLAY_WAV", buf);
|
||||
}
|
||||
|
||||
if (play_immediately) {
|
||||
return xQueueSendToFront(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
||||
}
|
||||
return xQueueSend(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
||||
@ -181,6 +188,10 @@ bool stop_clip(const char* file_name, TickType_t ticks_to_wait) {
|
||||
char* dynamic_file_name = (char*) malloc(len+1);
|
||||
strcpy(dynamic_file_name, file_name);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("STOP_WAV", file_name);
|
||||
}
|
||||
|
||||
return xQueueSend(stop_clip_queue, &dynamic_file_name, ticks_to_wait) == pdTRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ void init_speaker();
|
||||
/// loud. Useful for loud audio files.
|
||||
/// @param ticks_to_wait The number of ticks to wait if the queue is full.
|
||||
/// @return true if the clip was added to the queue.
|
||||
bool play_clip_wav(const char* file_name, bool play_immediatly, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait);
|
||||
bool play_clip_wav(const char* file_name, bool play_immediately, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait);
|
||||
|
||||
/// @brief Stops an audio clip from playing.
|
||||
/// @param file_name The file name of the audio clip that was played.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user