source: golgotha/src/i4/sound/linux/linux_sound.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef LINUX_SOUND_HH
10#define LINUX_SOUND_HH
11
12#include "sound/sound.hh"
13#include "math/fixed_point.hh"
14#include <pthread.h>
15
16typedef i4_fixed_point<10> linux_sound_index;
17enum { LINUX_SOUND_NUM_VOICE = 8 };
18
19class linux_sample_class
20{
21public:
22  w8 *data;
23  linux_sound_index sample_rate;
24  linux_sound_index size;
25};
26
27class linux_sound_class;
28
29class linux_voice_class : public i4_voice_class
30{
31public:
32  linux_sound_index index;
33  linux_sound_index increment;
34  w16 volume;
35  sw16 pan;
36  w16 left_vol,right_vol;
37  i4_bool looping, active;
38  linux_sample_class *sound;
39
40  linux_voice_class() : sound(0) {}
41
42  ~linux_voice_class() {}
43
44  virtual void stop() = 0;
45  virtual void play();
46  virtual void set_frequency(i4_frequency freq);
47  virtual void set_volume(i4_volume vol);
48  virtual void set_pan(i4_pan pan);
49};
50
51class linux_sound_class : public i4_sound_manager_class
52{
53  friend void *linux_sound_mixer(void *arg);
54protected:
55  int fd;
56  linux_sample_class *sound;
57  linux_voice_class voice[LINUX_SOUND_NUM_VOICE];
58  int thread_state;
59
60  void start_thread();
61  void stop_thread();
62
63  void initialize_volume_table();
64public:
65  I4_SOUND_NAME("Linux Sound");
66 
67  virtual void init();
68  virtual void uninit() { stop_thread(); }
69
70  virtual void load_sounds(w32 max_sounds);
71
72  virtual i4_voice_class *alloc(i4_sound_id sound_id, const sound_parameters& param);
73};
74extern linux_sound_class linux_sound;
75
76#endif
77
78//{{{ Emacs Locals
79// Local Variables:
80// folded-file: t
81// End:
82//}}}
Note: See TracBrowser for help on using the repository browser.