ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/audio_oss_esd.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/audio_oss_esd.cpp (file contents):
Revision 1.14 by gbeauche, 2002-10-03T15:47:59Z vs.
Revision 1.15 by cebix, 2002-10-15T16:25:04Z

# Line 31 | Line 31
31   #endif
32  
33   #ifdef __FreeBSD__
34 < #include <sys/soundcard.h>
34 > #include <machine/soundcard.h>
35   #endif
36  
37   #include "cpu_emulation.h"
# Line 54 | Line 54 | static int audio_sample_rate_index = 0;
54   static int audio_sample_size_index = 0;
55   static int audio_channel_count_index = 0;
56  
57 // Constants
58 #define DSP_NAME "/dev/dsp"
59
57   // Global variables
58 < static int audio_fd = -1;                                                       // fd of /dev/dsp or ESD
59 < static int mixer_fd = -1;                                                       // fd of /dev/mixer
58 > static int audio_fd = -1;                                                       // fd of dsp or ESD
59 > static int mixer_fd = -1;                                                       // fd of mixer
60   static sem_t audio_irq_done_sem;                                        // Signal from interrupt to streaming thread: data block read
61   static bool sem_inited = false;                                         // Flag: audio_irq_done_sem initialized
62   static int sound_buffer_size;                                           // Size of sound buffer in bytes
# Line 86 | Line 83 | static void set_audio_status_format(void
83          AudioStatus.channels = audio_channel_counts[audio_channel_count_index];
84   }
85  
86 < // Init using /dev/dsp, returns false on error
86 > // Init using the dsp device, returns false on error
87   static bool open_dsp(void)
88   {
89 <        // Open /dev/dsp
90 <        audio_fd = open(DSP_NAME, O_WRONLY);
89 >        // Open the device
90 >        const char *dsp = PrefsFindString("dsp");
91 >        audio_fd = open(dsp, O_WRONLY);
92          if (audio_fd < 0) {
93 <                fprintf(stderr, "WARNING: Cannot open %s (%s)\n", DSP_NAME, strerror(errno));
93 >                fprintf(stderr, "WARNING: Cannot open %s (%s)\n", dsp, strerror(errno));
94                  return false;
95          }
96  
97 <        printf("Using " DSP_NAME " audio output\n");
97 >        printf("Using %s audio output\n", dsp);
98  
99          // Get supported sample formats
100          if (audio_sample_sizes.empty()) {
# Line 213 | Line 211 | static bool open_esd(void)
211  
212                  // The reason we do this here is that we don't want to add sample
213                  // rates etc. unless the ESD server connection could be opened
214 <                // (if ESD fails, /dev/dsp might be tried next)
214 >                // (if ESD fails, dsp might be tried next)
215                  audio_sample_rates.push_back(11025 << 16);
216                  audio_sample_rates.push_back(22050 << 16);
217                  audio_sample_rates.push_back(44100 << 16);
# Line 246 | Line 244 | static bool open_audio(void)
244                          goto dev_opened;
245   #endif
246  
247 <        // Try to open /dev/dsp
247 >        // Try to open dsp
248          if (open_dsp())
249                  goto dev_opened;
250  
251   #ifdef ENABLE_ESD
252 <        // Hm, /dev/dsp failed so we try ESD again if ESPEAKER wasn't set
252 >        // Hm, dsp failed so we try ESD again if ESPEAKER wasn't set
253          if (!getenv("ESPEAKER"))
254                  if (open_esd())
255                          goto dev_opened;
# Line 294 | Line 292 | void AudioInit(void)
292                  return;
293          sem_inited = true;
294  
295 <        // Try to open /dev/mixer
296 <        mixer_fd = open("/dev/mixer", O_RDWR);
295 >        // Try to open the mixer device
296 >        const char *mixer = PrefsFindString("mixer");
297 >        mixer_fd = open(mixer, O_RDWR);
298          if (mixer_fd < 0)
299 <                printf("WARNING: Cannot open /dev/mixer (%s)", strerror(errno));
299 >                printf("WARNING: Cannot open %s (%s)\n", mixer, strerror(errno));
300  
301          // Open and initialize audio device
302          open_audio();
# Line 320 | Line 319 | static void close_audio(void)
319                  stream_thread_active = false;
320          }
321  
322 <        // Close /dev/dsp or ESD socket
322 >        // Close dsp or ESD socket
323          if (audio_fd >= 0) {
324                  close(audio_fd);
325                  audio_fd = -1;
# Line 340 | Line 339 | void AudioExit(void)
339                  sem_inited = false;
340          }
341  
342 <        // Close /dev/mixer
342 >        // Close mixer device
343          if (mixer_fd >= 0) {
344                  close(mixer_fd);
345                  mixer_fd = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines