1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-20 22:02:59 +00:00
mpv/DOCS/OUTDATED-tech/libao2.txt

57 lines
2.5 KiB
Plaintext
Raw Normal View History

6. libao2: this control audio playing
As in libvo (see 5.) also here are some drivers, based on the same API:
static int control(int cmd, int arg);
This is for reading/setting driver-specific and other special parameters.
Not really used for now.
static int init(int rate,int channels,int format,int flags);
The init of driver, opens device, sets sample rate, channels, sample format
parameters.
Sample format: usually AFMT_S16_LE or AFMT_U8, for more definitions see
dec_audio.c and linux/soundcards.h files!
static void uninit(void);
Guess what.
Ok I help: closes the device, not (yet) called when exit.
static void reset(void);
Resets device. To be exact, it's for deleting buffers' contents,
so after reset() the previously received stuff won't be output.
(called if pause or seek)
static int get_space(void);
Returns how many bytes can be written into the audio buffer without
blocking (making caller process wait). MPlayer occasionally checks the
remaining space and tries to fill the buffer with play() if there's free
space. The buffer size used should be sane; a buffer that is too small
could run empty before MPlayer tries filling it again (normally once per
video frame), a buffer that is too big would force MPlayer decode the file
far ahead trying to find enough audio data to fill it.
static int play(void* data,int len,int flags);
Plays a bit of audio, which is received throught the "data" memory area, with
a size of "len". It has to copy the data, because they can be overwritten
after the call is made. Doesn't have to use all the bytes; it has to
return the number of bytes used used (copied to buffer). If
flags|AOPLAY_FINAL_CHUNK is true then this is the last audio in the file.
The purpose of this flag is to tell aos that round down the audio played
from "len" to a multiple of some chunksize that this "len" should not be
rounded down to 0 or the data will never be played (as MPlayer will never
call play() with a larger len).
static float get_delay(void);
Returns how long time it will take to play the data currently in the
output buffer. Be exact, if possible, since the whole timing depends
on this! In the worst case, return the maximum delay.
!!! Because the video is synchronized to the audio (card), it's very important
!!! that the get_delay function is correctly implemented!
static void audio_pause(void);
Pause playing but do not delete buffered data if possible.
static void audio_resume(void);
Continue playing after audio_pause().