From 36e722bb07d5ad14bad6eafcf9ac6b2a77b9e652 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 21 Jan 2003 19:46:53 +0000 Subject: [PATCH] r3839: *** empty log message *** --- wdq2wav.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/wdq2wav.cpp b/wdq2wav.cpp index 0607f12..12aad5e 100644 --- a/wdq2wav.cpp +++ b/wdq2wav.cpp @@ -8,7 +8,7 @@ ** ** Copyright (c) 2003 Kevin Rosenberg ** -** $Id: wdq2wav.cpp,v 1.12 2003/01/21 12:59:56 kevin Exp $ +** $Id: wdq2wav.cpp,v 1.13 2003/01/21 19:46:53 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -26,7 +26,7 @@ #include -const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.12 2003/01/21 12:59:56 kevin Exp $"; +const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.13 2003/01/21 19:46:53 kevin Exp $"; bool g_quiet = false; bool g_verbose = false; @@ -644,7 +644,7 @@ WavFile::Play () return true; #elif defined(LINUX) int fd; - if ((fd = open ("/dev/dsp",O_WRONLY)) < 0) { + if ((fd = open ("/dev/dsp",O_WRONLY)) == -1) { error_msg ("Error opening /dev/dsp"); return false; } @@ -652,35 +652,43 @@ WavFile::Play () int format = AFMT_S16_LE; if (ioctl (fd, SNDCTL_DSP_SETFMT, &format) == -1) { error_msg ("Error setting DSP format"); - close(fd); return false; } + close(fd); return false; + } if (format != AFMT_S16_LE) { error_msg ("DSP Format not set"); - close(fd); return false; } + close(fd); return false; + } int channels = m_nChannels; if (ioctl (fd, SNDCTL_DSP_CHANNELS, &format) == -1) { error_msg ("Error setting number of channels"); - close(fd); return false; } + close(fd); return false; + } if (channels != m_nChannels) { error_msg ("Number of channels not set"); - close(fd); return false; } + close(fd); return false; + } int speed = static_cast(m_rate + 0.5); if (ioctl (fd, SNDCTL_DSP_SPEED, &speed) == -1) { error_msg ("Error setting sample rate"); - close(fd); return false; } - double set_speed = speed; - if (fabs (set_speed - m_rate) / m_rate > 0.1) { - error_msg ("Sample rate not set"); - close(fd); return false; } + close(fd); return false; + } + if (speed != m_rate && ! g_quiet) { + std::ostringstream os; + os << "Warning: Sample rate set to " << speed << ", not " << m_rate; + error_msg (os.str().c_str()); + } if (write (fd, reinterpret_cast(m_data) + m_nHeaderBytes, m_nDataBytes) != m_nDataBytes) { error_msg ("Error writing audio samples"); - close(fd); return false; } + close(fd); return false; + } close (fd); return true; +#else #endif return false; -- 2.34.1