MCPcopy Create free account
hub / github.com/audacity/audacity / AddSamples

Method AddSamples

modules/import-export/mod-aup/ImportAUP.cpp:1440–1653  ·  view source on GitHub ↗

All errors that occur here will simply insert silence and allow the import to continue.

Source from the content-addressed store, hash-verified

1438// All errors that occur here will simply insert silence and allow the
1439// import to continue.
1440bool AUPImportFileHandle::AddSamples(const FilePath &blockFilename,
1441 const FilePath &audioFilename,
1442 sampleCount len,
1443 sampleFormat format,
1444 sampleCount origin /* = 0 */,
1445 int channel /* = 0 */)
1446{
1447 auto pClip = mClip ? mClip : mWaveTrack->RightmostOrNewClip().get();
1448 auto &pBlock = mFileMap[wxFileNameFromPath(blockFilename)].second;
1449 if (pBlock) {
1450 // Replicate the sharing of blocks
1451 if (pClip->NChannels() != 1)
1452 return false;
1453 pClip->AppendLegacySharedBlock( pBlock );
1454 return true;
1455 }
1456
1457 // Third party library has its own type alias, check it before
1458 // adding origin + size_t
1459 static_assert(sizeof(sampleCount::type) <= sizeof(sf_count_t),
1460 "Type sf_count_t is too narrow to hold a sampleCount");
1461
1462 SF_INFO info;
1463 memset(&info, 0, sizeof(info));
1464
1465 wxFile f; // will be closed when it goes out of scope
1466 SNDFILE *sf = nullptr;
1467 bool success = false;
1468
1469#ifndef UNCAUGHT_EXCEPTIONS_UNAVAILABLE
1470 const auto uncaughtExceptionsCount = std::uncaught_exceptions();
1471#endif
1472
1473 auto cleanup = finally([&]
1474 {
1475 // Do this before any throwing might happen
1476 if (sf)
1477 {
1478 SFCall<int>(sf_close, sf);
1479 }
1480
1481 if (!success)
1482 {
1483 SetWarning(XO("Error while processing %s\n\nInserting silence.").Format(audioFilename));
1484
1485 // If we are unwinding for an exception, don't do another
1486 // potentially throwing operation
1487#ifdef UNCAUGHT_EXCEPTIONS_UNAVAILABLE
1488 if (!std::uncaught_exception())
1489#else
1490 if (uncaughtExceptionsCount == std::uncaught_exceptions())
1491#endif
1492 // If this does throw, let that propagate, don't guard the call
1493 AddSilence(len);
1494 }
1495 });
1496
1497 if (!f.Open(audioFilename))

Callers

nothing calls this directly

Calls 12

finallyFunction · 0.85
sf_subtype_is_integerFunction · 0.85
CopySamplesFunction · 0.85
RightmostOrNewClipMethod · 0.80
as_size_tMethod · 0.80
ptrMethod · 0.80
AppendLegacyNewBlockMethod · 0.80
getMethod · 0.45
NChannelsMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected