Fix some doxygen warnings

This commit is contained in:
badaix 2024-07-02 12:43:32 +02:00
parent 061f92a361
commit c156fab123
6 changed files with 43 additions and 11 deletions

View file

@ -952,7 +952,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is # Note that relative paths are relative to the directory from which doxygen is
# run. # run.
EXCLUDE = README.md common/json.hpp server/etc EXCLUDE = README.md common/json.hpp server/etc server/jsonrpcpp.hpp common/popl.hpp common/aixlog.hpp
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded # directories that are symbolic links (a Unix file system feature) are excluded

View file

@ -1,6 +1,6 @@
/*** /***
This file is part of snapcast This file is part of snapcast
Copyright (C) 2014-2023 Johannes Pohl Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -27,22 +27,27 @@
// 3rd party headers // 3rd party headers
// standard headers // standard headers
#include <mutex>
namespace decoder namespace decoder
{ {
/// Base class for an audio decoder
class Decoder class Decoder
{ {
public: public:
Decoder(){}; /// c'tor
Decoder() = default;
/// d'tor
virtual ~Decoder() = default; virtual ~Decoder() = default;
/// decode encoded data stored in @p chunk, and write decoded data back into @p chunk
/// return true, if data could be decoded and written back into @p chunk
virtual bool decode(msg::PcmChunk* chunk) = 0; virtual bool decode(msg::PcmChunk* chunk) = 0;
virtual SampleFormat setHeader(msg::CodecHeader* chunk) = 0;
protected: /// Set the codec header, stored in @p chunk.
std::mutex mutex_; /// The CodecHeader is sent to every newly connected streaming client as first audio message.
/// @return the sampleformat, decoded from the header
virtual SampleFormat setHeader(msg::CodecHeader* chunk) = 0;
}; };
} // namespace decoder } // namespace decoder

View file

@ -26,6 +26,7 @@
// standard headers // standard headers
#include <memory> #include <memory>
#include <mutex>
namespace decoder namespace decoder
@ -60,6 +61,9 @@ public:
CacheInfo cacheInfo_; CacheInfo cacheInfo_;
std::unique_ptr<FLAC__StreamDecoderErrorStatus> lastError_; std::unique_ptr<FLAC__StreamDecoderErrorStatus> lastError_;
private:
std::mutex mutex_;
}; };
} // namespace decoder } // namespace decoder

View file

@ -29,6 +29,10 @@
#endif #endif
#include <ogg/ogg.h> #include <ogg/ogg.h>
// standard headers
#include <mutex>
namespace decoder namespace decoder
{ {
@ -64,6 +68,7 @@ private:
vorbis_block vb; /// local working space for packet->PCM decode vorbis_block vb; /// local working space for packet->PCM decode
SampleFormat sampleFormat_; SampleFormat sampleFormat_;
std::mutex mutex_;
}; };
} // namespace decoder } // namespace decoder

View file

@ -40,21 +40,24 @@ namespace encoder
class Encoder class Encoder
{ {
public: public:
/// Callback type to return encoded chunks, along with the encoder itself and the duration in ms of the chunk
using OnEncodedCallback = std::function<void(const Encoder&, std::shared_ptr<msg::PcmChunk>, double)>; using OnEncodedCallback = std::function<void(const Encoder&, std::shared_ptr<msg::PcmChunk>, double)>;
/// ctor. Codec options (E.g. compression level) are passed as string and are codec dependend /// c'tor
/// Codec options (E.g. compression level) are passed as string and are codec dependend
Encoder(const std::string& codecOptions = "") : headerChunk_(nullptr), codecOptions_(codecOptions) Encoder(const std::string& codecOptions = "") : headerChunk_(nullptr), codecOptions_(codecOptions)
{ {
} }
/// d'tor
virtual ~Encoder() = default; virtual ~Encoder() = default;
/// The listener will receive the encoded stream /// The listener will receive the encoded stream
virtual void init(OnEncodedCallback callback, const SampleFormat& format) virtual void init(OnEncodedCallback callback, const SampleFormat& format)
{ {
if (codecOptions_ == "") if (codecOptions_.empty())
codecOptions_ = getDefaultOptions(); codecOptions_ = getDefaultOptions();
encoded_callback_ = callback; encoded_callback_ = std::move(callback);
sampleFormat_ = format; sampleFormat_ = format;
initEncoder(); initEncoder();
} }
@ -62,13 +65,16 @@ public:
/// Here the work is done. Encoded data is passed to the EncoderListener. /// Here the work is done. Encoded data is passed to the EncoderListener.
virtual void encode(const msg::PcmChunk& chunk) = 0; virtual void encode(const msg::PcmChunk& chunk) = 0;
/// @return the name of the encoder
virtual std::string name() const = 0; virtual std::string name() const = 0;
/// @return configuration options of the encoder
virtual std::string getAvailableOptions() const virtual std::string getAvailableOptions() const
{ {
return "No codec options supported"; return "No codec options supported";
} }
/// @return default configuration option of the encoder
virtual std::string getDefaultOptions() const virtual std::string getDefaultOptions() const
{ {
return ""; return "";
@ -81,11 +87,16 @@ public:
} }
protected: protected:
/// Initialize the encoder
virtual void initEncoder() = 0; virtual void initEncoder() = 0;
/// The sampleformat
SampleFormat sampleFormat_; SampleFormat sampleFormat_;
/// The codec header, sent to each newly connected streaming client
std::shared_ptr<msg::CodecHeader> headerChunk_; std::shared_ptr<msg::CodecHeader> headerChunk_;
/// The configured codec options
std::string codecOptions_; std::string codecOptions_;
/// Callback to return encoded chunks
OnEncodedCallback encoded_callback_; OnEncodedCallback encoded_callback_;
}; };

View file

@ -106,6 +106,7 @@ private:
}; };
/// Write result callback function type
using WriteHandler = std::function<void(boost::system::error_code ec, std::size_t length)>; using WriteHandler = std::function<void(boost::system::error_code ec, std::size_t length)>;
/// Endpoint for a connected client. /// Endpoint for a connected client.
@ -117,21 +118,27 @@ using WriteHandler = std::function<void(boost::system::error_code ec, std::size_
class StreamSession : public std::enable_shared_from_this<StreamSession> class StreamSession : public std::enable_shared_from_this<StreamSession>
{ {
public: public:
/// ctor. Received message from the client are passed to StreamMessageReceiver /// c'tor. Received message from the client are passed to StreamMessageReceiver
StreamSession(const boost::asio::any_io_executor& executor, StreamMessageReceiver* receiver); StreamSession(const boost::asio::any_io_executor& executor, StreamMessageReceiver* receiver);
/// d'tor
virtual ~StreamSession() = default; virtual ~StreamSession() = default;
/// @return the IP of the connected streaming client
virtual std::string getIP() = 0; virtual std::string getIP() = 0;
/// Start the StreamSession, e.g. start reading and processing data
virtual void start() = 0; virtual void start() = 0;
/// Stop the StreamSession
virtual void stop() = 0; virtual void stop() = 0;
/// Set the message receiver to @p receiver
void setMessageReceiver(StreamMessageReceiver* receiver) void setMessageReceiver(StreamMessageReceiver* receiver)
{ {
messageReceiver_ = receiver; messageReceiver_ = receiver;
} }
protected: protected:
/// Send data @p buffer to the streaming client, result is returned in the callback @p handler
virtual void sendAsync(const shared_const_buffer& buffer, const WriteHandler& handler) = 0; virtual void sendAsync(const shared_const_buffer& buffer, const WriteHandler& handler) = 0;
public: public: