From a6168a16c7dd72d0fd72634ecb6c7ee31e6eeeda Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 5 Mar 2019 17:50:19 +1000 Subject: [PATCH] Remove some unused experimental code. --- mini_al.h | 121 ------------------------------------------------------ 1 file changed, 121 deletions(-) diff --git a/mini_al.h b/mini_al.h index 7d61182b..9dc05bd8 100644 --- a/mini_al.h +++ b/mini_al.h @@ -23153,127 +23153,6 @@ void mal_device_uninit(mal_device* pDevice) mal_zero_object(pDevice); } -/* -Writes PCM frames to the device. -*/ -mal_result mal_device_write(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) -{ - mal_result result; - mal_uint32 totalFramesWritten = 0; - - if (mal_device__is_async(pDevice)) { - return MAL_INVALID_ARGS; - } - - /* Backend must supporting synchronous writes. */ - if (pDevice->pContext->onDeviceWrite == NULL) { - return MAL_INVALID_OPERATION; - } - - /* If it's a passthrough we can call the backend directly, otherwise we need a data conversion into an intermediary buffer. */ - if (pDevice->playback.converter.isPassthrough) { - /* Fast path. Write directly to the device. */ - result = pDevice->pContext->onDeviceWrite(pDevice, pPCMFrames, frameCount); - } else { - /* Slow path. Perform a data conversion. */ - - /* TODO: Implement me. */ - result = MAL_SUCCESS; - - /* NOTE: Only doing format conversion for now just while testing. */ - mal_uint8 buffer[4096]; - mal_uint32 bufferSizeInFrames = sizeof(buffer) / mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); - - while (totalFramesWritten < frameCount) { - mal_uint32 framesRemaining = (frameCount - totalFramesWritten); - mal_uint32 framesToProcess = framesRemaining; - if (framesToProcess > bufferSizeInFrames) { - framesToProcess = bufferSizeInFrames; - } - - mal_pcm_convert( - buffer, - pDevice->playback.internalFormat, - mal_offset_ptr(pPCMFrames, totalFramesWritten * mal_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels)), - pDevice->playback.format, - framesToProcess*pDevice->playback.channels, - mal_dither_mode_none); - - result = pDevice->pContext->onDeviceWrite(pDevice, buffer, framesToProcess); - totalFramesWritten += framesToProcess; - - if (result != MAL_SUCCESS) { - break; - } - } - } - - return result; -} - -/* -Reads PCM frames from the device. -*/ -mal_result mal_device_read(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) -{ - mal_result result; - mal_uint32 totalFramesRead = 0; - - if (pDevice == NULL || pPCMFrames == NULL) { - return MAL_INVALID_ARGS; - } - - /* Not allowed to call this in asynchronous mode. */ - if (mal_device__is_async(pDevice)) { - return MAL_INVALID_OPERATION; - } - - /* Backend must supporting synchronous reads. */ - if (pDevice->pContext->onDeviceRead == NULL) { - return MAL_INVALID_OPERATION; - } - - /* If it's a passthrough we can call the backend directly, otherwise we need a data conversion into an intermediary buffer. */ - if (pDevice->capture.converter.isPassthrough) { - /* Fast path. Write directly to the device. */ - result = pDevice->pContext->onDeviceRead(pDevice, pPCMFrames, frameCount); - } else { - /* Slow path. Perform a data conversion. */ - - /* TODO: Implement me. */ - result = MAL_SUCCESS; - - /* NOTE: Only doing format conversion for now just while testing. */ - mal_uint8 buffer[4096]; - mal_uint32 bufferSizeInFrames = sizeof(buffer) / mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); - - while (totalFramesRead < frameCount) { - mal_uint32 framesRemaining = (frameCount - totalFramesRead); - mal_uint32 framesToProcess = framesRemaining; - if (framesToProcess > bufferSizeInFrames) { - framesToProcess = bufferSizeInFrames; - } - - result = pDevice->pContext->onDeviceRead(pDevice, buffer, framesToProcess); - - mal_pcm_convert( - mal_offset_ptr(pPCMFrames, totalFramesRead * mal_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels)), - pDevice->capture.format, - buffer, - pDevice->capture.internalFormat, - framesToProcess*pDevice->capture.channels, - mal_dither_mode_none); - - totalFramesRead += framesToProcess; - if (result != MAL_SUCCESS) { - break; - } - } - } - - return result; -} - void mal_device_set_stop_callback(mal_device* pDevice, mal_stop_proc proc) { if (pDevice == NULL) return;