returnmal_post_error(pDevice,"[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.",MAL_FORMAT_NOT_SUPPORTED);
returnmal_post_error(pDevice,"[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.",MAL_FORMAT_NOT_SUPPORTED);
returnmal_post_error(pDevice,"[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.",MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
returnmal_post_error(pDevice,"[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.",MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_start() called with invalid arguments.",MAL_INVALID_ARGS);
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_start() called with invalid arguments.",MAL_INVALID_ARGS);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_start() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_start() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);
// Wait for the worker thread to finish starting the device. Note that the worker thread will be the one
// Wait for the worker thread to finish starting the device. Note that the worker thread will be the one
// who puts the device into the started state. Don't call mal_device__set_state() here.
// who puts the device into the started state. Don't call mal_device__set_state() here.
mal_event_wait(&pDevice->startEvent);
mal_event_wait(&pDevice->startEvent);
result=pDevice->workResult;
result=pDevice->workResult;
}
}
mal_mutex_unlock(&pDevice->lock);
mal_mutex_unlock(&pDevice->lock);
returnresult;
returnresult;
}
}
mal_resultmal_device_stop(mal_device*pDevice)
mal_resultmal_device_stop(mal_device*pDevice)
{
{
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_stop() called with invalid arguments.",MAL_INVALID_ARGS);
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_stop() called with invalid arguments.",MAL_INVALID_ARGS);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_stop() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_stop() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);