--- libao2/ao_oss.c.orig 2009-09-16 09:04:40.000000000 +0800 +++ libao2/ao_oss.c 2009-09-17 20:45:07.000000000 +0800 @@ -182,7 +182,16 @@ if(AF_FORMAT_IS_AC3(ao_data.format)) return CONTROL_TRUE; - if ((fd = open(oss_mixer_device, O_RDONLY)) > 0) +#ifdef __FreeBSD__ + if (audio_fd != -1 && oss_mixer_channel == SOUND_MIXER_PCM && + (oss_mixer_device == PATH_DEV_MIXER || + strcmp(oss_mixer_device, PATH_DEV_MIXER) == 0 || + strcmp(oss_mixer_device, dsp) == 0)) + fd = audio_fd; + else +#endif + fd = open(oss_mixer_device, O_RDONLY); + if (fd > 0) { ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); if (devs & (1 << oss_mixer_channel)) @@ -201,10 +210,12 @@ } else { - close(fd); + if (fd != audio_fd) + close(fd); return CONTROL_ERROR; } - close(fd); + if (fd != audio_fd) + close(fd); return CONTROL_OK; } } @@ -437,6 +448,12 @@ // stop playing and empty buffers (for seeking/pause) static void reset(void){ int oss_format; +#ifdef SNDCTL_DSP_RESET + if (audio_fd < 0) + return; + + ioctl(audio_fd, SNDCTL_DSP_RESET, NULL); +#else uninit(1); audio_fd=open(dsp, O_WRONLY); if(audio_fd < 0){ @@ -447,6 +464,7 @@ #if defined(FD_CLOEXEC) && defined(F_SETFD) fcntl(audio_fd, F_SETFD, FD_CLOEXEC); #endif +#endif ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate); oss_format = format2oss(ao_data.format); @@ -466,13 +484,32 @@ // stop playing, keep buffers (for pause) static void audio_pause(void) { +#ifdef SNDCTL_DSP_SETTRIGGER + int trig; + + if (audio_fd < 0) + return; + + trig = 0; + ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &trig); +#else prepause_space = get_space(); uninit(1); +#endif } // resume playing, after audio_pause() static void audio_resume(void) { +#ifdef SNDCTL_DSP_SETTRIGGER + int trig; + + if (audio_fd < 0) + return; + + trig = PCM_ENABLE_OUTPUT; + ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &trig); +#else int fillcnt; reset(); fillcnt = get_space() - prepause_space; @@ -481,6 +518,7 @@ play(silence, fillcnt, 0); free(silence); } +#endif } --- libao2/ao_pcm.c.orig 2007-10-08 03:49:27.000000000 +0800 +++ libao2/ao_pcm.c 2007-12-16 00:31:15.000000000 +0800 @@ -113,27 +113,32 @@ bits=8; switch(format){ - case AF_FORMAT_S32_BE: - format=AF_FORMAT_S32_LE; - case AF_FORMAT_S32_LE: - bits=32; - break; case AF_FORMAT_FLOAT_BE: format=AF_FORMAT_FLOAT_LE; case AF_FORMAT_FLOAT_LE: + case AF_FORMAT_U32_BE: + case AF_FORMAT_U32_LE: + case AF_FORMAT_S32_BE: + case AF_FORMAT_S32_LE: bits=32; break; - case AF_FORMAT_S8: - format=AF_FORMAT_U8; - case AF_FORMAT_U8: - break; + case AF_FORMAT_U16_BE: + case AF_FORMAT_U16_LE: + case AF_FORMAT_S16_BE: + case AF_FORMAT_S16_LE: case AF_FORMAT_AC3_BE: case AF_FORMAT_AC3_LE: bits=16; break; + case AF_FORMAT_S8: + case AF_FORMAT_U8: + break; default: - format=AF_FORMAT_S16_LE; - bits=16; + if (!(!ao_pcm_waveheader && + (format == AF_FORMAT_A_LAW || format == AF_FORMAT_MU_LAW))) { + format=AF_FORMAT_S16_LE; + bits=16; + } break; } --- libao2/ao_alsa.c.orig 2009-09-16 07:55:17.000000000 +0800 +++ libao2/ao_alsa.c 2009-09-16 07:59:11.000000000 +0800 @@ -372,6 +372,18 @@ case AF_FORMAT_S16_BE: alsa_format = SND_PCM_FORMAT_S16_BE; break; + case AF_FORMAT_U24_LE: + alsa_format = SND_PCM_FORMAT_U24_3LE; + break; + case AF_FORMAT_U24_BE: + alsa_format = SND_PCM_FORMAT_U24_3BE; + break; + case AF_FORMAT_S24_LE: + alsa_format = SND_PCM_FORMAT_S24_3LE; + break; + case AF_FORMAT_S24_BE: + alsa_format = SND_PCM_FORMAT_S24_3BE; + break; case AF_FORMAT_U32_LE: alsa_format = SND_PCM_FORMAT_U32_LE; break; --- libavcodec/resample2.c.orig 2009-01-19 10:40:22.000000000 +0800 +++ libavcodec/resample2.c 2009-01-19 10:40:54.000000000 +0800 @@ -28,6 +28,9 @@ #include "avcodec.h" #include "dsputil.h" +#undef CONFIG_RESAMPLE_HP +#define CONFIG_RESAMPLE_HP 1 + #ifndef CONFIG_RESAMPLE_HP #define FILTER_SHIFT 15