**
** 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
#include <wdq2wav.h>
-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;
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;
}
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<int>(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<char*>(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;