*** ../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 . * * $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 + * + * 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 - #include #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;