-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue after latest update. #484
Comments
I had the same problem. |
Ok, compiler no not give me error, but function do not read the file. |
In the latest version of SdFat the copy constructor for File classes is private to prevent multiple copies of a file object. A function with this signature will create copy of myFile on the stack.
This can cause bugs since the File object in the calling program is not updated. With this call by reference only one copy of the file object exists:
I you really want to have multiple, maybe inconsistent, copies of a file object you can edit SdFatConfig.h here. |
void AudioZeroClass::play(FsFile& myFile) { By changing only the definition of audiozero, the file is played, but only the first time. In the previous version, this did not happen. `void AudioZeroClass::play(File myFile) {
} |
This is because of the change from call by value to call by reference. The file object in the calling program now used instead of a copy so play now closes the file object in the calling program. Generally having multiple copies of a file object for an open file causes bugs. If you don't want to fix the multiple copy problem just edit SdFatConfig.h and allow multiple copies. |
How do I get the file to play again? |
See the above link to the place to change in SdFatConfig.h. |
Not, without change SdFat
With this relise how I can play again?
Il 30 Maggio 2024 18:47:52 CEST, Bill Greiman ***@***.***> ha scritto:
> How do I get the file to play again?
See the above link to the place to change in SdFatConfig.h.
--
Reply to this email directly or view it on GitHub:
#484 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
--
Inviato dal mio dispositivo Android con K-9 Mail. Perdonate la brevità.
|
at line 68 of SdFatConfig.h
to
|
Does this fix my issue too? |
looks like it did... now compiles without error. |
It doesn't fix the fundamental issue of multiple copies of a file object but it will allow call by value. |
It's been a long time since I looked at my code, but am I creating multiple instances? SdFat sd; is SdFile an inherited class of File ? By the way, I'm a novice at C++, so it's a miracle how I managed to get my coding working in the first place. |
File is a typedef. The whole class structure has become very complex to allow SdFat to run on many boards. Many of the definitions are here. There are two basic ways to create a copy of an object. The copy constructor which makes a copy on the stack for call by value.
And the assignment operator:
The state of the file is in the File object so multiple objects for a file can cause problems. If one object is used for write and the file is closed with another object, file system corruption is likely. |
@gioreva BTW I added sdfat to the AudioZero library 5 years ago. Just interested re you using my library https://github.com/rickyelqasem/AudioZeroSdFat or did you modify it yourself? |
I think I made a lot of changes. But I haven't figured out how I can loop the playback, leaving SdFat private. |
I would put a rewind at the start of
and remove the |
I'm using the TMRPcm library and previously sat 2.1.2 with no problems. After updating sdfat to latest version I get the following errors on compile:
TMRpcm.cpp:1442:61: error: use of deleted function 'SdFile::SdFile(const SdFile&)'
SdFat.h:468:7: error: use of deleted function 'PrintFile::PrintFile(const PrintFile&)'
ArduinoFiles.h:43:7: error: 'constexpr FatFile::FatFile(const FatFile&)' is private within this context
Could you point me in the right direction? and Sorry if its been documented.
The text was updated successfully, but these errors were encountered: