paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Enumerations | Functions
check_wav.c File Reference

Detect and delete a wav header. More...

#include <regex.h>
#include "para.h"
#include "string.h"
#include "list.h"
#include "sched.h"
#include "buffer_tree.h"
#include "error.h"
#include "check_wav.h"
#include "portable_io.h"

Macros

#define WAV_HEADER_LEN   44
 Length of a standard wav header. More...
 

Enumerations

enum  check_wav_state { CWS_NEED_HEADER, CWS_HAVE_HEADER, CWS_NO_HEADER }
 The possible states of a check_wav instance. More...
 

Functions

void check_wav_pre_monitor (struct sched *s, struct check_wav_context *cwc)
 Request a minimal timeout if not idle. More...
 
int check_wav_post_monitor (struct check_wav_context *cwc)
 Filter out the wav header, pushdown everything else. More...
 
struct check_wav_context * check_wav_init (struct btr_node *parent, struct btr_node *child, struct wav_params *params, struct btr_node **cw_btrn)
 Allocate and set up a new check_wav instance. More...
 
void check_wav_shutdown (struct check_wav_context *cwc)
 Dellocate all ressources of a check_wav instance. More...
 

Detailed Description

Detect and delete a wav header.

Macro Definition Documentation

◆ WAV_HEADER_LEN

#define WAV_HEADER_LEN   44

Length of a standard wav header.

Enumeration Type Documentation

◆ check_wav_state

The possible states of a check_wav instance.

Enumerator
CWS_NEED_HEADER 

Initial state, less than WAV_HEADER_LEN bytes available.

CWS_HAVE_HEADER 

Wav hader was detected.

CWS_NO_HEADER 

First part of the stream did not look like a wav header.

Function Documentation

◆ check_wav_pre_monitor()

void check_wav_pre_monitor ( struct sched s,
struct check_wav_context *  cwc 
)

Request a minimal timeout if not idle.

Parameters
sThe scheduler instance.
cwcThe buffer tree node is derived from this.

If no data is available and the buffer tree node is not in error state, the function does nothing.

References btr_node_status(), BTR_NT_INTERNAL, and sched_min_delay().

◆ check_wav_post_monitor()

int check_wav_post_monitor ( struct check_wav_context *  cwc)

Filter out the wav header, pushdown everything else.

Parameters
cwcThe context of this instance.

This function looks at the first WAV_HEADER_SIZE bytes of the input queue of the btrn of cwc. If they look like a wav header, the function extracts the information of interest and swallows this part of the stream. Otherwise it is pushed down to all children. In either case the rest of the input is pushed down as well.

Once the first part has been processed this way, the state of the instance changes from CWS_NEED_HEADER to CWS_HAVE_HEADER or CWS_NO_HEADER.

Returns
Standard.

References btr_merge(), btr_next_buffer(), btr_node_status(), BTR_NT_INTERNAL, CWS_HAVE_HEADER, CWS_NEED_HEADER, CWS_NO_HEADER, PARA_INFO_LOG, PARA_NOTICE_LOG, and SAMPLE_FORMATS.

◆ check_wav_init()

struct check_wav_context* check_wav_init ( struct btr_node *  parent,
struct btr_node *  child,
struct wav_params params,
struct btr_node **  cw_btrn 
)

Allocate and set up a new check_wav instance.

Parameters
parentThis buffer tree node will be the parent of the new node.
childThe child of the new node.
paramsDefault values and options.
cw_btrnA pointer to the check wav node is returned here.

This function also sets up the ->execute handler of the btrn so that all children of this node can figure out channel count, sample rate, etc.

Returns
The (opaque) handle of the newly created check_wav instance. It is supposed to be passed to check_wav_pre_monitor() and check_wav_post_monitor().
See also
btr_new_node.

References btr_new_node(), CWS_NEED_HEADER, EMBRACE, WAV_HEADER_LEN, and zalloc().

◆ check_wav_shutdown()

void check_wav_shutdown ( struct check_wav_context *  cwc)

Dellocate all ressources of a check_wav instance.

Parameters
cwcDetermines the instance to shut down.

This function may only be called after check_wav_post_monitor() has returned negative.