mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-09-19 17:49:59 +02:00
d28f9def97
In ALSA PCM interface, two parameters are used for size of intermediate buffer for data frames; period size and buffer size. Actual effects of these sizes differs depending on hardware, but basically the size of period is used for intervals of hardware interrupts and the size of buffer is used to maintain the intermediate buffer as ring buffer. These parameters can be configured as a part of hardware parameters by data frame unit or micro second. PCM API in alsa-lib also includes helper functions to configure them by the two units. This commit adds support for options to the parameters by both units. When no options are given, default values are applied according to current aplay; available maximum size of buffer up to 500msec, a quarter of the size of buffer for period size. However, these calculation should be reconsidered somehow. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
64 lines
1.5 KiB
C
64 lines
1.5 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;
|
|
|
|
unsigned int msec_per_period;
|
|
unsigned int msec_per_buffer;
|
|
unsigned int frames_per_period;
|
|
unsigned int frames_per_buffer;
|
|
|
|
bool finish_at_xrun:1;
|
|
bool nonblock:1;
|
|
bool mmap:1;
|
|
bool test_nowait:1;
|
|
|
|
bool use_waiter: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
|