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