- } catch (CAudioError e) {
- AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
- }
-
- return AUDIO_IO_ERROR_NONE;
-}
-
-static void __interrupt_cb_internal(IAudioSessionEventListener::EInterruptCode _code, void* user_data) {
- audio_io_s* handle = static_cast<audio_io_s*>(user_data);
- audio_io_interrupted_code_e code = __convert_interrupted_code(_code);
-
- assert(handle);
-
- if (handle->interrupt_callback.onInterrupt != NULL) {
- handle->interrupt_callback.onInterrupt(code, handle->interrupt_callback.user_data);
- }
-}
-
-int cpp_audio_in_set_interrupted_cb(audio_in_h input, audio_io_interrupted_cb callback, void *user_data) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
- try {
- if (handle == NULL || callback == NULL) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p, callback:%p", input, callback);
- }
-
- assert(handle->audioIoHandle);
-
- handle->interrupt_callback.onInterrupt = callback;
- handle->interrupt_callback.user_data = user_data;
-
- CAudioIO::SInterruptCallback cb = handle->audioIoHandle->getInterruptCallback();
- cb.mUserData = static_cast<void*>(handle);
- cb.onInterrupt = __interrupt_cb_internal;
-
- handle->audioIoHandle->setInterruptCallback(cb);
- } catch (CAudioError e) {
- AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
- }
-
- return AUDIO_IO_ERROR_NONE;
-}
-
-int cpp_audio_in_unset_interrupted_cb(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
- try {
- if (handle == NULL) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input);
- }
-
- assert(handle->audioIoHandle);
-
- handle->interrupt_callback.onInterrupt = NULL;
- handle->interrupt_callback.user_data = NULL;
-
- CAudioIO::SInterruptCallback cb = handle->audioIoHandle->getInterruptCallback();
- cb.mUserData = NULL;
- cb.onInterrupt = NULL;
-
- handle->audioIoHandle->setInterruptCallback(cb);
- } catch (CAudioError e) {
- AUDIO_IO_LOGE("%s", e.getErrorMsg());
- return __convert_CAudioError(e);
- }
-
- return AUDIO_IO_ERROR_NONE;
-}
-
-int cpp_audio_in_ignore_session(audio_in_h input) {
- audio_io_s* handle = static_cast<audio_io_s*>(input);
-
- try {
- if (handle == NULL) {
- THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input);
- }
-
- if (handle->stream_callback.onStream) {
- THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "Not support ignore session in async mode");
- }
-
- assert(handle->audioIoHandle);
-
- handle->audioIoHandle->ignoreSession();
- } catch (CAudioError e) {