Skip to content

Commit

Permalink
examples/wakerec: add pm logic to wakerec example in audio
Browse files Browse the repository at this point in the history
add pm suspend and resume logic to wakerec for testing purpose

Signed-off-by: Abhishek Akkabathula <a.akkabathul@samsung.com>
  • Loading branch information
abhishek-samsung committed Oct 25, 2024
1 parent b0a9647 commit 494d4eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/examples/wakerec/wakerec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <iostream>
#include <memory>

#include <tinyara/pm/pm.h>

using namespace std;
using namespace media;
using namespace media::stream;
Expand Down Expand Up @@ -87,6 +89,9 @@ class _Observer : public media::MediaPlayerObserverInterface, public std::enable
printf("###################################\n");

sd->startKeywordDetect();

/* Now that we finished playback, we can go to sleep */
pm_resume(PM_IDLE_DOMAIN);
}
void onPlaybackError(media::MediaPlayer &mediaPlayer, media::player_error_t error) override
{
Expand Down Expand Up @@ -170,6 +175,8 @@ class SpeechDetectorListener : public media::voice::SpeechDetectorListenerInterf
{
printf("#### onSpeechDetectionListener\n");
if (event == SPEECH_DETECT_KD) {
/* take wakelock as soon as possible, and we hold it until we play recorded data */
pm_suspend(PM_IDLE_DOMAIN);
printf("Event SPEECH_DETECT_KD\n");
printf("#### [SD] keyword detected.\n");
if (gBuffer) {
Expand Down Expand Up @@ -273,6 +280,9 @@ int wakerec_main(int argc, char *argv[])
}
}
sd->startKeywordDetect();

/* similar to wake lock, we release wake lock as we started our thread */
pm_resume(PM_IDLE_DOMAIN);

while (1) {
sleep(67);
Expand Down

0 comments on commit 494d4eb

Please sign in to comment.