scache.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef fooscachehfoo
  2. #define fooscachehfoo
  3. /***
  4. This file is part of PulseAudio.
  5. Copyright 2004-2006 Lennart Poettering
  6. Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
  7. PulseAudio is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU Lesser General Public License as published
  9. by the Free Software Foundation; either version 2.1 of the License,
  10. or (at your option) any later version.
  11. PulseAudio is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public License
  16. along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
  17. ***/
  18. #include <sys/types.h>
  19. #include <pulse/context.h>
  20. #include <pulse/stream.h>
  21. #include <pulse/cdecl.h>
  22. #include <pulse/version.h>
  23. /** \page scache Sample Cache
  24. *
  25. * \section overv_sec Overview
  26. *
  27. * The sample cache provides a simple way of overcoming high network latencies
  28. * and reducing bandwidth. Instead of streaming a sound precisely when it
  29. * should be played, it is stored on the server and only the command to start
  30. * playing it needs to be sent.
  31. *
  32. * \section create_sec Creation
  33. *
  34. * To create a sample, the normal stream API is used (see \ref streams). The
  35. * function pa_stream_connect_upload() will make sure the stream is stored as
  36. * a sample on the server.
  37. *
  38. * To complete the upload, pa_stream_finish_upload() is called and the sample
  39. * will receive the same name as the stream. If the upload should be aborted,
  40. * simply call pa_stream_disconnect().
  41. *
  42. * \section play_sec Playing samples
  43. *
  44. * To play back a sample, simply call pa_context_play_sample():
  45. *
  46. * \code
  47. * pa_operation *o;
  48. *
  49. * o = pa_context_play_sample(my_context,
  50. * "sample2", // Name of my sample
  51. * NULL, // Use default sink
  52. * PA_VOLUME_NORM, // Full volume
  53. * NULL, // Don't need a callback
  54. * NULL
  55. * );
  56. * if (o)
  57. * pa_operation_unref(o);
  58. * \endcode
  59. *
  60. * \section rem_sec Removing samples
  61. *
  62. * When a sample is no longer needed, it should be removed on the server to
  63. * save resources. The sample is deleted using pa_context_remove_sample().
  64. */
  65. /** \file
  66. * All sample cache related routines
  67. *
  68. * See also \subpage scache
  69. */
  70. PA_C_DECL_BEGIN
  71. /** Callback prototype for pa_context_play_sample_with_proplist(). The
  72. * idx value is the index of the sink input object, or
  73. * PA_INVALID_INDEX on failure. \since 0.9.11 */
  74. typedef void (*pa_context_play_sample_cb_t)(pa_context *c, uint32_t idx, void *userdata);
  75. /** Make this stream a sample upload stream */
  76. int pa_stream_connect_upload(pa_stream *s, size_t length);
  77. /** Finish the sample upload, the stream name will become the sample
  78. * name. You cancel a sample upload by issuing
  79. * pa_stream_disconnect() */
  80. int pa_stream_finish_upload(pa_stream *s);
  81. /** Remove a sample from the sample cache. Returns an operation object which may be used to cancel the operation while it is running */
  82. pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata);
  83. /** Play a sample from the sample cache to the specified device. If
  84. * the latter is NULL use the default sink. Returns an operation
  85. * object */
  86. pa_operation* pa_context_play_sample(
  87. pa_context *c /**< Context */,
  88. const char *name /**< Name of the sample to play */,
  89. const char *dev /**< Sink to play this sample on */,
  90. pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,
  91. pa_context_success_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
  92. void *userdata /**< Userdata to pass to the callback */);
  93. /** Play a sample from the sample cache to the specified device,
  94. * allowing specification of a property list for the playback
  95. * stream. If the latter is NULL use the default sink. Returns an
  96. * operation object. \since 0.9.11 */
  97. pa_operation* pa_context_play_sample_with_proplist(
  98. pa_context *c /**< Context */,
  99. const char *name /**< Name of the sample to play */,
  100. const char *dev /**< Sink to play this sample on */,
  101. pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,
  102. pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will be merged into this property list */,
  103. pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
  104. void *userdata /**< Userdata to pass to the callback */);
  105. PA_C_DECL_END
  106. #endif