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

Method GetBlob

libraries/lib-project-file-io/SqliteSampleBlock.cpp:578–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576}
577
578size_t SqliteSampleBlock::GetBlob(void *dest,
579 sampleFormat destformat,
580 sqlite3_stmt *stmt,
581 sampleFormat srcformat,
582 size_t srcoffset,
583 size_t srcbytes)
584{
585 auto db = DB();
586
587 wxASSERT(!IsSilent());
588
589 if (!mValid)
590 {
591 Load(mBlockID);
592 }
593
594 int rc;
595 size_t minbytes = 0;
596
597 // Bind statement parameters
598 // Might return SQLITE_MISUSE which means it's our mistake that we violated
599 // preconditions; should return SQL_OK which is 0
600 if (sqlite3_bind_int64(stmt, 1, mBlockID))
601 {
602 ADD_EXCEPTION_CONTEXT(
603 "sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
604 ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::bind");
605
606 wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
607 }
608
609 // Execute the statement
610 rc = sqlite3_step(stmt);
611 if (rc != SQLITE_ROW)
612 {
613 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
614 ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::step");
615
616 wxLogDebug(wxT("SqliteSampleBlock::GetBlob - SQLITE error %s"), sqlite3_errmsg(db));
617
618 // Clear statement bindings and rewind statement
619 sqlite3_clear_bindings(stmt);
620 sqlite3_reset(stmt);
621
622 // Just showing the user a simple message, not the library error too
623 // which isn't internationalized
624 // Actually this can lead to 'Could not read from file' error message
625 // but it can also lead to no error message at all and a flat line,
626 // depending on where GetBlob is called from.
627 // The latter can happen when repainting the screen.
628 // That possibly happens on a very slow machine. Possibly that's the
629 // right trade off when a machine can't keep up?
630 // ANSWER-ME: Do we always report an error when we should here?
631 Conn()->ThrowException( false );
632 }
633
634 // Retrieve returned data
635 samplePtr src = (samplePtr) sqlite3_column_blob(stmt, 0);

Callers

nothing calls this directly

Calls 6

LoadFunction · 0.85
to_stringFunction · 0.85
CopySamplesFunction · 0.85
ThrowExceptionMethod · 0.80
minFunction · 0.50
DBMethod · 0.45

Tested by

no test coverage detected