freebsd-dev/usr.sbin/bhyve/audio.h
Marcelo Araujo 3e21da8ad1 Add SPDX tags to bhyve(8) HD Audio device.
Reviewed by:	bcran
Differential Revision:	https://reviews.freebsd.org/D20750
2019-06-25 06:24:56 +00:00

89 lines
2.9 KiB
C

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _AUDIO_EMUL_H_
#define _AUDIO_EMUL_H_
#include <sys/types.h>
#include <sys/soundcard.h>
/*
* Audio Player data structures
*/
struct audio;
struct audio_params {
int channels;
int format;
int rate;
};
/*
* Audio Player API
*/
/*
* audio_init - initialize an instance of audio player
* @dev_name - the backend sound device used to play / capture
* @dir - dir = 1 for write mode, dir = 0 for read mode
* Returns NULL on error and the address of the audio player instance
*/
struct audio *audio_init(const char *dev_name, uint8_t dir);
/*
* audio_set_params - reset the sound device and set the audio params
* @aud - the audio player to be configured
* @params - the audio parameters to be set
* Returns -1 on error and 0 on success
*/
int audio_set_params(struct audio *aud, struct audio_params *params);
/*
* audio_playback - plays samples to the sound device using blocking operations
* @aud - the audio player used to play the samples
* @buf - the buffer containing the samples
* @count - the number of bytes in buffer
* Returns -1 on error and 0 on success
*/
int audio_playback(struct audio *aud, const void *buf, size_t count);
/*
* audio_record - records samples from the sound device using blocking
* operations.
* @aud - the audio player used to capture the samples
* @buf - the buffer to receive the samples
* @count - the number of bytes to capture in buffer
* Returns -1 on error and 0 on success
*/
int audio_record(struct audio *aud, void *buf, size_t count);
#endif /* _AUDIO_EMUL_H_ */