idirectfbdatabuffer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __IDIRECTFBDATABUFFER_H__
  24. #define __IDIRECTFBDATABUFFER_H__
  25. #include <core/core.h>
  26. /*
  27. * private data struct of IDirectFBDataBuffer
  28. */
  29. typedef struct {
  30. int ref; /* reference counter */
  31. char *filename; /* Only set if databuffer is created from file. */
  32. CoreDFB *core;
  33. bool is_memory;
  34. } IDirectFBDataBuffer_data;
  35. /*
  36. * private data struct of IDirectFBDataBuffer_File
  37. */
  38. typedef struct {
  39. IDirectFBDataBuffer_data base;
  40. DirectStream *stream;
  41. pthread_mutex_t mutex;
  42. } IDirectFBDataBuffer_File_data;
  43. /*
  44. * private data struct of IDirectFBDataBuffer_Memory
  45. */
  46. typedef struct {
  47. IDirectFBDataBuffer_data base;
  48. const void *buffer;
  49. unsigned int length;
  50. unsigned int pos;
  51. } IDirectFBDataBuffer_Memory_data;
  52. /*
  53. * base constructor
  54. *
  55. * If the databuffer is created for a file, the filename can be provided
  56. * for fallbacks.
  57. */
  58. DFBResult IDirectFBDataBuffer_Construct( IDirectFBDataBuffer *thiz,
  59. const char *filename,
  60. CoreDFB *core );
  61. /*
  62. * base destructor
  63. */
  64. void IDirectFBDataBuffer_Destruct( IDirectFBDataBuffer *thiz );
  65. /*
  66. * generic streamed data buffer
  67. */
  68. DFBResult IDirectFBDataBuffer_Streamed_Construct( IDirectFBDataBuffer *thiz,
  69. CoreDFB *core );
  70. /*
  71. * file based static data buffer
  72. */
  73. DFBResult IDirectFBDataBuffer_File_Construct( IDirectFBDataBuffer *thiz,
  74. const char *filename,
  75. CoreDFB *core );
  76. /*
  77. * memory based static data buffer
  78. */
  79. DFBResult IDirectFBDataBuffer_Memory_Construct( IDirectFBDataBuffer *thiz,
  80. const void *data,
  81. unsigned int length,
  82. CoreDFB *core );
  83. #endif