kconverttest.cc
00001 #include <stdio.h> 00002 00003 #include <tqfile.h> 00004 #include <tqobject.h> 00005 00006 #include <tdelocale.h> 00007 #include <tdeaboutdata.h> 00008 #include <tdecmdlineargs.h> 00009 #include <tdeapplication.h> 00010 00011 #include <flowsystem.h> 00012 #include <kplayobject.h> 00013 #include <kartsdispatcher.h> 00014 #include <kplayobjectfactory.h> 00015 #include <kaudioconverter.h> 00016 #include "kconverttest.moc" 00017 00018 using namespace std; 00019 using namespace Arts; 00020 00021 static TDECmdLineOptions options[] = 00022 { 00023 { "+[URL]", I18N_NOOP("URL to open"), 0 }, 00024 TDECmdLineLastOption 00025 }; 00026 00027 KConvertTest::KConvertTest() 00028 { 00029 } 00030 00031 void KConvertTest::slotRawStreamStart() 00032 { 00033 // cout << "[START]\n\n" << endl; 00034 } 00035 00036 void KConvertTest::slotNewBlockSize(long blockSize) 00037 { 00038 m_blockSize = blockSize; 00039 } 00040 00041 void KConvertTest::slotNewBlockPointer(long blockPointer) 00042 { 00043 m_blockPointer = blockPointer; 00044 } 00045 00046 void KConvertTest::slotNewData() 00047 { 00048 fwrite((void *) m_blockPointer, 1, m_blockSize, stdout); 00049 } 00050 00051 void KConvertTest::slotRawStreamFinished() 00052 { 00053 // cout << "\n\n[END]" << endl; 00054 } 00055 00056 int main(int argc, char **argv) 00057 { 00058 TDEAboutData aboutData("kconverttest", I18N_NOOP("KConvertTest"), I18N_NOOP("0.1"), "", TDEAboutData::License_GPL, ""); 00059 00060 TDECmdLineArgs::init(argc, argv, &aboutData); 00061 TDECmdLineArgs::addCmdLineOptions(options); 00062 TDEApplication app; 00063 00064 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); 00065 00066 KURL url; 00067 00068 if(args->count()) 00069 url = args->arg(0); 00070 else 00071 exit(1); 00072 00073 args->clear(); 00074 00075 KConvertTest *get = new KConvertTest(); 00076 00077 KArtsDispatcher dispatcher; 00078 KAudioConverter converter; 00079 00080 // FIXME: crashes 00081 // converter.setup(44100); 00082 converter.requestPlayObject(url); 00083 00084 TQObject::connect(&converter, TQT_SIGNAL(rawStreamStart()), get, TQT_SLOT(slotRawStreamStart())); 00085 00086 TQObject::connect(&converter, TQT_SIGNAL(newBlockSize(long)), get, TQT_SLOT(slotNewBlockSize(long))); 00087 TQObject::connect(&converter, TQT_SIGNAL(newBlockPointer(long)), get, TQT_SLOT(slotNewBlockPointer(long))); 00088 TQObject::connect(&converter, TQT_SIGNAL(newData()), get, TQT_SLOT(slotNewData())); 00089 00090 TQObject::connect(&converter, TQT_SIGNAL(rawStreamFinished()), get, TQT_SLOT(slotRawStreamFinished())); 00091 00092 converter.start(); 00093 00094 app.exec(); 00095 } 00096