view DOCS/tech/libao2.txt @ 23572:a00685941686

demux_mkv very long seek fix The seek code searching for the closest position in the index used "int64_t min_diff=0xFFFFFFFL" as the initial "further from the goal than any real alternative" value. The unit is milliseconds so seeks more than about 75 hours past the end of the file would fail to recognize the last index position as the best match. This was triggered in practice by chapter seek code which apparently uses a seek of 1000000000 seconds forward to mean "seek to the end". The practical effect was that trying to seek to the next chapter in a file without chapters made MPlayer block until it finished reading the file from the current position to the end. Fixed by increasing the initial value from FFFFFFF to FFFFFFFFFFFFFFF.
author uau
date Wed, 20 Jun 2007 18:19:03 +0000
parents 5c6111664933
children eda346733b8c
line wrap: on
line source

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();
  Guess what.
  Ok I help: closes the device, not (yet) called when exit.

static void reset();
  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();
  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(); 
  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().