arduino-snapclient
All Classes Namespaces Functions Pages
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
SnapProcessorRTOS Class Reference

Processor for which the encoded output is buffered in a queue in order to prevent any buffer underruns. A RTOS task feeds the output from the queue. More...

#include <SnapProcessorRTOS.h>

Inheritance diagram for SnapProcessorRTOS:
SnapProcessor

Public Member Functions

 SnapProcessorRTOS (int buffer_size, int activationAtPercent=75)
 Default constructor.
 
 SnapProcessorRTOS (SnapOutput &output, int buffer_size, int activationAtPercent=75)
 Default constructor.
 
bool begin () override
 Sets up the output and the client.
 
const char * clientName ()
 
bool doLoop ()
 Call via SnapClient in Arduino Loop!
 
virtual bool doLoop1 ()
 Usually not used!
 
void end (void) override
 
tv_t getLatency ()
 
const char * hostName ()
 
void setAudioInfo (AudioInfo info)
 
void setClient (Client &client)
 Defines an alternative client to the WiFiClient.
 
void setClientName (const char *name)
 Defines the client name (default "libsnapcast")
 
void setDecoder (AudioDecoder &dec)
 Defines the decoder class.
 
void setFastLoop (bool flag)
 
void setHostName (const char *name)
 Defines the host name (default CONFIG_SNAPCAST_CLIENT_NAME)
 
void setMacAddress (const char *adr)
 
void setOutput (AudioOutput &output)
 Defines the output class.
 
void setServerIP (IPAddress address)
 
void setServerPort (int port)
 
void setSnapOutput (SnapOutput &out)
 Defines the SnapOutput implementation.
 
void setStartOutput (bool start)
 
void setStartTask (bool flag)
 
void setVolumeFactor (float fact)
 Adjust volume by factor e.g. 1.5.
 
SnapOutputsnapOutput ()
 
float volume (void)
 Provides the volume (in the range of 0.0 to 1.0)
 

Protected Types

enum  loop_status_enum { LoopStart , LoopStep , LoopEnd }
 

Protected Member Functions

bool audioBegin ()
 
void audioEnd ()
 
int bufferTaskActivationLimit ()
 Determines the buffer fill limit at which we start to process the data.
 
bool connectClient ()
 connects to the server: returns true if we are connected
 
void copy ()
 Copy the buffered data to the output.
 
void init_rtos (int bufferSize, int activationAtPercent)
 store parameters provided by constructor
 
virtual void processExt ()
 additional processing
 
bool processLoopStep ()
 
bool processLoopStepFast ()
 
bool processMessageCodecHeader ()
 
bool processMessageCodecHeaderExt (codec_type codecType)
 
bool processMessageCodecHeaderOpus (codec_type codecType)
 
bool processMessageCodecHeaderWav (codec_type codecType)
 
bool processMessageLoop ()
 
bool processMessageServerSettings ()
 
bool processMessageTime ()
 
bool processMessageWireChunk ()
 
bool readBaseMessage ()
 
bool readData ()
 
bool resizeData ()
 
void setMute (bool flag)
 
void setVolume (float vol)
 
bool wireChunk (SnapMessageWireChunk &wire_chunk_message)
 
size_t writeAudio (const uint8_t *data, size_t size) override
 Writes the encoded audio data to a queue.
 
size_t writeAudioInfo (SnapAudioHeader &header)
 
bool writeHallo ()
 
bool writeMessage ()
 
bool writeTimedMessage ()
 

Static Protected Member Functions

static void task_copy ()
 static method for rtos task: make sure we constantly output audio
 

Protected Attributes

int active_percent
 
std::vector< int16_t > audio
 
SnapMessageBase base_message
 
std::vector< char > base_message_serialized
 
audio_tools::BufferRTOS< uint8_t > buffer {0}
 
int buffer_size
 
uint16_t channels = 2
 
const char * client_name = "libsnapcast"
 
uint32_t client_state_muted = 0
 
codec_type codec_from_server = NO_CODEC
 
int16_t frame_size = 512
 
bool header_received = false
 
const char * hostname = CONFIG_SNAPCAST_CLIENT_NAME
 
bool http_task_start = true
 
int id_counter = 0
 
bool is_fast_loop = false
 
bool is_time_set = false
 
uint64_t last_time_sync = 0
 
loop_status_enum loop_status = LoopStart
 
const char * mac_address = "00-00-00-00-00"
 
timeval now
 
bool output_start = false
 
Client * p_client = nullptr
 
SnapOutputp_snap_output = nullptr
 
std::vector< char > send_receive_buffer
 
IPAddress server_ip
 
int server_port = CONFIG_SNAPCAST_SERVER_PORT
 
SnapMessageServerSettings server_settings_message
 
int size = 0
 
audio_tools::QueueRTOS< size_t > size_queue {0}
 
SnapTimesnap_time = SnapTime::instance()
 
char * start = nullptr
 
const char * TAG = "SnapProcessorRTOS"
 
audio_tools::Task task {"output", RTOS_STACK_SIZE, RTOS_TASK_PRIORITY, 1}
 
bool task_started = false
 
SnapMessageTime time_message
 

Static Protected Attributes

static SnapProcessorRTOSself = nullptr
 

Detailed Description

Processor for which the encoded output is buffered in a queue in order to prevent any buffer underruns. A RTOS task feeds the output from the queue.

Author
Phil Schatzmann
Version
0.1
Date
2024-02-26

The documentation for this class was generated from the following file: