Browse Source

Merge pull request #217 from FrankBoesing/patch-3

Fix for two little bugs
dds
Paul Stoffregen 8 years ago
parent
commit
15ad56ce44
1 changed files with 21 additions and 5 deletions
  1. +21
    -5
      play_sd_raw.cpp

+ 21
- 5
play_sd_raw.cpp View File

bool AudioPlaySdRaw::play(const char *filename) bool AudioPlaySdRaw::play(const char *filename)
{ {
stop(); stop();
#if defined(HAS_KINETIS_SDHC)
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStartUsingSPI();
#else
AudioStartUsingSPI(); AudioStartUsingSPI();
#endif
__disable_irq();
rawfile = SD.open(filename); rawfile = SD.open(filename);
__enable_irq();
if (!rawfile) { if (!rawfile) {
//Serial.println("unable to open file"); //Serial.println("unable to open file");
AudioStopUsingSPI();
#if defined(HAS_KINETIS_SDHC)
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI();
#else
AudioStopUsingSPI();
#endif
return false; return false;
} }
file_size = rawfile.size(); file_size = rawfile.size();
playing = false; playing = false;
__enable_irq(); __enable_irq();
rawfile.close(); rawfile.close();
AudioStopUsingSPI();
#if defined(HAS_KINETIS_SDHC)
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI();
#else
AudioStopUsingSPI();
#endif
} else { } else {
__enable_irq(); __enable_irq();
} }
transmit(block); transmit(block);
} else { } else {
rawfile.close(); rawfile.close();
AudioStopUsingSPI();
#if defined(HAS_KINETIS_SDHC)
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI();
#else
AudioStopUsingSPI();
#endif
playing = false; playing = false;
} }
release(block); release(block);
{ {
return ((uint64_t)file_size * B2M) >> 32; return ((uint64_t)file_size * B2M) >> 32;
} }



Loading…
Cancel
Save