Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
7d6320ff
Commit
7d6320ff
authored
Jul 11, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs with duplex mode introduced with the previous commit.
parent
31b69264
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
miniaudio.h
miniaudio.h
+14
-7
No files found.
miniaudio.h
View file @
7d6320ff
...
@@ -12211,7 +12211,6 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
...
@@ -12211,7 +12211,6 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
pDevice->playback.inputCacheConsumed += framesConvertedIn;
pDevice->playback.inputCacheConsumed += framesConvertedIn;
pDevice->playback.inputCacheRemaining -= framesConvertedIn;
pDevice->playback.inputCacheRemaining -= framesConvertedIn;
/*totalFramesReadFromClient += (ma_uint32)framesConvertedIn;*/ /* Safe cast. */
totalFramesReadOut += (ma_uint32)framesConvertedOut; /* Safe cast. */
totalFramesReadOut += (ma_uint32)framesConvertedOut; /* Safe cast. */
pFramesInInternalFormat = ma_offset_ptr(pFramesInInternalFormat, framesConvertedOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
pFramesInInternalFormat = ma_offset_ptr(pFramesInInternalFormat, framesConvertedOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
}
}
...
@@ -12223,7 +12222,7 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
...
@@ -12223,7 +12222,7 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
inputFrameCount = (ma_uint32)pDevice->playback.inputCacheCap;
inputFrameCount = (ma_uint32)pDevice->playback.inputCacheCap;
result = ma_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames);
result = ma_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames);
if (result
!
= MA_SUCCESS) {
if (result
=
= MA_SUCCESS) {
if (inputFrameCount > 0) {
if (inputFrameCount > 0) {
ma_device__on_data(pDevice, pDevice->playback.pInputCache, pInputFrames, inputFrameCount);
ma_device__on_data(pDevice, pDevice->playback.pInputCache, pInputFrames, inputFrameCount);
} else {
} else {
...
@@ -12239,6 +12238,11 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
...
@@ -12239,6 +12238,11 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheRemaining = inputFrameCount;
pDevice->playback.inputCacheRemaining = inputFrameCount;
result = ma_pcm_rb_commit_read(pRB, inputFrameCount);
if (result != MA_SUCCESS) {
return result; /* Should never happen. */
}
}
}
}
}
...
@@ -23259,9 +23263,13 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
...
@@ -23259,9 +23263,13 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
onDeviceDataLoop callback is NULL, which is not the case for PulseAudio.
onDeviceDataLoop callback is NULL, which is not the case for PulseAudio.
*/
*/
if (pConfig->deviceType == ma_device_type_duplex) {
if (pConfig->deviceType == ma_device_type_duplex) {
result = ma_duplex_rb_init(format, channels, sampleRate, pDescriptorCapture->sampleRate, pDescriptorCapture->periodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
ma_format rbFormat = (format != ma_format_unknown) ? format : pDescriptorCapture->format;
ma_uint32 rbChannels = (channels > 0) ? channels : pDescriptorCapture->channels;
ma_uint32 rbSampleRate = (sampleRate > 0) ? sampleRate : pDescriptorCapture->sampleRate;
result = ma_duplex_rb_init(rbFormat, rbChannels, rbSampleRate, pDescriptorCapture->sampleRate, pDescriptorCapture->periodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
if (result != MA_SUCCESS) {
if (result != MA_SUCCESS) {
ma_log_post
(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize ring buffer."
);
ma_log_post
f(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize ring buffer. %s.\n", ma_result_description(result)
);
goto on_error4;
goto on_error4;
}
}
}
}
...
@@ -32665,14 +32673,13 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
...
@@ -32665,14 +32673,13 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
In playback mode, iff the data converter does not support retrieval of the required number of
In playback mode, iff the data converter does not support retrieval of the required number of
input frames given a number of output frames, we need to fall back to a heap-allocated cache.
input frames given a number of output frames, we need to fall back to a heap-allocated cache.
*/
*/
if (deviceType == ma_device_type_playback) {
if (deviceType == ma_device_type_playback
|| deviceType == ma_device_type_duplex
) {
ma_uint64 unused;
ma_uint64 unused;
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheRemaining = 0;
pDevice->playback.inputCacheRemaining = 0;
result = ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused);
if (deviceType == ma_device_type_duplex || ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) {
if (result != MA_SUCCESS) {
/* We need a heap allocated cache. We want to size this based on the period size. */
/* We need a heap allocated cache. We want to size this based on the period size. */
void* pNewInputCache;
void* pNewInputCache;
ma_uint64 newInputCacheCap;
ma_uint64 newInputCacheCap;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment