From 496dcbb01803c54180c21e1df7869d4758ff02b9 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 23 Oct 2024 16:27:43 -0400 Subject: [PATCH] 2024-10-23 Fred Gleason * Incremented the package version to 4.3.0int6. Signed-off-by: Fred Gleason --- .gitignore | 1 + ChangeLog | 2 + rdhpi/rdhpiplaystream.cpp | 3 +- rdhpi/rdhpiplaystream.h | 5 +- tests/Makefile.am | 11 ++- tests/hpiplayout_test.cpp | 142 ++++++++++++++++++++++++++++++++++++++ tests/hpiplayout_test.h | 60 ++++++++++++++++ 7 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 tests/hpiplayout_test.cpp create mode 100644 tests/hpiplayout_test.h diff --git a/.gitignore b/.gitignore index 7c0e1833..492fe2a4 100644 --- a/.gitignore +++ b/.gitignore @@ -149,6 +149,7 @@ tests/download_test tests/feed_image_test tests/getpids_test tests/gpio_fuzz_test +tests/hpiplayout_test tests/log_unlink_test tests/mcast_recv_test tests/metadata_wildcard_test diff --git a/ChangeLog b/ChangeLog index e419fd8a..e8998907 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24919,3 +24919,5 @@ files to be included in DEB packages. 2024-10-09 Fred Gleason * Fixed a bug that broke the 'make rpm' target. +2024-10-23 Fred Gleason + * Added an 'hpiplayout_test' command in 'tests/'. diff --git a/rdhpi/rdhpiplaystream.cpp b/rdhpi/rdhpiplaystream.cpp index 0ac5a599..fe28e1c6 100644 --- a/rdhpi/rdhpiplaystream.cpp +++ b/rdhpi/rdhpiplaystream.cpp @@ -58,7 +58,8 @@ volatile static int stream_mutex[HPI_MAX_ADAPTERS][HPI_MAX_STREAMS]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; #endif -RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,QWidget *parent) +//RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,QWidget *parent) +RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,QObject *parent) :QObject(parent),RDWaveFile() { int quan; diff --git a/rdhpi/rdhpiplaystream.h b/rdhpi/rdhpiplaystream.h index 39bdb2cd..828362bc 100644 --- a/rdhpi/rdhpiplaystream.h +++ b/rdhpi/rdhpiplaystream.h @@ -26,7 +26,7 @@ #include #include #include -#include +//#include #include #include #include @@ -51,7 +51,8 @@ class RDHPIPlayStream : public QObject,public RDWaveFile public: enum State {Stopped=0,Playing=1,Paused=2}; enum Error {Ok=0,NoFile=1,NoStream=2,AlreadyOpen=3}; - RDHPIPlayStream(RDHPISoundCard *card,QWidget *parent=0); + // RDHPIPlayStream(RDHPISoundCard *card,QWidget *parent=0); + RDHPIPlayStream(RDHPISoundCard *card,QObject *parent=0); ~RDHPIPlayStream(); QString errorString(RDHPIPlayStream::Error err); bool formatSupported(RDWaveFile::Format format); diff --git a/tests/Makefile.am b/tests/Makefile.am index f98cf840..75f69445 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am ## -## (C) Copyright 2002-2023 Fred Gleason +## (C) Copyright 2002-2024 Fred Gleason ## ## 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 @@ -18,8 +18,8 @@ ## ## Use automake to process this into a Makefile.in -AM_CPPFLAGS = -Wall -I$(top_srcdir)/lib -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@ -LIBS = -L$(top_srcdir)/lib +AM_CPPFLAGS = -Wall -I$(top_srcdir)/lib -I$(top_srcdir)/rdhpi -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@ +LIBS = -L$(top_srcdir)/lib -L$(top_srcdir)/rdhpi MOC = @QT_MOC@ # The dependency for qt's Meta Object Compiler (moc) @@ -40,6 +40,7 @@ noinst_PROGRAMS = audio_convert_test\ feed_image_test\ getpids_test\ gpio_fuzz_test\ + hpiplayout_test\ log_unlink_test\ mcast_recv_test\ metadata_wildcard_test\ @@ -105,6 +106,10 @@ getpids_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMA dist_gpio_fuzz_test_SOURCES = gpio_fuzz_test.cpp gpio_fuzz_test.h gpio_fuzz_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ +dist_hpiplayout_test_SOURCES = hpiplayout_test.cpp hpiplayout_test.h +nodist_hpiplayout_test_SOURCES = moc_hpiplayout_test.cpp +hpiplayout_test_LDADD = @LIB_RDLIBS@ @LIBHPI@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ + dist_log_unlink_test_SOURCES = log_unlink_test.cpp log_unlink_test.h nodist_log_unlink_test_SOURCES = moc_log_unlink_test.cpp log_unlink_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ diff --git a/tests/hpiplayout_test.cpp b/tests/hpiplayout_test.cpp new file mode 100644 index 00000000..c5fd57f6 --- /dev/null +++ b/tests/hpiplayout_test.cpp @@ -0,0 +1,142 @@ +// hpiplayout_test.cpp +// +// Test the Rivendell multicast receiver routines +// +// (C) Copyright 2018-2021 Fred Gleason +// +// 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 +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include +#include + +#include + +#include "hpiplayout_test.h" + +MainObject::MainObject(QObject *parent) + : QObject(parent) +{ + QHostAddress from_addr; + int card=0; + int port=0; + bool ok=false; + + RDCmdSwitch *cmd=new RDCmdSwitch("hpiplayout_test",HPIPLAYOUT_TEST_USAGE); + for(unsigned i=0;ikeys();i++) { + if(cmd->key(i)=="--card") { + card=cmd->value(i).toInt(&ok); + if((!ok)||(card<0)||(card>=HPI_MAX_ADAPTERS)) { + fprintf(stderr,"hpiplayout_test: invalid --card\n"); + exit(1); + } + cmd->setProcessed(i,true); + } + if(cmd->key(i)=="--filename") { + d_filename=cmd->value(i); + cmd->setProcessed(i,true); + } + if(cmd->key(i)=="--port") { + port=cmd->value(i).toInt(&ok); + if((!ok)||(port<0)||(port>=HPI_MAX_NODES)) { + fprintf(stderr,"hpiplayout_test: invalid --port\n"); + exit(1); + } + cmd->setProcessed(i,true); + } + if(!cmd->processed(i)) { + fprintf(stderr,"hpiplayout_test: unknown option \"%s\"\n", + cmd->key(i).toUtf8().constData()); + exit(256); + } + } + if(d_filename.isEmpty()) { + fprintf(stderr,"hpiplayout_test: you must provide a \"--filename\"\n"); + exit(1); + } + + d_rdconfig=new RDConfig(); + d_rdconfig->load(); + + d_soundcard=new RDHPISoundCard(d_rdconfig,this); + d_wavedata=new RDWaveData(); + d_playstream=new RDHPIPlayStream(d_soundcard,this); + connect(d_playstream,SIGNAL(isStopped(bool)),this,SLOT(isStoppedData(bool))); + connect(d_playstream,SIGNAL(played()),this,SLOT(playedData())); + connect(d_playstream,SIGNAL(stopped()),this,SLOT(stoppedData())); + connect(d_playstream,SIGNAL(paused()),this,SLOT(pausedData())); + connect(d_playstream,SIGNAL(position(int)),this,SLOT(positionData(int))); + connect(d_playstream,SIGNAL(stateChanged(int,int,int)), + this,SLOT(stateChangedData(int,int,int))); + + d_playstream->setCard(card); + if(d_playstream->openWave(d_filename)!=RDHPIPlayStream::Ok) { + fprintf(stderr,"hpiplayout_test: failed to open \"%s\"\n", + d_filename.toUtf8().constData()); + exit(1); + } + printf("card: %d stream: %d\n",d_playstream->getCard(), + d_playstream->getStream()); + d_soundcard->setOutputVolume(card,d_playstream->getStream(),port,0); + d_playstream->play(); +} + + +void MainObject::isStoppedData(bool state) +{ + printf("isStopped(%u)\n",state); + if(state) { + exit(0); + } +} + + +void MainObject::playedData() +{ + printf("played()\n"); +} + + +void MainObject::pausedData() +{ + printf("isPaused()\n"); +} + + +void MainObject::stoppedData() +{ + printf("stopped()\n"); + exit(0); +} + + +void MainObject::positionData(int samples) +{ + printf("position(%d)\n",samples); + +} + + +void MainObject::stateChangedData(int card,int stream,int state) +{ + printf("stateChanged(%d,%d,%d)\n",card,stream,state); +} + + +int main(int argc,char *argv[]) +{ + QApplication a(argc,argv,false); + new MainObject(); + return a.exec(); +} diff --git a/tests/hpiplayout_test.h b/tests/hpiplayout_test.h new file mode 100644 index 00000000..67e32350 --- /dev/null +++ b/tests/hpiplayout_test.h @@ -0,0 +1,60 @@ +// hpiplayout_test.h +// +// Test the Rivendell HPI playout routines +// +// (C) Copyright 2024 Fred Gleason +// +// 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 +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef HPIPLAYOUT_TEST_H +#define HPIPLAYOUT_TEST_H + +#include + +#include "rdconfig.h" +#include "rdwavefile.h" + +#include "rdhpiplaystream.h" +#include "rdhpisoundcard.h" + +#define HPIPLAYOUT_TEST_USAGE "[options]\n\nTest the Rivendell HPI play-out routines\n\nOptions are:\n--filename=\n WAV file to play\n\n--card=\n Card number [0-15]\n\n--port=\n Port number [0-16]\n\n" + +class MainObject : public QObject +{ + Q_OBJECT; + public: + MainObject(QObject *parent=0); + + private slots: + void isStoppedData(bool state); + void playedData(); + void pausedData(); + void stoppedData(); + void positionData(int samples); + void stateChangedData(int card,int stream,int state); + + private: + QString d_filename; + int d_card; + int d_stream; + int d_port; + RDHPISoundCard *d_soundcard; + RDHPIPlayStream *d_playstream; + RDWaveData *d_wavedata; + RDConfig *d_rdconfig; +}; + + +#endif // HPIPLAYOUT_TEST_H