Blame axfer/frame-cache.h

Packit Service a9274b
// SPDX-License-Identifier: GPL-2.0
Packit Service a9274b
//
Packit Service a9274b
// frame-cache.h - maintainer of cache for data frame.
Packit Service a9274b
//
Packit Service a9274b
// Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
Packit Service a9274b
//
Packit Service a9274b
// Licensed under the terms of the GNU General Public License, version 2.
Packit Service a9274b
Packit Service a9274b
#include <alsa/asoundlib.h>
Packit Service a9274b
Packit Service a9274b
struct frame_cache {
Packit Service a9274b
	void *buf;
Packit Service a9274b
	void *buf_ptr;
Packit Service a9274b
Packit Service a9274b
	unsigned int remained_count;
Packit Service a9274b
Packit Service a9274b
	snd_pcm_access_t access;
Packit Service a9274b
	unsigned int bytes_per_sample;
Packit Service a9274b
	unsigned int samples_per_frame;
Packit Service a9274b
	unsigned int frames_per_cache;
Packit Service a9274b
Packit Service a9274b
	void (*align_frames)(struct frame_cache *cache,
Packit Service a9274b
			     unsigned int consumed_count);
Packit Service a9274b
};
Packit Service a9274b
Packit Service a9274b
int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access,
Packit Service a9274b
		     unsigned int bytes_per_sample,
Packit Service a9274b
		     unsigned int samples_per_frame,
Packit Service a9274b
		     unsigned int frames_per_cache);
Packit Service a9274b
void frame_cache_destroy(struct frame_cache *cache);
Packit Service a9274b
Packit Service a9274b
static inline unsigned int frame_cache_get_count(struct frame_cache *cache)
Packit Service a9274b
{
Packit Service a9274b
	return cache->remained_count;
Packit Service a9274b
}
Packit Service a9274b
Packit Service a9274b
static inline void frame_cache_increase_count(struct frame_cache *cache,
Packit Service a9274b
					      unsigned int frame_count)
Packit Service a9274b
{
Packit Service a9274b
	cache->remained_count += frame_count;
Packit Service a9274b
}
Packit Service a9274b
Packit Service a9274b
static inline void frame_cache_reduce(struct frame_cache *cache,
Packit Service a9274b
				      unsigned int consumed_count)
Packit Service a9274b
{
Packit Service a9274b
	cache->align_frames(cache, consumed_count);
Packit Service a9274b
}