seq_fifo.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA sequencer FIFO
  4. * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  5. */
  6. #ifndef __SND_SEQ_FIFO_H
  7. #define __SND_SEQ_FIFO_H
  8. #include "seq_memory.h"
  9. #include "seq_lock.h"
  10. /* === FIFO === */
  11. struct snd_seq_fifo {
  12. struct snd_seq_pool *pool; /* FIFO pool */
  13. struct snd_seq_event_cell *head; /* pointer to head of fifo */
  14. struct snd_seq_event_cell *tail; /* pointer to tail of fifo */
  15. int cells;
  16. spinlock_t lock;
  17. snd_use_lock_t use_lock;
  18. wait_queue_head_t input_sleep;
  19. atomic_t overflow;
  20. };
  21. /* create new fifo (constructor) */
  22. struct snd_seq_fifo *snd_seq_fifo_new(int poolsize);
  23. /* delete fifo (destructor) */
  24. void snd_seq_fifo_delete(struct snd_seq_fifo **f);
  25. /* enqueue event to fifo */
  26. int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event);
  27. /* lock fifo from release */
  28. #define snd_seq_fifo_lock(fifo) snd_use_lock_use(&(fifo)->use_lock)
  29. #define snd_seq_fifo_unlock(fifo) snd_use_lock_free(&(fifo)->use_lock)
  30. /* get a cell from fifo - fifo should be locked */
  31. int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, struct snd_seq_event_cell **cellp, int nonblock);
  32. /* free dequeued cell - fifo should be locked */
  33. void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, struct snd_seq_event_cell *cell);
  34. /* clean up queue */
  35. void snd_seq_fifo_clear(struct snd_seq_fifo *f);
  36. /* polling */
  37. int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, poll_table *wait);
  38. /* resize pool in fifo */
  39. int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize);
  40. /* get the number of unused cells safely */
  41. int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f);
  42. #endif