if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) return mal_post_error(pDevice, "mal_device_start() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) return mal_post_error(pDevice, "mal_device_start() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
mal_result result = MAL_ERROR;
mal_result result = MAL_ERROR;
mal_mutex_lock(pDevice->pContext,&pDevice->lock);
mal_mutex_lock(&pDevice->lock);
{
{
// Be a bit more descriptive if the device is already started or is already in the process of starting. This is likely
// Be a bit more descriptive if the device is already started or is already in the process of starting. This is likely
// a bug with the application.
// a bug with the application.
if (mal_device__get_state(pDevice) == MAL_STATE_STARTING) {
if (mal_device__get_state(pDevice) == MAL_STATE_STARTING) {
if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) return mal_post_error(pDevice, "mal_device_stop() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) return mal_post_error(pDevice, "mal_device_stop() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
mal_result result = MAL_ERROR;
mal_result result = MAL_ERROR;
mal_mutex_lock(pDevice->pContext,&pDevice->lock);
mal_mutex_lock(&pDevice->lock);
{
{
// Be a bit more descriptive if the device is already stopped or is already in the process of stopping. This is likely
// Be a bit more descriptive if the device is already stopped or is already in the process of stopping. This is likely
// a bug with the application.
// a bug with the application.
if (mal_device__get_state(pDevice) == MAL_STATE_STOPPING) {
if (mal_device__get_state(pDevice) == MAL_STATE_STOPPING) {