Skip to content

Commit

Permalink
init audio file manager when sd read successfully (#2338)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-m-adams authored Jul 28, 2024
1 parent c367c04 commit ab4f0f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
29 changes: 12 additions & 17 deletions src/deluge/storage/audio/audio_file_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ AudioFileManager::AudioFileManager() {
}
}

void AudioFileManager::firstCardRead() {
if (cardReadOnce) {
cardReinserted();
}
else {
init();
}
}

void AudioFileManager::init() {

clusterBeingLoaded = NULL;
Expand Down Expand Up @@ -1246,23 +1255,9 @@ void AudioFileManager::slowRoutine() {

// If we know the card's been ejected...
if (cardEjected) {
// If it's still ejected, get out
if (!storageManager.checkSDPresent()) {
return;

// Otherwise, see if we can get it
}
else {
Error error = storageManager.initSD();
if (error == Error::NONE) {
cardEjected = false;
if (cardReadOnce) {
cardReinserted();
}
else {
init();
}
}
Error error = storageManager.initSD();
if (error == Error::NONE) {
cardEjected = false;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/deluge/storage/audio/audio_file_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class AudioFileManager {

ClusterPriorityQueue loadingQueue;

uint32_t clusterSize;
uint32_t clusterSizeAtBoot;
uint32_t clusterSize{32768};
uint32_t clusterSizeAtBoot{0};
int32_t clusterSizeMagnitude;

uint32_t clusterObjectSize;
Expand All @@ -133,6 +133,7 @@ class AudioFileManager {

int32_t highestUsedAudioRecordingNumber[kNumAudioRecordingFolders];
bool highestUsedAudioRecordingNumberNeedsReChecking[kNumAudioRecordingFolders];
void firstCardRead();

private:
void setClusterSize(uint32_t newSize);
Expand Down
1 change: 1 addition & 0 deletions src/deluge/storage/storage_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Error StorageManager::initSD() {
return error; //<
});
if (success) {
audioFileManager.firstCardRead(); // tell the audio file manager that we have a new card
return Error::NONE;
}
return Error::SD_CARD;
Expand Down

0 comments on commit ab4f0f4

Please sign in to comment.