alsa-utils/axfer/xfer-libasound.h
Takashi Sakamoto b5d2fadfb1 axfer: add support for MMAP PCM operation
In alsa-lib PCM API, data frames can be handled in mapped page frame,
instead of calling any system calls.

This commit support for this type of operation. To reduce CPU usage,
this commit uses 'snd_pcm_wait()' to wait for event notification.

Below lines are examples to execute:
$ axfer transfer -M -P -d 2 -D hw:0,3 /dev/urandom -f dat -vvv
$ axfer transfer -M -C -d 2 -D hw:1,0 /dev/null -r 48000 -vvv

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-11-13 12:04:37 +01:00

56 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-2.0
//
// xfer-libasound.h - a header for receiver/transmitter of frames by alsa-lib.
//
// Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
//
// Licensed under the terms of the GNU General Public License, version 2.
#ifndef __ALSA_UTILS_AXFER_XFER_LIBASOUND__H_
#define __ALSA_UTILS_AXFER_XFER_LIBASOUND__H_
#include "xfer.h"
#define logging(state, ...) \
snd_output_printf(state->log, __VA_ARGS__)
struct xfer_libasound_ops;
struct libasound_state {
snd_pcm_t *handle;
snd_output_t *log;
snd_pcm_hw_params_t *hw_params;
snd_pcm_sw_params_t *sw_params;
const struct xfer_libasound_ops *ops;
void *private_data;
bool verbose;
char *node_literal;
bool finish_at_xrun:1;
bool nonblock:1;
bool mmap:1;
};
// For internal use in 'libasound' module.
struct xfer_libasound_ops {
int (*pre_process)(struct libasound_state *state);
int (*process_frames)(struct libasound_state *state,
unsigned int *frame_count,
struct mapper_context *mapper,
struct container_context *cntrs);
void (*post_process)(struct libasound_state *state);
unsigned int private_size;
};
extern const struct xfer_libasound_ops xfer_libasound_irq_rw_ops;
extern const struct xfer_libasound_ops xfer_libasound_irq_mmap_r_ops;
extern const struct xfer_libasound_ops xfer_libasound_irq_mmap_w_ops;
#endif