Skip to content

Commit

Permalink
Fix some doxygen warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jul 2, 2024
1 parent 47d5d34 commit f640d42
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# 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
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
17 changes: 11 additions & 6 deletions client/decoder/decoder.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***
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
it under the terms of the GNU General Public License as published by
Expand All @@ -27,22 +27,27 @@
// 3rd party headers

// standard headers
#include <mutex>

namespace decoder
{

/// Base class for an audio decoder
class Decoder
{
public:
Decoder(){};
/// c'tor
Decoder() = default;
/// d'tor
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 SampleFormat setHeader(msg::CodecHeader* chunk) = 0;

protected:
std::mutex mutex_;
/// Set the codec header, stored in @p chunk.
/// 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
4 changes: 4 additions & 0 deletions client/decoder/flac_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

// standard headers
#include <memory>
#include <mutex>


namespace decoder
Expand Down Expand Up @@ -60,6 +61,9 @@ class FlacDecoder : public Decoder

CacheInfo cacheInfo_;
std::unique_ptr<FLAC__StreamDecoderErrorStatus> lastError_;

private:
std::mutex mutex_;
};

} // namespace decoder
5 changes: 5 additions & 0 deletions client/decoder/ogg_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#endif
#include <ogg/ogg.h>

// standard headers
#include <mutex>


namespace decoder
{

Expand Down Expand Up @@ -64,6 +68,7 @@ class OggDecoder : public Decoder
vorbis_block vb; /// local working space for packet->PCM decode

SampleFormat sampleFormat_;
std::mutex mutex_;
};

} // namespace decoder
17 changes: 14 additions & 3 deletions server/encoder/encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,41 @@ namespace encoder
class Encoder
{
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)>;

/// 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)
{
}

/// d'tor
virtual ~Encoder() = default;

/// The listener will receive the encoded stream
virtual void init(OnEncodedCallback callback, const SampleFormat& format)
{
if (codecOptions_ == "")
if (codecOptions_.empty())
codecOptions_ = getDefaultOptions();
encoded_callback_ = callback;
encoded_callback_ = std::move(callback);
sampleFormat_ = format;
initEncoder();
}

/// Here the work is done. Encoded data is passed to the EncoderListener.
virtual void encode(const msg::PcmChunk& chunk) = 0;

/// @return the name of the encoder
virtual std::string name() const = 0;

/// @return configuration options of the encoder
virtual std::string getAvailableOptions() const
{
return "No codec options supported";
}

/// @return default configuration option of the encoder
virtual std::string getDefaultOptions() const
{
return "";
Expand All @@ -81,11 +87,16 @@ class Encoder
}

protected:
/// Initialize the encoder
virtual void initEncoder() = 0;

/// The sampleformat
SampleFormat sampleFormat_;
/// The codec header, sent to each newly connected streaming client
std::shared_ptr<msg::CodecHeader> headerChunk_;
/// The configured codec options
std::string codecOptions_;
/// Callback to return encoded chunks
OnEncodedCallback encoded_callback_;
};

Expand Down
9 changes: 8 additions & 1 deletion server/stream_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class shared_const_buffer
};


/// Write result callback function type
using WriteHandler = std::function<void(boost::system::error_code ec, std::size_t length)>;

/// Endpoint for a connected client.
Expand All @@ -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>
{
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);
/// d'tor
virtual ~StreamSession() = default;

/// @return the IP of the connected streaming client
virtual std::string getIP() = 0;

/// Start the StreamSession, e.g. start reading and processing data
virtual void start() = 0;
/// Stop the StreamSession
virtual void stop() = 0;

/// Set the message receiver to @p receiver
void setMessageReceiver(StreamMessageReceiver* receiver)
{
messageReceiver_ = receiver;
}

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;

public:
Expand Down

0 comments on commit f640d42

Please sign in to comment.