summaryrefslogtreecommitdiff
path: root/net/opal/files/patch-oss
blob: 1f8720bf55c64bb4296a194963fa2503b1da9e59 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
*** ../pwlib/src/ptlib/unix/oss.cxx.orig	Thu Dec 12 09:03:56 2002
--- ../pwlib/src/ptlib/unix/oss.cxx	Sun Feb  2 19:22:40 2003
***************
*** 27,32 ****
--- 27,45 ----
   * Contributor(s): Loopback feature: Philip Edelbrock <phil@netroedge.com>.
   *
   * $Log: oss.cxx,v $
+  * Revision 1.58  2003/02/02 18:54:22  rogerh
+  * FreeBSD changes for support of dspN.M (eg dsp0.0) sound card entries.
+  * Problem reported by Lars Eggert <larse@isi.edu>
+  *
+  * Revision 1.57  2003/01/06 19:25:07  rogerh
+  * Add NetBSD video support.
+  * Add correct includes for OSS ioctls (note the proper way to do this now
+  * is via pwlib commands)
+  * From Andreas Wrede, taken in part from NetBSD's package system
+  *
+  * Revision 1.56  2003/01/06 19:10:22  rogerh
+  * NetBSD uses /dev/audio and not /dev/dsp
+  *
   * Revision 1.55  2002/12/12 09:03:56  rogerh
   * On two FreeBSD machines, Read() calls from the sound card were not blocking
   * correctly and returned with less bytes than asked for. This made OpenH323
***************
*** 223,229 ****
  
  #ifdef P_LINUX
  #include <sys/soundcard.h>
- #include <sys/time.h>
  #endif
  
  #ifdef P_FREEBSD
--- 236,241 ----
*************** PSoundChannel::~PSoundChannel()
*** 456,468 ****
  }
  
  static BOOL IsNumericString(PString numbers) {
!   // return true if 'numbers' contains only digits 0 to 9
    for (PINDEX p = 0; p < numbers.GetLength(); p++) {
!     if (!isdigit(numbers[p])) {
!       return FALSE;
      }
    }
!   return TRUE;
  }
  
  static void CollectSoundDevices(PDirectory devdir, POrdinalToString & dsp, POrdinalToString & mixer, BOOL collect_with_names)
--- 468,485 ----
  }
  
  static BOOL IsNumericString(PString numbers) {
!   // return true if 'numbers' contains only digits (0 to 9)
!   // or if it contains digits followed by a '.'
! 
!   BOOL isNumber = FALSE;
    for (PINDEX p = 0; p < numbers.GetLength(); p++) {
!     if (isdigit(numbers[p])) {
!       isNumber = TRUE;
!     } else {
!       return isNumber;
      }
    }
!   return isNumber;
  }
  
  static void CollectSoundDevices(PDirectory devdir, POrdinalToString & dsp, POrdinalToString & mixer, BOOL collect_with_names)
*************** static void CollectSoundDevices(PDirecto
*** 499,520 ****
          // On Linux devfs systems, the major numbers can change dynamically.
  	// On FreeBSD and other OSs, the major numbes are different to Linux.
  	// So collect devices by looking for dsp(N) and mixer(N).
! 	// Notes. FreeBSD supports audio stream mixing. For /dev/dsp0
! 	// there are also entries for /dev/dsp0.0 dsp0.1 dsp0.2 and dsp0.3
! 	// We will ignore these N.M devices.
  
          // Look for dsp
          if (filename == "dsp") {
            dsp.SetAt(0, devname);
          }
!         // Look for dspN. Insert at position cardnum + 1
          if ((filename.GetLength() > 3) && (filename.Left(3) == "dsp")) {
  	  PString numbers = filename.Mid(3); // get everything after 'dsp'
  	  if (IsNumericString(numbers)) {
              PINDEX cardnum = numbers.AsInteger();
              dsp.SetAt(cardnum+1, devname);
  	  }
          }
          // Look for mixer
          if (filename == "mixer") {
            mixer.SetAt(0, devname);
--- 516,562 ----
          // On Linux devfs systems, the major numbers can change dynamically.
  	// On FreeBSD and other OSs, the major numbes are different to Linux.
  	// So collect devices by looking for dsp(N) and mixer(N).
!         // (or /dev/audio(N) and mixer(N) on NetBSD
! 	// Notes. FreeBSD supports audio stream mixing. A single sound card
! 	// may have multiple /dev entries in the form /dev/dspN.M
! 	// eg /dev/dsp0.0 /dev/dsp0.1 /dev/dsp0.2 and /dev/dsp0.3
! 	// When adding these to the 'dsp' string array, only the first one
! 	// found is used.
  
+ #ifndef P_NETBSD
          // Look for dsp
          if (filename == "dsp") {
            dsp.SetAt(0, devname);
          }
! 
!         // Look for dspN entries. Insert at position N + 1
!         // and look for dspN.M entries. Insert at position N + 1 (ignoring M)
! 
          if ((filename.GetLength() > 3) && (filename.Left(3) == "dsp")) {
+ 
  	  PString numbers = filename.Mid(3); // get everything after 'dsp'
  	  if (IsNumericString(numbers)) {
+             PINDEX cardnum = numbers.AsInteger(); //dspN.M is truncated to dspN.
+ 	    // If we have not yet inserted something for this cardnum, insert it
+ 	    if (dsp.GetAt(cardnum+1) == NULL) {
+               dsp.SetAt(cardnum+1, devname);
+ 	    }
+ 	  }
+         }
+ #else
+         // Look for audio on NetBSD 
+         if (filename == "audio") {
+           dsp.SetAt(0, devname);
+         }
+         // Look for audioN. Insert at position cardnum + 1
+         if ((filename.GetLength() > 5) && (filename.Left(5) == "audio")) {
+ 	  PString numbers = filename.Mid(5); // get everything after 'audio'
+ 	  if (IsNumericString(numbers)) {
              PINDEX cardnum = numbers.AsInteger();
              dsp.SetAt(cardnum+1, devname);
  	  }
          }
+ #endif
          // Look for mixer
          if (filename == "mixer") {
            mixer.SetAt(0, devname);
*************** PString PSoundChannel::GetDefaultDevice(
*** 604,611 ****
--- 646,656 ----
  {
    // Normally /dev/dsp points to the default sound device. If this is not
    // present, probe /dev for sound devices and return the first detected device.
+ 
    if (PFile::Exists("/dev/dsp")) {
      return "/dev/dsp";
+   } else if (PFile::Exists("/dev/audio")) { // the NetBSD default name
+     return "/dev/audio";
    } else {
      // return the first dsp device detected
      PStringArray devicenames;