Mercurial > sdl-ios-xcode
view src/audio/SDL_audiodev.c @ 3809:7852b5b78af5 SDL-ryan-multiple-audio-device
Cleaning out SDL_audiodev.c and related references ...
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 05 Oct 2006 01:13:47 +0000 |
parents | c121d94672cb |
children | 2c5387c0a642 |
line wrap: on
line source
/* SDL - Simple DirectMedia Layer Copyright (C) 1997-2006 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Sam Lantinga slouken@libsdl.org */ #include "SDL_config.h" /* Get the name of the audio device we use for output */ #if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include "SDL_stdinc.h" #include "SDL_audiodev_c.h" #ifndef _PATH_DEV_DSP #if defined(__NETBSD__) || defined(__OPENBSD__) #define _PATH_DEV_DSP "/dev/audio" #else #define _PATH_DEV_DSP "/dev/dsp" #endif #endif #ifndef _PATH_DEV_DSP24 #define _PATH_DEV_DSP24 "/dev/sound/dsp" #endif #ifndef _PATH_DEV_AUDIO #define _PATH_DEV_AUDIO "/dev/audio" #endif int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; /* Figure out what our audio device is */ if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } audio_fd = open(audiodev, flags, 0); /* If the first open fails, look for other devices */ if ((audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath) - 3))) { int exists, instance; struct stat sb; instance = 1; do { /* Don't use errno ENOENT - it may not be thread-safe */ SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance++); exists = 0; if (stat(audiopath, &sb) == 0) { exists = 1; audio_fd = open(audiopath, flags, 0); } } while (exists && (audio_fd < 0)); audiodev = audiopath; } if (path != NULL) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } return (audio_fd); } #endif /* Audio driver selection */ /* vi: set ts=4 sw=4 expandtab: */