mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Guarantee cleanup of partial allocation on all error return paths...
... such as when allocating for capture channels fails after that for playback succeeds
This commit is contained in:
parent
3a94acd631
commit
8a6351d9cd
@ -2227,6 +2227,11 @@ bool AudioIO::AllocateBuffers(
|
|||||||
const TransportTracks &tracks, double t0, double t1, double sampleRate,
|
const TransportTracks &tracks, double t0, double t1, double sampleRate,
|
||||||
bool scrubbing )
|
bool scrubbing )
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
|
auto cleanup = finally([&]{
|
||||||
|
if (!success) StartStreamCleanup( false );
|
||||||
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
// The (audio) stream has been opened successfully (assuming we tried
|
// The (audio) stream has been opened successfully (assuming we tried
|
||||||
// to open it). We now proceed to
|
// to open it). We now proceed to
|
||||||
@ -2337,7 +2342,6 @@ bool AudioIO::AllocateBuffers(
|
|||||||
// 100 samples, just give up.
|
// 100 samples, just give up.
|
||||||
if(captureBufferSize < 100)
|
if(captureBufferSize < 100)
|
||||||
{
|
{
|
||||||
StartStreamCleanup();
|
|
||||||
AudacityMessageBox(_("Out of memory!"));
|
AudacityMessageBox(_("Out of memory!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2373,13 +2377,13 @@ bool AudioIO::AllocateBuffers(
|
|||||||
(size_t)lrint(mRate * mPlaybackRingBufferSecs);
|
(size_t)lrint(mRate * mPlaybackRingBufferSecs);
|
||||||
if(playbackBufferSize < 100 || mPlaybackSamplesToCopy < 100)
|
if(playbackBufferSize < 100 || mPlaybackSamplesToCopy < 100)
|
||||||
{
|
{
|
||||||
StartStreamCleanup();
|
|
||||||
AudacityMessageBox(_("Out of memory!"));
|
AudacityMessageBox(_("Out of memory!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(!bDone);
|
} while(!bDone);
|
||||||
|
|
||||||
|
success = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user