Skip to content

Commit

Permalink
Added --enable-oss-cookedmode configure argument to force SNDCTL_DSP_…
Browse files Browse the repository at this point in the history
…COOKEDMODE=1 on OSS.

Previous default of SNDCTL_DSP_COOKEDMODE=0 allowed some hardware to work with mismatched sample rate.
  • Loading branch information
yurivict committed Jul 19, 2017
1 parent cb654ad commit 7bae257
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,28 @@ AM_CONDITIONAL(HAVE_COREAUDIO, $HAVE_COREAUDIO)
AC_ARG_ENABLE(oss, AC_HELP_STRING([--disable-oss],[ignore OSS driver ]),
TRY_OSS=$enableval , TRY_OSS=yes )
HAVE_OSS="false"
USE_OSS_COOKEDMODE="false"
if test "x$TRY_OSS" = "xyes"
then
# check for Open Sound System
AC_CHECK_HEADER([sys/soundcard.h],
[HAVE_OSS="true"
JACK_DEFAULT_DRIVER=\"oss\"])

# enable OSS cookedmode to allow hardware with mismatching sample rates
if test "x$HAVE_OSS" = "xtrue"
then
AC_ARG_ENABLE(oss-cookedmode, AC_HELP_STRING([--enable-oss-cookedmode],[Enable cooked mode in OSS to accommodate hardware with mismatching sample rate]),
ENABLE_OSS_COOKEDMODE=$enableval, ENABLE_OSS_COOKEDMODE=no)
if test "x$ENABLE_OSS_COOKEDMODE" = "xyes"
then
USE_OSS_COOKEDMODE=true
AC_DEFINE(USE_OSS_COOKEDMODE, 1, [Enable cooked mode in OSS to accommodate hardware with mismatching sample rate])
fi
fi
fi
AM_CONDITIONAL(HAVE_OSS, $HAVE_OSS)
AM_CONDITIONAL(USE_OSS_COOKEDMODE, $USE_OSS_COOKEDMODE)

AC_ARG_ENABLE(sun, AC_HELP_STRING([--disable-sun],[ignore Sun driver ]),
TRY_SUN=$enableval , TRY_SUN=yes )
Expand Down Expand Up @@ -1008,6 +1022,7 @@ echo \| Build with ALSA support............................... : $HAVE_ALSA
echo \| Build with old FireWire \(FreeBob\) support............. : $HAVE_FREEBOB
echo \| Build with new FireWire \(FFADO\) support............... : $HAVE_FIREWIRE
echo \| Build with OSS support................................ : $HAVE_OSS
echo \| Enable OSS COOKEDMODE for hardware flexibility........ : $USE_OSS_COOKEDMODE
echo \| Build with Sun audio support.......................... : $HAVE_SUN
echo \| Build with Sndio audio support........................ : $HAVE_SNDIO
echo \| Build with CoreAudio support.......................... : $HAVE_COREAUDIO
Expand Down
16 changes: 10 additions & 6 deletions drivers/oss/oss_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ static int oss_driver_detach (oss_driver_t *driver, jack_engine_t *engine)

static int oss_driver_start (oss_driver_t *driver)
{
int flags = 0;
#if defined(USE_OSS_COOKEDMODE)
int cookedmode = 1;
#else
int cookedmode = 0;
#endif
int format;
int channels;
int samplerate;
Expand Down Expand Up @@ -464,7 +468,7 @@ static int oss_driver_start (oss_driver_t *driver)
indev, __FILE__, __LINE__, errno);
}
#ifndef OSS_NO_COOKED_MODE
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags);
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode);
#endif
fragsize = driver->period_size *
driver->capture_channels * samplesize;
Expand All @@ -479,7 +483,7 @@ static int oss_driver_start (oss_driver_t *driver)
outdev, __FILE__, __LINE__, errno);
}
#ifndef OSS_NO_COOKED_MODE
ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &flags);
ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &cookedmode);
#endif
fragsize = driver->period_size *
driver->playback_channels * samplesize;
Expand All @@ -497,7 +501,7 @@ static int oss_driver_start (oss_driver_t *driver)
return -1;
}
#ifndef OSS_NO_COOKED_MODE
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags);
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode);
#endif
} else if (driver->capture_channels == 0 &&
driver->playback_channels != 0) {
Expand All @@ -510,7 +514,7 @@ static int oss_driver_start (oss_driver_t *driver)
return -1;
}
#ifndef OSS_NO_COOKED_MODE
ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &flags);
ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &cookedmode);
#endif
} else {
infd = outfd = open (indev, O_RDWR | O_EXCL);
Expand All @@ -521,7 +525,7 @@ static int oss_driver_start (oss_driver_t *driver)
return -1;
}
#ifndef OSS_NO_COOKED_MODE
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags);
ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode);
#endif
}
if (infd >= 0 && outfd >= 0) {
Expand Down

0 comments on commit 7bae257

Please sign in to comment.