29 #include <soundcard.h>
31 #include <sys/soundcard.h>
35 #include <sys/ioctl.h>
37 #include <sys/select.h>
45 #define AUDIO_BLOCK_SIZE 4096
54 unsigned int flip_left : 1;
64 char *
flip = getenv(
"AUDIO_FLIP_LEFT");
67 audio_fd = open(audio_device, O_WRONLY);
69 audio_fd = open(audio_device, O_RDONLY);
75 if (flip && *flip ==
'1') {
81 fcntl(audio_fd, F_SETFL, O_NONBLOCK);
86 err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
89 if (tmp & AFMT_S16_BE) {
91 }
else if (tmp & AFMT_S16_LE) {
97 if (tmp & AFMT_S16_LE) {
99 }
else if (tmp & AFMT_S16_BE) {
118 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
125 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
132 err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
175 uint8_t *buf= pkt->
data;
186 if (ret < 0 && (errno != EAGAIN && errno != EINTR))
238 struct audio_buf_info abufi;
247 if (ret<0)
return AVERROR(errno);
255 if (ioctl(s->
fd, SNDCTL_DSP_GETISPACE, &abufi) == 0) {
256 bdelay += abufi.bytes;
266 short *p = (
short *) pkt->
data;
268 for (i = 0; i < ret; i += 4) {
291 static const AVClass oss_demuxer_class = {
306 .priv_class = &oss_demuxer_class,
310 #if CONFIG_OSS_OUTDEV
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
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_header(AVFormatContext *s1)
static int audio_write_trailer(AVFormatContext *s1)
static int audio_read_close(AVFormatContext *s1)
static int read_header(FFV1Context *f)
void av_free_packet(AVPacket *pkt)
Free a packet.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static int audio_open(AVFormatContext *s1, int is_output, const char *audio_device)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
AVCodecContext * codec
codec context
char filename[1024]
input or output filename
static int audio_close(AudioData *s)
static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
uint8_t buffer[AUDIO_BLOCK_SIZE]
enum AVMediaType codec_type
int sample_rate
samples per second
static const OptionDef options[]
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
static void flip(AVCodecContext *avctx, AVPicture *picture)
CodecID
Identify the syntax and semantics of the bitstream.
int channels
number of audio channels
void * priv_data
Format private data.
static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t av_gettime(void)
Get the current time in microseconds.