29 #include <soundcard.h>
31 #include <sys/soundcard.h>
35 #include <sys/ioctl.h>
38 #include "libavutil/log.h"
39 #include "libavutil/opt.h"
40 #include "libavutil/time.h"
41 #include "libavcodec/avcodec.h"
45 #define AUDIO_BLOCK_SIZE 4096
54 unsigned int flip_left : 1;
64 char *
flip = getenv(
"AUDIO_FLIP_LEFT");
75 if (flip && *flip ==
'1') {
81 if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
82 av_log(s1,
AV_LOG_WARNING,
"%s: Could not enable non block mode (%s)\n", audio_device, strerror(errno));
89 err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
92 if (tmp & AFMT_S16_BE) {
94 }
else if (tmp & AFMT_S16_LE) {
100 if (tmp & AFMT_S16_LE) {
102 }
else if (tmp & AFMT_S16_BE) {
121 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
128 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
135 err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
189 if (ret < 0 && (errno != EAGAIN && errno != EINTR))
241 struct audio_buf_info abufi;
250 if (ret<0)
return AVERROR(errno);
258 if (ioctl(s->
fd, SNDCTL_DSP_GETISPACE, &abufi) == 0) {
259 bdelay += abufi.bytes;
269 short *p = (
short *) pkt->
data;
271 for (i = 0; i <
ret; i += 4) {
294 static const AVClass oss_demuxer_class = {
309 .priv_class = &oss_demuxer_class,
313 #if CONFIG_OSS_OUTDEV
void av_free_packet(AVPacket *pkt)
Free a packet.
Audio buffer used for intermediate storage between conversion phases.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
AVCodecContext * codec
Codec context associated with this stream.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
const char * av_default_item_name(void *ctx)
Return the context name.
static int audio_write_header(AVFormatContext *s1)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int audio_write_trailer(AVFormatContext *s1)
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
static int audio_read_close(AVFormatContext *s1)
static av_cold int read_close(AVFormatContext *ctx)
static int audio_open(AVFormatContext *s1, int is_output, const char *audio_device)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
const OptionDef options[]
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * priv_data
Format private data.
char filename[1024]
input or output filename
int channels
channel count
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
common internal API header
int64_t av_gettime(void)
Get the current time in microseconds.
static int audio_close(AudioData *s)
static int read_header(FFV1Context *f)
uint8_t buffer[AUDIO_BLOCK_SIZE]
enum AVMediaType codec_type
static int audio_read_header(AVFormatContext *s1)
int sample_rate
samples per second
static void close(AVCodecParserContext *s)
Main libavdevice API header.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
Describe the class of an AVClass context structure.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static void flip(AVCodecContext *avctx, AVPicture *picture)
int channels
number of audio channels
static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...