Files
Rajarshee Chatterjee 74808f086e feat: Replace Legacy Media Controls with Nitro-Powered Playback (#1896)
* feat: Replace Legacy Media Controls with Nitro-Powered Playback

* feat: Add TTS Engine Selection

* chore: Remove User-Facing Error Reporting

* refactor: Combine `Tts` and `TtsSession` Imports from `nitro-tts` Module

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-24 23:42:17 +05:30

192 lines
7.2 KiB
C++
Generated

///
/// HybridTtsSessionSpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#include "HybridTtsSessionSpec.hpp"
// Forward declaration of `HybridTtsSessionSpec_cxx` to properly resolve imports.
namespace NitroTts { class HybridTtsSessionSpec_cxx; }
// Forward declaration of `TtsParagraph` to properly resolve imports.
namespace margelo::nitro::nitrotts { struct TtsParagraph; }
// Forward declaration of `TtsMetadata` to properly resolve imports.
namespace margelo::nitro::nitrotts { struct TtsMetadata; }
// Forward declaration of `TtsSettings` to properly resolve imports.
namespace margelo::nitro::nitrotts { struct TtsSettings; }
// Forward declaration of `ListenerSubscription` to properly resolve imports.
namespace margelo::nitro::nitrotts { struct ListenerSubscription; }
// Forward declaration of `TtsPlaybackState` to properly resolve imports.
namespace margelo::nitro::nitrotts { enum class TtsPlaybackState; }
// Forward declaration of `TtsProgress` to properly resolve imports.
namespace margelo::nitro::nitrotts { struct TtsProgress; }
#include <NitroModules/Promise.hpp>
#include "TtsParagraph.hpp"
#include <vector>
#include <string>
#include "TtsMetadata.hpp"
#include <optional>
#include "TtsSettings.hpp"
#include "ListenerSubscription.hpp"
#include <functional>
#include "TtsPlaybackState.hpp"
#include "TtsProgress.hpp"
#include "NitroTts-Swift-Cxx-Umbrella.hpp"
namespace margelo::nitro::nitrotts {
/**
* The C++ part of HybridTtsSessionSpec_cxx.swift.
*
* HybridTtsSessionSpecSwift (C++) accesses HybridTtsSessionSpec_cxx (Swift), and might
* contain some additional bridging code for C++ <> Swift interop.
*
* Since this obviously introduces an overhead, I hope at some point in
* the future, HybridTtsSessionSpec_cxx can directly inherit from the C++ class HybridTtsSessionSpec
* to simplify the whole structure and memory management.
*/
class HybridTtsSessionSpecSwift: public virtual HybridTtsSessionSpec {
public:
// Constructor from a Swift instance
explicit HybridTtsSessionSpecSwift(const NitroTts::HybridTtsSessionSpec_cxx& swiftPart):
HybridObject(HybridTtsSessionSpec::TAG),
_swiftPart(swiftPart) { }
public:
// Get the Swift part
inline NitroTts::HybridTtsSessionSpec_cxx& getSwiftPart() noexcept {
return _swiftPart;
}
public:
inline size_t getExternalMemorySize() noexcept override {
return _swiftPart.getMemorySize();
}
bool equals(const std::shared_ptr<HybridObject>& other) override {
if (auto otherCast = std::dynamic_pointer_cast<HybridTtsSessionSpecSwift>(other)) {
return _swiftPart.equals(otherCast->_swiftPart);
}
return false;
}
void dispose() noexcept override {
_swiftPart.dispose();
}
std::string toString() override {
return _swiftPart.toString();
}
public:
// Properties
public:
// Methods
inline std::shared_ptr<Promise<void>> load(const std::vector<TtsParagraph>& paragraphs, double initialIndex, const TtsMetadata& metadata, const TtsSettings& settings) override {
auto __result = _swiftPart.load(paragraphs, std::forward<decltype(initialIndex)>(initialIndex), std::forward<decltype(metadata)>(metadata), std::forward<decltype(settings)>(settings));
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> play() override {
auto __result = _swiftPart.play();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> pause() override {
auto __result = _swiftPart.pause();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> stop() override {
auto __result = _swiftPart.stop();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> skipPrevious() override {
auto __result = _swiftPart.skipPrevious();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> skipNext() override {
auto __result = _swiftPart.skipNext();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> replayCurrent() override {
auto __result = _swiftPart.replayCurrent();
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> seekTo(double index) override {
auto __result = _swiftPart.seekTo(std::forward<decltype(index)>(index));
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<void>> updateSettings(const TtsSettings& settings) override {
auto __result = _swiftPart.updateSettings(std::forward<decltype(settings)>(settings));
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline ListenerSubscription addOnStateChangedListener(const std::function<void(TtsPlaybackState /* state */)>& listener) override {
auto __result = _swiftPart.addOnStateChangedListener(listener);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline ListenerSubscription addOnProgressChangedListener(const std::function<void(const TtsProgress& /* progress */)>& listener) override {
auto __result = _swiftPart.addOnProgressChangedListener(listener);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline ListenerSubscription addOnErrorListener(const std::function<void(const std::string& /* message */)>& listener) override {
auto __result = _swiftPart.addOnErrorListener(listener);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
private:
NitroTts::HybridTtsSessionSpec_cxx _swiftPart;
};
} // namespace margelo::nitro::nitrotts