29 #include <soundcard.h>
31 #include <sys/soundcard.h>
35 #include <sys/ioctl.h>
44 #define AUDIO_BLOCK_SIZE 4096
53 unsigned int flip_left : 1;
63 char *
flip = getenv(
"AUDIO_FLIP_LEFT");
66 audio_fd = open(audio_device, O_WRONLY);
68 audio_fd = open(audio_device, O_RDONLY);
74 if (flip && *flip ==
'1') {
80 fcntl(audio_fd, F_SETFL, O_NONBLOCK);
85 err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
88 if (tmp & AFMT_S16_BE) {
90 }
else if (tmp & AFMT_S16_LE) {
96 if (tmp & AFMT_S16_LE) {
98 }
else if (tmp & AFMT_S16_BE) {
117 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
124 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
131 err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
185 if (ret < 0 && (errno != EAGAIN && errno != EINTR))
237 struct audio_buf_info abufi;
246 if (ret<0)
return AVERROR(errno);
254 if (ioctl(s->
fd, SNDCTL_DSP_GETISPACE, &abufi) == 0) {
255 bdelay += abufi.bytes;
265 short *p = (
short *) pkt->
data;
267 for (i = 0; i < ret; i += 4) {
290 static const AVClass oss_demuxer_class = {
305 .priv_class = &oss_demuxer_class,
309 #if CONFIG_OSS_OUTDEV
void av_free_packet(AVPacket *pkt)
Free a packet.
Audio buffer used for intermediate storage between conversion phases.
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)
struct AudioData AudioData
Audio buffer used for intermediate storage between conversion phases.
static av_cold int read_close(AVFormatContext *ctx)
static int audio_open(AVFormatContext *s1, int is_output, const char *audio_device)
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.
int channels
channel count
#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 associated with this stream.
char filename[1024]
input or output filename
static int audio_close(AudioData *s)
static int read_header(FFV1Context *f)
int64_t av_gettime(void)
Get the current time in microseconds.
uint8_t buffer[AUDIO_BLOCK_SIZE]
enum AVMediaType codec_type
static int audio_read_header(AVFormatContext *s1)
int sample_rate
samples per second
#define AV_OPT_FLAG_DECODING_PARAM
static void close(AVCodecParserContext *s)
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.
const OptionDef options[]
static void flip(AVCodecContext *avctx, AVPicture *picture)
int channels
number of audio channels
void * priv_data
Format private data.
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...