You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.6KB

  1. /*
  2. * ALSA input and output
  3. * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
  4. * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file alsa-audio.h
  24. * ALSA input and output: definitions and structures
  25. * @author Luca Abeni ( lucabe72 email it )
  26. * @author Benoit Fouet ( benoit fouet free fr )
  27. */
  28. #ifndef AVDEVICE_ALSA_AUDIO_H
  29. #define AVDEVICE_ALSA_AUDIO_H
  30. /* XXX: we make the assumption that the soundcard accepts this format */
  31. /* XXX: find better solution with "preinit" method, needed also in
  32. other formats */
  33. #ifdef WORDS_BIGENDIAN
  34. #define DEFAULT_CODEC_ID CODEC_ID_PCM_S16BE
  35. #else
  36. #define DEFAULT_CODEC_ID CODEC_ID_PCM_S16LE
  37. #endif
  38. typedef struct {
  39. snd_pcm_t *h;
  40. int frame_size; ///< preferred size for reads and writes
  41. int period_size; ///< bytes per sample * channels
  42. } AlsaData;
  43. /**
  44. * Opens an ALSA PCM.
  45. *
  46. * @param s media file handle
  47. * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
  48. * @param sample_rate in: requested sample rate;
  49. * out: actually selected sample rate
  50. * @param channels number of channels
  51. * @param codec_id in: requested CodecID or CODEC_ID_NONE;
  52. * out: actually selected CodecID, changed only if
  53. * CODEC_ID_NONE was requested
  54. *
  55. * @return 0 if OK, AVERROR_xxx on error
  56. */
  57. int ff_alsa_open(AVFormatContext *s, int mode, unsigned int *sample_rate,
  58. int channels, int *codec_id);
  59. /**
  60. * Closes the ALSA PCM.
  61. *
  62. * @param s1 media file handle
  63. *
  64. * @return 0
  65. */
  66. int ff_alsa_close(AVFormatContext *s1);
  67. /**
  68. * Tries to recover from ALSA buffer underrun.
  69. *
  70. * @param s1 media file handle
  71. * @param err error code reported by the previous ALSA call
  72. *
  73. * @return 0 if OK, AVERROR_xxx on error
  74. */
  75. int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
  76. #endif /* AVDEVICE_ALSA_AUDIO_H */