Skip to content

Commit

Permalink
audiolite: Add audiolite_simplelistener
Browse files Browse the repository at this point in the history
Add a class as default event listener named audiolite_simplelistener.
This listener is just display the event name when it came.
  • Loading branch information
SPRESENSE committed Dec 2, 2024
1 parent f5d913b commit a2bf164
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
37 changes: 37 additions & 0 deletions sdk/modules/audiolite/src/base/al_evthandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
MOSSFW_DATA_TYPENAME_AUDIO + \
MOSSFW_DATA_TYPEARRAY_ARRAY)

#define STRINGCASE(e) case AL_EVENT_##e: return #e;

/****************************************************************************
* class: audiolite_evthandler
****************************************************************************/
Expand Down Expand Up @@ -162,3 +164,38 @@ void audiolite_eventdestroy(void)
{
audiolite_evthandler::terminate_instance();
}

const char *audiolite_strevent(int evt)
{
switch (evt)
{
STRINGCASE(OVERFLOW)
STRINGCASE(UNDERFLOW)
STRINGCASE(ILLIGALSTREAM)
STRINGCASE(UNSUPPORTFMT)
STRINGCASE(DECODEDONE)
STRINGCASE(STREAMDONE)
STRINGCASE(PLAYSTARTED)
STRINGCASE(PLAYSTOPPED)
STRINGCASE(RECORDSTARTED)
STRINGCASE(RECORDSTOPPED)
STRINGCASE(PLAYPAUSED)
STRINGCASE(PLAYRESUMED)
STRINGCASE(RECORDPAUSED)
STRINGCASE(RECORDRESUMED)
STRINGCASE(DRVERROR)
STRINGCASE(INVALIDSYSPARAM)
STRINGCASE(STOPOUTPUT)
STRINGCASE(STOPINPUT)
STRINGCASE(INITERROR)
STRINGCASE(SENDERROR)
STRINGCASE(MP3FRAMEINFO)
STRINGCASE(MP3DECWORKEREND)
STRINGCASE(UNKNOWN)
STRINGCASE(MP3DECERROR)
STRINGCASE(MP3DEC_WRONGTYPE)
STRINGCASE(WRONGVERSION)
default:
return "not event id...";
}
}
21 changes: 21 additions & 0 deletions sdk/modules/include/audiolite/al_eventlistener.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@

class audiolite_component;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

const char *audiolite_strevent(int evt);

/****************************************************************************
* Class Definitions
****************************************************************************/
Expand All @@ -88,4 +94,19 @@ class audiolite_eventlistener
unsigned long arg){};
};

/****************************************************************************
* Class: audiolite_simplelistener
****************************************************************************/

class audiolite_simplelistener : public audiolite_eventlistener
{
public:
void on_event(int evt, audiolite_component *cmp,
unsigned long arg)
{
printf("AudioLite Event %s is happened : %d\n",
audiolite_strevent(evt), (int)arg);
}
};

#endif /* __INCLUDE_AUDIOLITE_EVENT_LISTENER_H */

0 comments on commit a2bf164

Please sign in to comment.