defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010-2011 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 #include "audioio.hpp" 00012 #include "audiooutputdevice.hpp" 00013 #include <QDebug> 00014 #include "audiocore.hpp" 00015 #include "audiooutputdevicethread.hpp" 00016 00017 using namespace Audio; 00018 00019 AudioOutputDevice::AudioOutputDevice(const QString& name, QAudioDeviceInfo device) 00020 { 00021 _name = name; 00022 _type = OutputDeviceType; 00023 // input->setOutput(this); 00024 audioThread = new AudioOutputDeviceThread(device); 00025 connect(this, SIGNAL(startAudio()), audioThread, SLOT(startAudio())); 00026 connect(this, SIGNAL(pauseAudio()), audioThread, SLOT(pauseAudio())); 00027 connect(this, SIGNAL(stopAudio()), audioThread, SLOT(stopAudio())); 00028 qRegisterMetaType<QAudioFormat>("QAudioFormat"); 00029 connect(this, SIGNAL(changeFormat(QAudioFormat)), audioThread, SLOT(changeFormat(QAudioFormat))); 00030 } 00031 00032 AudioOutputDevice::~AudioOutputDevice() 00033 { 00034 delete audioThread; 00035 } 00036 00037 bool AudioOutputDevice::isStarted() 00038 { 00039 return audioThread->isStarted(); 00040 } 00041 00042 bool AudioOutputDevice::setFormat(QAudioFormat format) 00043 { 00044 //return audioThread->setFormat(format); 00045 emit changeFormat(format); 00046 return true; 00047 } 00048 00049 QAudio::State AudioOutputDevice::state() 00050 { 00051 return audioThread->state(); 00052 } 00053 00054 void AudioOutputDevice::start() 00055 { 00056 emit startAudio(); 00057 } 00058 00059 void AudioOutputDevice::stop() 00060 { 00061 emit stopAudio(); 00062 } 00063 00064 00065 void AudioOutputDevice::pause() 00066 { 00067 emit pauseAudio(); 00068 } 00069 00070 void AudioOutputDevice::setInput(AudioIO *i) 00071 { 00072 input = i; 00073 open(QIODevice::ReadOnly); 00074 audioThread->setInput(this); 00075 } 00076 00077 00078 qint64 AudioOutputDevice::writeData(const char *data, qint64 maxlen) 00079 { 00080 Q_UNUSED(data); 00081 Q_UNUSED(maxlen); 00082 return 0; 00083 } 00084 00085 qint64 AudioOutputDevice::readData(char *data, qint64 maxlen) 00086 { 00087 return input->readData(data, maxlen, this); 00088 } 00089 00090 qint64 AudioOutputDevice::readData(char *data, qint64 maxlen, AudioIO *from) 00091 { 00092 Q_UNUSED(data); 00093 Q_UNUSED(maxlen); 00094 Q_UNUSED(from); 00095 return 0; 00096 } 00097 00098 00099 AudioIO *AudioOutputDevice::getAudioInput(const AudioIO*) 00100 { 00101 return 0; 00102 } 00103 00104 const AudioIO *AudioOutputDevice::getOutputDevice(const AudioIO*) const 00105 { 00106 return 0; 00107 }