mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-14 05:25:43 +01:00
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
|
// SPDX-License-Identifier: GPL-2.0
|
||
|
//
|
||
|
// frame-cache.h - maintainer of cache for data frame.
|
||
|
//
|
||
|
// Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
|
||
|
//
|
||
|
// Licensed under the terms of the GNU General Public License, version 2.
|
||
|
|
||
|
#include <alsa/asoundlib.h>
|
||
|
|
||
|
struct frame_cache {
|
||
|
void *buf;
|
||
|
void *buf_ptr;
|
||
|
|
||
|
unsigned int remained_count;
|
||
|
|
||
|
snd_pcm_access_t access;
|
||
|
unsigned int bytes_per_sample;
|
||
|
unsigned int samples_per_frame;
|
||
|
unsigned int frames_per_cache;
|
||
|
|
||
|
void (*align_frames)(struct frame_cache *cache,
|
||
|
unsigned int consumed_count);
|
||
|
};
|
||
|
|
||
|
int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access,
|
||
|
unsigned int bytes_per_sample,
|
||
|
unsigned int samples_per_frame,
|
||
|
unsigned int frames_per_cache);
|
||
|
void frame_cache_destroy(struct frame_cache *cache);
|
||
|
|
||
|
static inline unsigned int frame_cache_get_count(struct frame_cache *cache)
|
||
|
{
|
||
|
return cache->remained_count;
|
||
|
}
|
||
|
|
||
|
static inline void frame_cache_increase_count(struct frame_cache *cache,
|
||
|
unsigned int frame_count)
|
||
|
{
|
||
|
cache->remained_count += frame_count;
|
||
|
}
|
||
|
|
||
|
static inline void frame_cache_reduce(struct frame_cache *cache,
|
||
|
unsigned int consumed_count)
|
||
|
{
|
||
|
cache->align_frames(cache, consumed_count);
|
||
|
}
|