2014-08-14 Fred Gleason <fredg@paravelsystems.com>

* Fixed warnings in 'lib/rdaudioconvert.cpp'.
	* Fixed warnings in 'lib/rdaudioexport.cpp'.
	* Fixed warnings in 'lib/rdaudioimport.cpp'.
	* Fixed warnings in 'lib/rdcart_dialog.cpp'.
	* Fixed warnings in 'lib/rdconf.cpp'.
	* Fixed warnings in 'lib/rdcopyaudio.cpp'.
	* Fixed warnings in 'lib/rdescape_string.cpp'.
	* Fixed warnings in 'lib/rdevent_line.cpp'.
	* Fixed warnings in 'lib/rdfeed.cpp'.
	* Refactored 'RDOneShot' to use int values in 'lib/rdoneshot.cpp'
	and 'lib/rdoneshot.h'.
	* Fixed warnings in 'lib/rdpeaksexport.cpp'.
	* Fixed warnings in 'lib/rdtrimaudio.cpp'.
	* Fixed warnings in 'lib/rdwavefile.cpp'.
	* Fixed warnings in 'rdhpi/rdhpiplaystream.cpp'.
	* Fixed warnings in 'rdhpi/rdhpirecordstream.cpp'.
	* Fixed warnings in 'rdhpi/rdhpisoundcard.cpp'.
	* Fixed warnings in 'pam_rd/pam_rd.cpp'.
	* Fixed warnings in 'rdadmin/edit_rdairplay.cpp'.
	* Fixed warnings in 'rdairplay/list_log.cpp'.
	* Fixed warnings in 'rdairplay/log_play.cpp'.
	* Fixed warnings in 'rdairplay/pie_counter.cpp'.
	* Fixed warnings in 'rdairplay/rlm_host.cpp'.
	* Fixed warnings in 'rdcatchd/rdcatchd.cpp'.
	* Fixed warnings in 'rdlogedit/editlog.cpp'.
	* Fixed warnings in 'rdlogmanager/rdlogmanager.cpp'.
	* Fixed warnings in 'rdrepl/replfactory.h'.
	* Fixed warnings in 'ripcd/acu1p.cpp' and 'ripcd/acu1p.h'.
	* Fixed warnings in 'ripcd/bt16x2.cpp' and 'ripcd/bt16x2.h'.
	* Fixed warnings in 'ripcd/btss164.cpp' and 'ripcd/btss164.h'.
	* Fixed warnings in 'ripcd/btss42.cpp' and 'ripcd/btss42.h'.
	* Fixed warnings in 'ripcd/btss44.cpp' and 'ripcd/btss44.h'.
	* Fixed warnings in 'ripcd/btss82.cpp' and 'ripcd/btss82.h'.
	* Fixed warnings in 'ripcd/btsrc16.cpp' and 'ripcd/btsrc16.h'.
	* Fixed warnings in 'ripcd/btsrc8iii.cpp' and 'ripcd/btsrc8iii.h'.
	* Fixed warnings in 'ripcd/livewire_mcastgpio.cpp'.
	* Fixed warnings in 'ripcd/local_gpio.cpp' and 'ripcd/local_gpio.h'.
	* Fixed warnings in 'ripcd/sas64000gpi.cpp' and 'ripcd/sas64000gpi.h'.
	* Fixed warnings in 'ripcd/vguest.cpp' and 'ripcd/vguest.h'.
	* Fixed warnings in 'utils/rdhpiinfo/rdhpiinfo.cpp'
	* Fixed warnings in 'utils/rdgen/wavlib.cpp'
	* Fixed warnings in 'utils/rdimport/rdimport.cpp'
	* Fixed warnings in 'utils/rdsoftkeys/rdsoftkeys.cpp'
	* Fixed warnings in 'web/rdxport/export.cpp'
This commit is contained in:
Fred Gleason
2014-08-14 19:08:38 -04:00
parent e02e625950
commit 89b846f7d6
63 changed files with 423 additions and 448 deletions

View File

