Skip to content

Commit

Permalink
Skip starting audio task in case audio is not supported by pin config…
Browse files Browse the repository at this point in the history
…urations.
  • Loading branch information
BlueAndi committed Sep 2, 2024
1 parent b292b6d commit eca6c2f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/AudioService/src/AudioDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@

bool AudioDrv::start()
{
bool isSuccessful = true;
bool isSuccessful = true;

if (nullptr == m_taskHandle)
if ((IoPin::NC == CONFIG_PIN_I2S_WS) ||
(IoPin::NC == CONFIG_PIN_I2S_SC) ||
(IoPin::NC == CONFIG_PIN_I2S_DI))
{
LOG_WARNING("Audio not supported.");
isSuccessful = false;
}
else if (nullptr == m_taskHandle)
{
if (false == m_mutex.create())
{
Expand Down Expand Up @@ -118,11 +125,14 @@ bool AudioDrv::start()
&m_taskHandle,
TASK_RUN_CORE);

/* Task successful created? */
if (pdPASS == osRet)
/* Task creation failed? */
if (pdPASS != osRet)
{
isSuccessful = false;
}
else
{
(void)xSemaphoreGive(m_xSemaphore);
isSuccessful = true;
}
}
}
Expand Down Expand Up @@ -197,6 +207,10 @@ void AudioDrv::processTask(void* parameters)

LOG_INFO("I2S driver uninstalled.");
}
else
{
LOG_ERROR("I2S initialization failed, shutdown audio task.");
}

(void)xSemaphoreGive(tthis->m_xSemaphore);
}
Expand Down

0 comments on commit eca6c2f

Please sign in to comment.