Paraslash Audio Streaming | |
About News Download Documentation Development |
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... | |
Detect and delete a wav header.
#define WAV_HEADER_LEN 44 |
Length of a standard wav header.
enum check_wav_state |
void check_wav_pre_monitor | ( | struct sched * | s, |
struct check_wav_context * | cwc | ||
) |
Request a minimal timeout if not idle.
s | The scheduler instance. |
cwc | The 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().
int check_wav_post_monitor | ( | struct check_wav_context * | cwc | ) |
Filter out the wav header, pushdown everything else.
cwc | The 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
.
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.
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.
parent | This buffer tree node will be the parent of the new node. |
child | The child of the new node. |
params | Default values and options. |
cw_btrn | A 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.
References btr_new_node(), CWS_NEED_HEADER, EMBRACE, WAV_HEADER_LEN, and zalloc().
void check_wav_shutdown | ( | struct check_wav_context * | cwc | ) |
Dellocate all ressources of a check_wav instance.
cwc | Determines the instance to shut down. |
This function may only be called after check_wav_post_monitor() has returned negative.