seq_fifo.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * ALSA sequencer FIFO
  3. * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef __SND_SEQ_FIFO_H
  22. #define __SND_SEQ_FIFO_H
  23. #include "seq_memory.h"
  24. #include "seq_lock.h"
  25. /* === FIFO === */
  26. struct snd_seq_fifo {
  27. struct snd_seq_pool *pool; /* FIFO pool */
  28. struct snd_seq_event_cell *head; /* pointer to head of fifo */
  29. struct snd_seq_event_cell *tail; /* pointer to tail of fifo */
  30. int cells;
  31. spinlock_t lock;
  32. snd_use_lock_t use_lock;
  33. wait_queue_head_t input_sleep;
  34. atomic_t overflow;
  35. };
  36. /* create new fifo (constructor) */
  37. struct snd_seq_fifo *snd_seq_fifo_new(int poolsize);
  38. /* delete fifo (destructor) */
  39. void snd_seq_fifo_delete(struct snd_seq_fifo **f);
  40. /* enqueue event to fifo */
  41. int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event);
  42. /* lock fifo from release */
  43. #define snd_seq_fifo_lock(fifo) snd_use_lock_use(&(fifo)->use_lock)
  44. #define snd_seq_fifo_unlock(fifo) snd_use_lock_free(&(fifo)->use_lock)
  45. /* get a cell from fifo - fifo should be locked */
  46. int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, struct snd_seq_event_cell **cellp, int nonblock);
  47. /* free dequeued cell - fifo should be locked */
  48. void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, struct snd_seq_event_cell *cell);
  49. /* clean up queue */
  50. void snd_seq_fifo_clear(struct snd_seq_fifo *f);
  51. /* polling */
  52. int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, poll_table *wait);
  53. /* resize pool in fifo */
  54. int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize);
  55. #endif