@@ -68,7 +68,7 @@ RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,
QWidget *parent,const char *name)
:QObject(parent,name),RDWaveFile()
{
hpi_err_t hpi_err;
// hpi_err_t hpi_err;
int quan;
uint16_t type[HPI_MAX_ADAPTERS];
@@ -99,9 +99,9 @@ RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,
card_index[i]=i;
}
#else
hpi_err=HPI_SubSysGetNumAdapters(NULL,&quan);
LogHpi(HPI_SubSysGetNumAdapters(NULL,&quan));
for(int i=0;i<quan;i++) {
hpi_err=HPI_SubSysGetAdapter(NULL,i,card_index+i,type+i);
LogHpi(HPI_SubSysGetAdapter(NULL,i,card_index+i,type+i));
}
#endif // HPI_VER
@@ -157,7 +157,6 @@ QString RDHPIPlayStream::errorString(RDHPIPlayStream::Error err)
bool RDHPIPlayStream::formatSupported(RDWaveFile::Format format)
{
hpi_err_t hpi_error;
#if HPI_VER < 0x30A00
HPI_FORMAT hpi_format;
#else
@@ -177,8 +176,7 @@ bool RDHPIPlayStream::formatSupported(RDWaveFile::Format format)
}
if(!is_open) {
for(int i=0;i<sound_card->getCardOutputStreams(card_number);i++) {
if((hpi_error=HPI_OutStreamOpen(NULL,card_index[card_number],i,
&hostream))==0) {
if(HPI_OutStreamOpen(NULL,card_index[card_number],i,&hostream)==0) {
found=true;
break;
}
@@ -192,30 +190,30 @@ bool RDHPIPlayStream::formatSupported(RDWaveFile::Format format)
}
switch(format) {
case RDWaveFile::Pcm16:
hpi_error=HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_PCM16_SIGNED,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_PCM16_SIGNED,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_OutStreamQueryFormat(NULL,hostream,&hpi_format);
break;
case RDWaveFile::MpegL1:
hpi_error=HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L1,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L1,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_OutStreamQueryFormat(NULL,hostream,&hpi_format);
break;
case RDWaveFile::MpegL2:
hpi_error=HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L2,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L2,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_OutStreamQueryFormat(NULL,hostream,&hpi_format);
break;;
case RDWaveFile::MpegL3:
hpi_error=HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L3,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hpi_format,getChannels(),
HPI_FORMAT_MPEG_L3,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_OutStreamQueryFormat(NULL,hostream,&hpi_format);
break;
@@ -224,7 +222,7 @@ bool RDHPIPlayStream::formatSupported(RDWaveFile::Format format)
break;
}
if(!is_open) {
hpi_error=HPI_OutStreamClose(NULL,hostream);
LogHpi(HPI_OutStreamClose(NULL,hostream));
}
if(state!=0) {
return false;
@@ -385,15 +383,14 @@ bool RDHPIPlayStream::play()
#ifdef RPLAYSTREAM_SHOW_SLOTS
printf("play() -- Card: %d Stream: %d\n",card_number,stream_number);
#endif // RPLAYSTREAM_SHOW_SLOTS
hpi_err_t hpi_error;
syslog(LOG_ERR,"Play - 1\n");
if(!is_open) {
return false;
}
if((!playing)&&(!is_paused)) {
hpi_error=HPI_OutStreamSetTimeScale(NULL,hpi_stream,
LogHpi(HPI_OutStreamSetTimeScale(NULL,hpi_stream,
(uint16_t)((RD_TIMESCALE_DIVISOR/(double)play_speed)*
HPI_OSTREAM_TIMESCALE_UNITS));
HPI_OSTREAM_TIMESCALE_UNITS)));
if(HPI_OutStreamGetInfoEx(NULL,hpi_stream,
&state,&buffer_size,&data_to_play,
&samples_played,&reserved)!=0) {
@@ -415,22 +412,22 @@ bool RDHPIPlayStream::play()
case WAVE_FORMAT_VORBIS:
switch(getBitsPerSample()) {
case 8:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM8_UNSIGNED,getSamplesPerSec(),
0,0);
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM8_UNSIGNED,
getSamplesPerSec(),0,0));
break;
case 16:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM16_SIGNED,getSamplesPerSec(),
0,0);
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM16_SIGNED,
getSamplesPerSec(),0,0));
break;
case 32:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM32_SIGNED,getSamplesPerSec(),
0,0);
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_PCM32_SIGNED,
getSamplesPerSec(),0,0));
break;
default:
hpi_error=HPI_AdapterClose(NULL,card_index[card_number]);
LogHpi(HPI_AdapterClose(NULL,card_index[card_number]));
return false;
break;
}
@@ -438,22 +435,22 @@ bool RDHPIPlayStream::play()
case WAVE_FORMAT_MPEG:
switch(getHeadLayer()) {
case 1:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L1,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags());
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L1,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags()));
break;
case 2:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L2,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags());
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L2,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags()));
break;
case 3:
hpi_error=HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L3,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags());
LogHpi(HPI_FormatCreate(&format,getChannels(),
HPI_FORMAT_MPEG_L3,getSamplesPerSec(),
getHeadBitRate(),getHeadFlags()));
break;
default:
hpi_error=HPI_AdapterClose(NULL,card_index[card_number]);
LogHpi(HPI_AdapterClose(NULL,card_index[card_number]));
return false;
}
break;
@@ -480,11 +477,10 @@ bool RDHPIPlayStream::play()
}
readWave(pdata,read_bytes);
#if HPI_VER > 0x00030500
hpi_error=
HPI_OutStreamWriteBuf(NULL,hpi_stream,pdata,read_bytes,&format);
LogHpi(HPI_OutStreamWriteBuf(NULL,hpi_stream,pdata,read_bytes,&format));
#else
hpi_error=HPI_DataCreate(&hpi_data,&format,pdata,read_bytes);
hpi_error=HPI_OutStreamWrite(NULL,hpi_stream,&hpi_data);
LogHpi(HPI_DataCreate(&hpi_data,&format,pdata,read_bytes));
LogHpi(HPI_OutStreamWrite(NULL,hpi_stream,&hpi_data));
#endif
if(HPI_OutStreamStart(NULL,hpi_stream)!=0) {
return false;
@@ -506,7 +502,7 @@ bool RDHPIPlayStream::play()
}
}
if((!playing)&(is_paused|repositioned)) {
hpi_error=HPI_OutStreamStart(NULL,hpi_stream);
LogHpi(HPI_OutStreamStart(NULL,hpi_stream));
clock->start(FRAGMENT_TIME);
playing=true;
stopping=false;
@@ -527,7 +523,6 @@ void RDHPIPlayStream::pause()
#ifdef RPLAYSTREAM_SHOW_SLOTS
printf("pause() -- Card: %d Stream: %d\n",card_number,stream_number);
#endif // RPLAYSTREAM_SHOW_SLOTS
hpi_err_t hpi_error;
uint16_t state;
uint32_t buffer_size;
uint32_t data_to_play;
@@ -537,10 +532,10 @@ void RDHPIPlayStream::pause()
return;
}
if(playing) {
hpi_error=HPI_OutStreamStop(NULL,hpi_stream);
LogHpi(HPI_OutStreamStop(NULL,hpi_stream));
clock->stop();
hpi_error=HPI_OutStreamGetInfoEx(NULL,hpi_stream,&state,&buffer_size,
&data_to_play,&samples_played,&reserved);
LogHpi(HPI_OutStreamGetInfoEx(NULL,hpi_stream,&state,&buffer_size,
&data_to_play,&samples_played,&reserved));
switch(getFormatTag()) {
case WAVE_FORMAT_PCM:
samples_pending=data_to_play/(getChannels()*getBitsPerSample()/8);
@@ -569,18 +564,17 @@ void RDHPIPlayStream::stop()
printf("stop() -- Card: %d Stream: %d\n",card_number,stream_number);
#endif // RPLAYSTREAM_SHOW_SLOTS
hpi_err_t hpi_error;
if(!is_open) {
return;
}
if(playing|is_paused) {
hpi_error=HPI_OutStreamStop(NULL,hpi_stream);
LogHpi(HPI_OutStreamStop(NULL,hpi_stream));
clock->stop();
playing=false;
is_paused=false;
seekWave(0,SEEK_SET);
hpi_error=HPI_OutStreamReset(NULL,hpi_stream);
LogHpi(HPI_OutStreamReset(NULL,hpi_stream));
samples_pending=0;
samples_skipped=0;
stream_state=RDHPIPlayStream::Stopped;
@@ -610,8 +604,6 @@ int RDHPIPlayStream::currentPosition()
bool RDHPIPlayStream::setPosition(unsigned samples)
{
hpi_err_t hpi_error;
#ifdef RPLAYSTREAM_SHOW_SLOTS
printf("setPosition(%d) -- Card: %d Stream: %d\n",samples,
card_number,stream_number);
@@ -629,7 +621,7 @@ bool RDHPIPlayStream::setPosition(unsigned samples)
is_paused=false;
repositioned=true;
}
hpi_error=HPI_OutStreamReset(NULL,hpi_stream);
LogHpi(HPI_OutStreamReset(NULL,hpi_stream));
samples_played=0;
switch(getFormatTag()) {
case WAVE_FORMAT_PCM:
@@ -755,12 +747,10 @@ void RDHPIPlayStream::Drained()
int RDHPIPlayStream::GetStream()
{
hpi_err_t hpi_error;
#ifdef RDHPIPLAYSTREAM_USE_LOCAL_MUTEX
for(int i=0;i<sound_card->getCardOutputStreams(card_number);i++) {
if(++stream_mutex[card_number][i]==1) {
hpi_error=HPI_OutStreamOpen(NULL,card_index[card_number],i,&hpi_stream);
LogHpi(HPI_OutStreamOpen(NULL,card_index[card_number],i,&hpi_stream));
stream_number=i;
return stream_number;
}
@@ -784,15 +774,25 @@ int RDHPIPlayStream::GetStream()
void RDHPIPlayStream::FreeStream()
{
hpi_err_t hpi_error;
#ifdef RDHPIPLAYSTREAM_USE_LOCAL_MUTEX
stream_mutex[card_number][stream_number]--;
hpi_error=HPI_OutStreamClose(NULL,hpi_stream);
LogHpi(HPI_OutStreamClose(NULL,hpi_stream));
stream_number=-1;
#else
hpi_error=HPI_OutStreamClose(NULL,hpi_stream);
LogHpi(HPI_OutStreamClose(NULL,hpi_stream));
// syslog(LOG_ERR,"HPI closing ostream: %d",stream_number);
stream_number=-1;
#endif
}
hpi_err_t RDHPIPlayStream::LogHpi(hpi_err_t err)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s",err_txt);
}
return err;
}

View File

@@ -91,6 +91,7 @@ class RDHPIPlayStream : public QObject,public RDWaveFile
void Drained();
int GetStream();
void FreeStream();
hpi_err_t LogHpi(hpi_err_t err);
RDHPISoundCard *sound_card;
RDHPIPlayStream::State stream_state;
QString wave_name;

View File

@@ -26,6 +26,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
#include <fcntl.h>
#include <qobject.h>
#include <qwidget.h>
@@ -39,7 +40,6 @@ RDHPIRecordStream::RDHPIRecordStream(RDHPISoundCard *card,
QWidget *parent,const char *name)
:QObject(parent,name),RDWaveFile()
{
hpi_err_t hpi_err;
int quan;
uint16_t type[HPI_MAX_ADAPTERS];
@@ -79,9 +79,9 @@ RDHPIRecordStream::RDHPIRecordStream(RDHPISoundCard *card,
card_index[i]=i;
}
#else
hpi_err=HPI_SubSysGetNumAdapters(NULL,&quan);
LogHpi(HPI_SubSysGetNumAdapters(NULL,&quan));
for(int i=0;i<quan;i++) {
hpi_err=HPI_SubSysGetAdapter(NULL,i,card_index+i,type+i);
LogHpi(HPI_SubSysGetAdapter(NULL,i,card_index+i,type+i));
}
#endif // HPI_VER
@@ -179,7 +179,6 @@ bool RDHPIRecordStream::formatSupported(RDWaveFile::Format format)
struct hpi_format hformat;
#endif
hpi_handle_t histream;
hpi_err_t hpi_err;
bool found=false;
if(card_number<0) {
@@ -207,34 +206,34 @@ bool RDHPIRecordStream::formatSupported(RDWaveFile::Format format)
}
switch(format) {
case RDWaveFile::Pcm8:
hpi_err=HPI_FormatCreate(&hformat,getChannels(),
HPI_FORMAT_PCM8_UNSIGNED,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hformat,getChannels(),
HPI_FORMAT_PCM8_UNSIGNED,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_InStreamQueryFormat(NULL,histream,&hformat);
break;
case RDWaveFile::Pcm16:
hpi_err=HPI_FormatCreate(&hformat,getChannels(),
HPI_FORMAT_PCM16_SIGNED,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hformat,getChannels(),
HPI_FORMAT_PCM16_SIGNED,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_InStreamQueryFormat(NULL,histream,&hformat);
break;
case RDWaveFile::MpegL1:
hpi_err=HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L1,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L1,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_InStreamQueryFormat(NULL,histream,&hformat);
break;
case RDWaveFile::MpegL2:
hpi_err=HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L2,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L2,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_InStreamQueryFormat(NULL,histream,&hformat);
break;
case RDWaveFile::MpegL3:
hpi_err=HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L3,
getSamplesPerSec(),getHeadBitRate(),0);
LogHpi(HPI_FormatCreate(&hformat,getChannels(),HPI_FORMAT_MPEG_L3,
getSamplesPerSec(),getHeadBitRate(),0));
state=HPI_InStreamQueryFormat(NULL,histream,&hformat);
break;
@@ -243,7 +242,7 @@ bool RDHPIRecordStream::formatSupported(RDWaveFile::Format format)
break;
}
if(!is_open) {
hpi_err=HPI_InStreamClose(NULL,histream);
LogHpi(HPI_InStreamClose(NULL,histream));
}
if(state!=0) {
return false;
@@ -526,8 +525,6 @@ bool RDHPIRecordStream::recordReady()
void RDHPIRecordStream::record()
{
hpi_err_t hpi_err;
if(debug) {
printf("RDHPIRecordStream: received record()\n");
}
@@ -538,8 +535,8 @@ void RDHPIRecordStream::record()
recordReady();
}
record_started=false;
hpi_err=HPI_InStreamReset(NULL,hpi_stream);
hpi_err=HPI_InStreamStart(NULL,hpi_stream);
LogHpi(HPI_InStreamReset(NULL,hpi_stream));
LogHpi(HPI_InStreamStart(NULL,hpi_stream));
is_recording=true;
is_paused=false;
emit isStopped(false);
@@ -556,21 +553,19 @@ void RDHPIRecordStream::record()
void RDHPIRecordStream::pause()
{
hpi_err_t hpi_err;
if(debug) {
printf("RDHPIRecordStream: received pause()\n");
}
if(!is_recording) {
return;
}
hpi_err=HPI_InStreamStop(NULL,hpi_stream);
LogHpi(HPI_InStreamStop(NULL,hpi_stream));
tickClock();
hpi_err=HPI_InStreamGetInfoEx(NULL,hpi_stream,&state,&buffer_size,
&data_recorded,&samples_recorded,&reserved);
LogHpi(HPI_InStreamGetInfoEx(NULL,hpi_stream,&state,&buffer_size,
&data_recorded,&samples_recorded,&reserved));
is_recording=false;
is_paused=true;
hpi_err=HPI_InStreamStart(NULL,hpi_stream);
LogHpi(HPI_InStreamStart(NULL,hpi_stream));
emit paused();
emit stateChanged(card_number,stream_number,2); // Paused
if(debug) {
@@ -582,13 +577,11 @@ void RDHPIRecordStream::pause()
void RDHPIRecordStream::stop()
{
hpi_err_t hpi_err;
if(debug) {
printf("RDHPIRecordStream: received stop()\n");
}
if(is_ready|is_recording|is_paused) {
hpi_err=HPI_InStreamStop(NULL,hpi_stream);
LogHpi(HPI_InStreamStop(NULL,hpi_stream));
tickClock();
clock->stop();
is_recording=false;
@@ -626,11 +619,9 @@ void RDHPIRecordStream::setRecordLength(int length)
void RDHPIRecordStream::tickClock()
{
hpi_err_t hpi_err;
hpi_err=HPI_InStreamGetInfoEx(NULL,hpi_stream,
&state,&buffer_size,&data_recorded,
&samples_recorded,&reserved);
LogHpi(HPI_InStreamGetInfoEx(NULL,hpi_stream,
&state,&buffer_size,&data_recorded,
&samples_recorded,&reserved));
if((!record_started)&&(is_recording)) {
if(samples_recorded>0) {
if(record_length>0) {
@@ -647,23 +638,22 @@ void RDHPIRecordStream::tickClock()
}
while(data_recorded>fragment_size) {
#if HPI_VER > 0x00030500
hpi_err=HPI_InStreamReadBuf(NULL,hpi_stream,pdata,fragment_size);
LogHpi(HPI_InStreamReadBuf(NULL,hpi_stream,pdata,fragment_size));
#else
hpi_err=HPI_InStreamRead(NULL,hpi_stream,&hpi_data);
LogHpi(HPI_InStreamRead(NULL,hpi_stream,&hpi_data));
#endif
if(is_recording) {
writeWave(pdata,fragment_size);
}
hpi_err=HPI_InStreamGetInfoEx(NULL,hpi_stream,
&state,&buffer_size,&data_recorded,
&samples_recorded,&reserved);
LogHpi(HPI_InStreamGetInfoEx(NULL,hpi_stream,&state,&buffer_size,
&data_recorded,&samples_recorded,&reserved));
}
if(state==HPI_STATE_STOPPED) {
#if HPI_VER > 0x00030500
hpi_err=HPI_InStreamReadBuf(NULL,hpi_stream,pdata,data_recorded);
LogHpi(HPI_InStreamReadBuf(NULL,hpi_stream,pdata,data_recorded));
#else
hpi_err=HPI_DataCreate(&hpi_data,&format,pdata,data_recorded);
hpi_err=HPI_InStreamRead(NULL,hpi_stream,&hpi_data);
LogHpi(HPI_DataCreate(&hpi_data,&format,pdata,data_recorded));
LogHpi(HPI_InStreamRead(NULL,hpi_stream,&hpi_data));
#endif
if(is_recording) {
writeWave(pdata,data_recorded);
@@ -696,8 +686,17 @@ bool RDHPIRecordStream::GetStream()
void RDHPIRecordStream::FreeStream()
{
hpi_err_t hpi_err;
hpi_err=HPI_InStreamClose(NULL,hpi_stream);
LogHpi(HPI_InStreamClose(NULL,hpi_stream));
}
hpi_err_t RDHPIRecordStream::LogHpi(hpi_err_t err)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s",err_txt);
}
return err;
}

View File

@@ -96,6 +96,7 @@ class RDHPIRecordStream : public QObject,public RDWaveFile
private:
bool GetStream();
void FreeStream();
hpi_err_t LogHpi(hpi_err_t err);
RDHPISoundCard *sound_card;
bool debug;
bool xrun;

View File

@@ -21,6 +21,7 @@
//
//
#include <syslog.h>
#include <qtimer.h>
#include <rdhpisoundcard.h>
@@ -226,18 +227,15 @@ RDHPISoundCard::SourceNode RDHPISoundCard::getInputPortMux(int card,int port)
{
uint16_t type;
uint16_t index;
hpi_err_t hpi_err;
hpi_err=HPI_Multiplexer_GetSource(NULL,input_mux_control[card][port],
&type,&index);
LogHpi(HPI_Multiplexer_GetSource(NULL,input_mux_control[card][port],
&type,&index));
return (RDHPISoundCard::SourceNode)type;
}
bool RDHPISoundCard::setInputPortMux(int card,int port,RDHPISoundCard::SourceNode node)
{
hpi_err_t hpi_error;
switch(node) {
case RDHPISoundCard::LineIn:
if(HPI_Multiplexer_SetSource(NULL,
@@ -247,10 +245,9 @@ bool RDHPISoundCard::setInputPortMux(int card,int port,RDHPISoundCard::SourceNod
}
break;
case RDHPISoundCard::AesEbuIn:
if((hpi_error=
HPI_Multiplexer_SetSource(NULL,
input_mux_control[card][port],node,
input_mux_index[card][port][1]))!=0) {
if(HPI_Multiplexer_SetSource(NULL,
input_mux_control[card][port],node,
input_mux_index[card][port][1])!=0) {
return false;
}
break;
@@ -265,12 +262,11 @@ bool RDHPISoundCard::setInputPortMux(int card,int port,RDHPISoundCard::SourceNod
unsigned short RDHPISoundCard::getInputPortError(int card,int port)
{
uint16_t error_word=0;
hpi_err_t hpi_err;
if(input_port_aesebu[card][port]) {
hpi_err=HPI_AESEBU_Receiver_GetErrorStatus(NULL,
input_port_aesebu_control[card][port],
&error_word);
LogHpi(HPI_AESEBU_Receiver_GetErrorStatus(NULL,
input_port_aesebu_control[card][port],
&error_word));
}
return error_word;
}
@@ -366,64 +362,55 @@ int RDHPISoundCard::tunerHighFrequency(int card,int port,
bool RDHPISoundCard::inputStreamMeter(int card,int stream,short *level)
{
hpi_err_t hpi_err;
if(card>=card_quantity) {
return false;
}
if(stream>=card_input_streams[card]) {
return false;
}
hpi_err=HPI_MeterGetPeak(NULL,
input_stream_meter_control[card][stream],level);
LogHpi(HPI_MeterGetPeak(NULL,
input_stream_meter_control[card][stream],level));
return true;
}
bool RDHPISoundCard::outputStreamMeter(int card,int stream,short *level)
{
hpi_err_t hpi_err;
if(card>=card_quantity) {
return false;
}
if(stream>=card_output_streams[card]) {
return false;
}
hpi_err=HPI_MeterGetPeak(NULL,
output_stream_meter_control[card][stream],level);
LogHpi(HPI_MeterGetPeak(NULL,
output_stream_meter_control[card][stream],level));
return true;
}
bool RDHPISoundCard::inputPortMeter(int card,int port,short *level)
{
hpi_err_t hpi_err;
if(card>=card_quantity) {
return false;
}
if(port>=card_input_ports[card]) {
return false;
}
hpi_err=HPI_MeterGetPeak(NULL,
input_port_meter_control[card][port],level);
LogHpi(HPI_MeterGetPeak(NULL,
input_port_meter_control[card][port],level));
return true;
}
bool RDHPISoundCard::outputPortMeter(int card,int port,short *level)
{
hpi_err_t hpi_err;
if(card>=card_quantity) {
return false;
}
if(port>=card_output_ports[card]) {
return false;
}
hpi_err=HPI_MeterGetPeak(NULL,
output_port_meter_control[card][port],level);
LogHpi(HPI_MeterGetPeak(NULL,output_port_meter_control[card][port],level));
return true;
}
@@ -471,10 +458,9 @@ bool RDHPISoundCard::haveInputStreamMux(int card,int stream) const
int RDHPISoundCard::getInputVolume(int card,int stream,int port)
{
short gain[2];
hpi_err_t hpi_err;
hpi_err=HPI_VolumeGetGain(NULL,
input_stream_volume_control[card][stream][port],gain);
LogHpi(HPI_VolumeGetGain(NULL,
input_stream_volume_control[card][stream][port],gain));
return gain[0];
}
@@ -482,10 +468,9 @@ int RDHPISoundCard::getInputVolume(int card,int stream,int port)
int RDHPISoundCard::getOutputVolume(int card,int stream,int port)
{
short gain[2];
hpi_err_t hpi_err;
hpi_err=HPI_VolumeGetGain(NULL,
output_stream_volume_control[card][stream][port],gain);
LogHpi(HPI_VolumeGetGain(NULL,
output_stream_volume_control[card][stream][port],gain));
return gain[0];
}
@@ -493,10 +478,8 @@ int RDHPISoundCard::getOutputVolume(int card,int stream,int port)
int RDHPISoundCard::getInputLevel(int card,int port)
{
short gain[2];
hpi_err_t hpi_err;
hpi_err=HPI_VolumeGetGain(NULL,
input_port_level_control[card][port],gain);
LogHpi(HPI_VolumeGetGain(NULL,input_port_level_control[card][port],gain));
return gain[0];
}
@@ -504,10 +487,8 @@ int RDHPISoundCard::getInputLevel(int card,int port)
int RDHPISoundCard::getOutputLevel(int card,int port)
{
short gain[2];
hpi_err_t hpi_err;
hpi_err=HPI_VolumeGetGain(NULL,
output_port_level_control[card][port],gain);
LogHpi(HPI_VolumeGetGain(NULL,output_port_level_control[card][port],gain));
return gain[0];
}
@@ -515,31 +496,28 @@ int RDHPISoundCard::getOutputLevel(int card,int port)
void RDHPISoundCard::setInputVolume(int card,int stream,int level)
{
hpi_err_t hpi_err;
if(!haveInputVolume(card,stream,0)) {
return;
}
short gain[2];
gain[0]=level;
gain[1]=level;
hpi_err=HPI_VolumeSetGain(NULL,
input_stream_volume_control[card][stream][0],gain);
LogHpi(HPI_VolumeSetGain(NULL,
input_stream_volume_control[card][stream][0],gain));
}
void RDHPISoundCard::setOutputVolume(int card,int stream,int port,int level)
{
hpi_err_t hpi_err;
if(!haveOutputVolume(card,stream,port)) {
return;
}
short gain[2];
gain[0]=level;
gain[1]=level;
hpi_err=HPI_VolumeSetGain(NULL,
output_stream_volume_control[card][stream][port],gain);
LogHpi(HPI_VolumeSetGain(NULL,
output_stream_volume_control[card][stream][port],
gain));
}
@@ -547,8 +525,6 @@ void RDHPISoundCard::setOutputVolume(int card,int stream,int port,int level)
void RDHPISoundCard::fadeOutputVolume(int card,int stream,int port,
int level,int length)
{
hpi_err_t hpi_err;
if(!haveOutputVolume(card,stream,port)) {
return;
}
@@ -556,15 +532,14 @@ void RDHPISoundCard::fadeOutputVolume(int card,int stream,int port,
gain[0]=level;
gain[1]=level;
hpi_err=HPI_VolumeAutoFadeProfile(NULL,
output_stream_volume_control[card][stream][port],
gain,length,hpi_fade_type);
LogHpi(HPI_VolumeAutoFadeProfile(NULL,
output_stream_volume_control[card][stream][port],
gain,length,hpi_fade_type));
}
void RDHPISoundCard::setInputLevel(int card,int port,int level)
{
hpi_err_t hpi_err;
short gain[HPI_MAX_CHANNELS];
if(!haveInputLevel(card,port)) {
@@ -573,13 +548,12 @@ void RDHPISoundCard::setInputLevel(int card,int port,int level)
for(unsigned i=0;i<HPI_MAX_CHANNELS;i++) {
gain[i]=level;
}
hpi_err=HPI_LevelSetGain(NULL,input_port_level_control[card][port],gain);
LogHpi(HPI_LevelSetGain(NULL,input_port_level_control[card][port],gain));
}
void RDHPISoundCard::setOutputLevel(int card,int port,int level)
{
hpi_err_t hpi_err;
short gain[HPI_MAX_CHANNELS];
if(!haveOutputLevel(card,port)) {
@@ -588,41 +562,34 @@ void RDHPISoundCard::setOutputLevel(int card,int port,int level)
for(unsigned i=0;i<HPI_MAX_CHANNELS;i++) {
gain[i]=level;
}
hpi_err=HPI_LevelSetGain(NULL,output_port_level_control[card][port],gain);
LogHpi(HPI_LevelSetGain(NULL,output_port_level_control[card][port],gain));
}
void RDHPISoundCard::setInputMode(int card,int port,
RDHPISoundCard::ChannelMode mode)
{
uint16_t hpi_err;
if(!haveInputMode(card,port)) {
return;
}
hpi_err=HPI_ChannelModeSet(NULL,input_port_mode_control[card][port],mode+1);
LogHpi(HPI_ChannelModeSet(NULL,input_port_mode_control[card][port],mode+1));
}
void RDHPISoundCard::setOutputMode(int card,int stream,
RDHPISoundCard::ChannelMode mode)
{
uint16_t hpi_err;
if(!haveOutputMode(card,stream)) {
return;
}
hpi_err=
HPI_ChannelModeSet(NULL,output_stream_mode_control[card][stream],mode+1);
LogHpi(HPI_ChannelModeSet(NULL,output_stream_mode_control[card][stream],
mode+1));
}
void RDHPISoundCard::setInputStreamVOX(int card,int stream,short gain)
{
hpi_err_t hpi_err;
hpi_err=HPI_VoxSetThreshold(NULL,
input_stream_vox_control[card][stream],gain);
LogHpi(HPI_VoxSetThreshold(NULL,input_stream_vox_control[card][stream],gain));
}
@@ -635,17 +602,15 @@ bool RDHPISoundCard::havePassthroughVolume(int card,int in_port,int out_port)
bool RDHPISoundCard::setPassthroughVolume(int card,int in_port,int out_port,
int level)
{
hpi_err_t hpi_err;
if(!passthrough_port_volume[card][in_port][out_port]) {
return false;
}
short gain[2];
gain[0]=level;
gain[1]=level;
hpi_err=HPI_VolumeSetGain(NULL,
passthrough_port_volume_control[card][in_port][out_port],
gain);
LogHpi(HPI_VolumeSetGain(NULL,
passthrough_port_volume_control[card][in_port][out_port],
gain));
return true;
}
@@ -678,23 +643,22 @@ void RDHPISoundCard::HPIProbe()
uint16_t l;
uint16_t type;
uint16_t index;
hpi_err_t hpi_err;
QString str;
hpi_fade_type=HPI_VOLUME_AUTOFADE_LOG;
#if HPI_VER < 0x00030600
hpi_err=HPI_SubSysGetVersion(NULL,&dummy_hpi);
LogHpi(HPI_SubSysGetVersion(NULL,&dummy_hpi));
HPI_SubSysFindAdapters(NULL,(uint16_t *)&card_quantity,
hpi_adapter_list,HPI_MAX_ADAPTERS);
#else
hpi_err=HPI_SubSysGetVersionEx(NULL,&dummy_hpi);
hpi_err=HPI_SubSysGetNumAdapters(NULL,&card_quantity);
LogHpi(HPI_SubSysGetVersionEx(NULL,&dummy_hpi));
LogHpi(HPI_SubSysGetNumAdapters(NULL,&card_quantity));
#endif // HPI_VER
for(int i=0;i<card_quantity;i++) {
#if HPI_VER < 0x00030600
card_index[i]=i;
#else
hpi_err=HPI_SubSysGetAdapter(NULL,i,card_index+i,hpi_adapter_list+i);
LogHpi(HPI_SubSysGetAdapter(NULL,i,card_index+i,hpi_adapter_list+i));
#endif // HPI_VER
if((hpi_adapter_list[i]&0xF000)==0x6000) {
timescale_support[i]=true;
@@ -715,12 +679,12 @@ void RDHPISoundCard::HPIProbe()
card_output_ports[i]=0;
card_description[i]=QString().sprintf("AudioScience %04X [%d]",
hpi_adapter_list[i],i+1);
hpi_err=HPI_AdapterOpen(NULL,card_index[i]);
hpi_err=HPI_AdapterGetInfo(NULL,card_index[i],
&card_output_streams[i],
&card_input_streams[i],
&dummy_version,(uint32_t *)&dummy_serial,
&dummy_type);
LogHpi(HPI_AdapterOpen(NULL,card_index[i]));
LogHpi(HPI_AdapterGetInfo(NULL,card_index[i],
&card_output_streams[i],
&card_input_streams[i],
&dummy_version,(uint32_t *)&dummy_serial,
&dummy_type));
hpi_info[i].setSerialNumber(dummy_serial);
hpi_info[i].setHpiVersion(dummy_hpi);
/*
@@ -731,7 +695,7 @@ void RDHPISoundCard::HPIProbe()
hpi_info[i].setDspMinorVersion((dummy_version>>7)&63);
hpi_info[i].setPcbVersion((char)(((dummy_version>>3)&7)+'A'));
hpi_info[i].setAssemblyVersion(dummy_version&7);
hpi_err=HPI_AdapterClose(NULL,card_index[i]);
LogHpi(HPI_AdapterClose(NULL,card_index[i]));
str=QString(tr("Input Stream"));
for(int j=0;j<card_input_streams[i];j++) {
input_stream_description[i][j]=
@@ -750,7 +714,7 @@ void RDHPISoundCard::HPIProbe()
// Mixer Initialization
//
for(int i=0;i<card_quantity;i++) {
hpi_err=HPI_MixerOpen(NULL,card_index[i],&hpi_mixer[i]);
LogHpi(HPI_MixerOpen(NULL,card_index[i],&hpi_mixer[i]));
//
// Get Input Ports
@@ -798,11 +762,11 @@ void RDHPISoundCard::HPIProbe()
card_output_ports[i]);
}
}
hpi_err=HPI_MixerGetControl(NULL,hpi_mixer[i],
HPI_SOURCENODE_CLOCK_SOURCE,0,
0,0,
HPI_CONTROL_SAMPLECLOCK,
&clock_source_control[i]);
LogHpi(HPI_MixerGetControl(NULL,hpi_mixer[i],
HPI_SOURCENODE_CLOCK_SOURCE,0,
0,0,
HPI_CONTROL_SAMPLECLOCK,
&clock_source_control[i]));
for(int j=0;j<card_input_streams[i];j++) {
if(HPI_MixerGetControl(NULL,hpi_mixer[i], // VOX Controls
0,0,
@@ -994,3 +958,15 @@ void RDHPISoundCard::HPIProbe()
connect(clock_timer,SIGNAL(timeout()),this,SLOT(clock()));
clock_timer->start(METER_INTERVAL);
}
hpi_err_t RDHPISoundCard::LogHpi(hpi_err_t err)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s",err_txt);
}
return err;
}

View File

@@ -172,6 +172,7 @@ class RDHPISoundCard : public QObject
private:
void HPIProbe();
hpi_err_t LogHpi(hpi_err_t err);
uint16_t card_input_streams[HPI_MAX_ADAPTERS];
uint16_t card_output_streams[HPI_MAX_ADAPTERS];
uint16_t card_input_ports[HPI_MAX_ADAPTERS];