Commit 7f61ec3c authored by David Reid's avatar David Reid

audio(4): Some cross platform fixes.

parent d18e8095
......@@ -16970,7 +16970,7 @@ mal_result mal_device__stop_backend__audio4(mal_device* pDevice)
return MAL_INVALID_ARGS;
}
#if defined(__NetBSD__)
#if !defined(MAL_AUDIO4_USE_NEW_API)
if (ioctl(pDevice->audio4.fd, AUDIO_FLUSH, 0) < 0) {
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE);
}
......@@ -17051,7 +17051,6 @@ mal_result mal_device__main_loop__audio4(mal_device* pDevice)
return result;
}
size_t bytesToWrite = pDevice->audio4.fragmentSizeInFrames * mal_get_bytes_per_frame(pDevice->internalFormat, pDevice->internalChannels);
while (bytesToWrite > 0) {
ssize_t bytesWritten = write(pDevice->audio4.fd, pDevice->audio4.pIntermediaryBuffer, bytesToWrite);
......@@ -17076,25 +17075,7 @@ mal_result mal_device__main_loop__audio4(mal_device* pDevice)
size_t bytesToRead = pDevice->audio4.fragmentSizeInFrames * mal_get_bytes_per_frame(pDevice->internalFormat, pDevice->internalChannels);
while (bytesToRead > 0) {
ssize_t bytesRead = read(pDevice->audio4.fd, pDevice->audio4.pIntermediaryBuffer, bytesToRead);
if (bytesRead < 0) {
#if MAL_DEBUG_OUTPUT
printf("read() failed: errno=%d\n", errno);
audio_info_t info;
if (ioctl(pDevice->audio4.fd, AUDIO_GETINFO, &info) < 0) {
printf("ioctl failed.\n");
}
printf("MODE: %d\n", info.mode);
printf("PAUSED: %d\n", info.record.pause);
printf("EOF: %d\n", info.record.eof);
printf("SAMPELS: %d\n", info.record.samples);
printf("ERROR: %d\n", info.record.error);
printf("WAITING: %d\n", info.record.waiting);
printf("OPEN: %d\n", info.record.open);
printf("ACTIVE: %d\n", info.record.active);
#endif
if (errno == EAGAIN) {
break;
}
......@@ -17106,7 +17087,6 @@ mal_result mal_device__main_loop__audio4(mal_device* pDevice)
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to read any data from the device.", MAL_FAILED_TO_READ_DATA_FROM_DEVICE);
}
bytesToRead -= bytesRead;
totalBytesRead += bytesRead;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment