mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-24 00:49:28 -04:00
1. Prepare Pure and Bell specific `Application` classes and add them to `app` target: - `products/BellHybrid/apps/Application.cpp` - `products/PurePhone/apps/Application.cpp` 2. Update `CMakeLists.txt` files. 3. Move `ApplicationBell` implementation to Bell-specific `Application` class and remove `ApplicationBell` files. 4. Change Bell apps parent classes from `ApplicationBell` to Bell-specific `Application` class. 5. Rename `Application` to `ApplicationCommon` in the rest of the files.
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <Audio/decoder/Decoder.hpp>
|
|
|
|
#include <AsyncTask.hpp>
|
|
|
|
namespace app
|
|
{
|
|
class ApplicationCommon;
|
|
|
|
class AbstractAudioOperations
|
|
{
|
|
public:
|
|
using OnPlayCallback = std::function<void(audio::RetCode retCode, audio::Token token)>;
|
|
using OnStopCallback = OnPlayCallback;
|
|
using OnPauseCallback = OnPlayCallback;
|
|
using OnResumeCallback = OnPlayCallback;
|
|
|
|
virtual ~AbstractAudioOperations() noexcept = default;
|
|
|
|
virtual bool play(const std::string &filePath, const OnPlayCallback &callback) = 0;
|
|
virtual bool pause(const audio::Token &token, const OnPauseCallback &callback) = 0;
|
|
virtual bool resume(const audio::Token &token, const OnResumeCallback &callback) = 0;
|
|
virtual bool stop(const audio::Token &token, const OnStopCallback &callback) = 0;
|
|
};
|
|
|
|
class AsyncAudioOperations : public AbstractAudioOperations, public app::AsyncCallbackReceiver
|
|
{
|
|
public:
|
|
explicit AsyncAudioOperations(ApplicationCommon *application);
|
|
|
|
bool play(const std::string &filePath, const OnPlayCallback &callback) override;
|
|
bool pause(const audio::Token &token, const OnPauseCallback &callback) override;
|
|
bool resume(const audio::Token &token, const OnResumeCallback &callback) override;
|
|
bool stop(const audio::Token &token, const OnStopCallback &callback) override;
|
|
|
|
private:
|
|
ApplicationCommon *application = nullptr;
|
|
};
|
|
} // namespace app
|