You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.5 KiB
79 lines
2.5 KiB
15 years ago
|
/***************************************************************************
|
||
|
encoder_pcm.cpp
|
||
|
-------------------
|
||
|
begin : Sat Aug 20 2005
|
||
|
copyright : (C) 2005 by Martin Witte
|
||
|
email : witte@kawo1.rwth-aachen.de
|
||
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include "encoder_pcm.h"
|
||
|
|
||
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
13 years ago
|
RecordingEncodingPCM::RecordingEncodingPCM(TQObject *parent, SoundStreamID ssid,
|
||
15 years ago
|
const RecordingConfig &cfg, const RadioStation *rs,
|
||
14 years ago
|
const TQString &filename)
|
||
13 years ago
|
: RecordingEncoding(parent, ssid, cfg, rs, filename),
|
||
15 years ago
|
m_output(NULL)
|
||
|
{
|
||
|
m_config.m_SoundFormat.m_Encoding = "raw";
|
||
|
openOutput(filename);
|
||
|
}
|
||
|
|
||
|
|
||
|
RecordingEncodingPCM::~RecordingEncodingPCM()
|
||
|
{
|
||
|
closeOutput();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void RecordingEncodingPCM::encode(const char *buffer, size_t buffer_size, char *&export_buffer, size_t &export_buffer_size)
|
||
|
{
|
||
|
if (m_error)
|
||
|
return;
|
||
|
m_encodedSize += buffer_size;
|
||
|
|
||
|
export_buffer = const_cast<char*>(buffer);
|
||
|
export_buffer_size = buffer_size;
|
||
|
int err = sf_write_raw(m_output, const_cast<char*>(buffer), buffer_size);
|
||
|
|
||
|
if (err != (int)buffer_size) {
|
||
|
m_error = true;
|
||
13 years ago
|
m_errorString += i18n("Error %1 writing output. ").arg(TQString().setNum(err));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
bool RecordingEncodingPCM::openOutput(const TQString &output)
|
||
15 years ago
|
{
|
||
|
SF_INFO sinfo;
|
||
|
m_config.getSoundFileInfo(sinfo, false);
|
||
|
m_output = sf_open(output.ascii(), SFM_WRITE, &sinfo);
|
||
|
|
||
|
if (!m_output) {
|
||
|
m_error = true;
|
||
13 years ago
|
m_errorString += i18n("Cannot open output file %1. ").arg(output);
|
||
15 years ago
|
}
|
||
|
return !m_error;
|
||
|
}
|
||
|
|
||
|
|
||
|
void RecordingEncodingPCM::closeOutput()
|
||
|
{
|
||
|
if (m_output) sf_close (m_output);
|
||
|
m_output = NULL;
|
||
|
}
|
||
|
|
||
|
|