M module-audio/Audio/Audio.cpp => module-audio/Audio/Audio.cpp +3 -0
@@ 1,7 1,9 @@
#include "Audio.hpp"
#include "Operation/Operation.hpp"
+
#include <log/log.hpp>
#include <Utils.hpp>
+#include <bsp/headset/headset.hpp>
namespace audio
{
@@ 14,6 16,7 @@ namespace audio
if (ret) {
currentOperation = std::move(ret.value());
}
+ headphonesInserted = bsp::headset::IsInserted();
}
Position Audio::GetPosition()
M module-audio/Audio/Operation/PlaybackOperation.cpp => module-audio/Audio/Operation/PlaybackOperation.cpp +4 -1
@@ 78,7 78,10 @@ namespace audio
return RetCode::InvokedInIncorrectState;
}
operationToken = token;
- auto tags = dec->fetchTags();
+
+ if (!tags) {
+ tags = dec->fetchTags();
+ }
eventCallback = callback;
state = State::Active;
M module-audio/Audio/Operation/PlaybackOperation.hpp => module-audio/Audio/Operation/PlaybackOperation.hpp +4 -2
@@ 13,6 13,7 @@ namespace audio::playbackDefaults
namespace audio
{
class decoder;
+ class Tags;
class PlaybackOperation : public Operation
{
@@ 41,8 42,9 @@ namespace audio
Position GetPosition() override final;
private:
- std::unique_ptr<decoder> dec = nullptr;
- std::unique_ptr<bsp::AudioDevice> audioDevice = nullptr;
+ std::unique_ptr<decoder> dec;
+ std::unique_ptr<bsp::AudioDevice> audioDevice;
+ std::unique_ptr<Tags> tags;
};
} // namespace audio
M module-audio/Audio/decoder/decoder.cpp => module-audio/Audio/decoder/decoder.cpp +2 -1
@@ 45,6 45,7 @@ namespace audio
std::unique_ptr<Tags> decoder::fetchTags()
{
if (fd) {
+ auto inPos = vfs.ftell(fd);
vfs.rewind(fd);
TagLib::FileStream fileStream(fd);
TagLib::FileRef tagReader(&fileStream);
@@ 68,7 69,7 @@ namespace audio
}
vfs.rewind(fd);
fetchTagsSpecific();
- vfs.rewind(fd);
+ vfs.fseek(fd, inPos, SEEK_SET);
}
tag->filePath.append(filePath);