diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
commit | 3f626c3e14f2fe5fdecc38d4265d74f8315b3490 (patch) | |
tree | 357b32156e211a33841e44b7a224313c7072ee46 /src/multimedia | |
parent | 57ce77e953b618739f6f1aec67f8e0de97e05b08 (diff) | |
parent | 6396e7a15079cb157caef319348a0bcd0b95a6a7 (diff) | |
download | Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.zip Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.gz Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.bz2 |
Merge remote branch 'origin/master' into 4.7
Conflicts:
src/corelib/kernel/qmetatype.cpp
src/declarative/graphicsitems/qdeclarativeevents.cpp
src/declarative/graphicsitems/qdeclarativeflickable.cpp
src/declarative/graphicsitems/qdeclarativegridview.cpp
src/declarative/qml/qdeclarativescript.cpp
src/declarative/util/qdeclarativeanimation.cpp
src/declarative/util/qdeclarativebehavior.cpp
src/declarative/util/qdeclarativeeasefollow.cpp
src/declarative/util/qdeclarativefontloader.cpp
src/declarative/util/qdeclarativelistmodel.cpp
src/declarative/util/qdeclarativespringfollow.cpp
src/declarative/util/qdeclarativestategroup.cpp
src/declarative/util/qdeclarativesystempalette.cpp
src/declarative/util/qdeclarativetimer.cpp
src/declarative/util/qmlstateoperations.cpp
src/multimedia/qml/qdeclarativeaudio.cpp
src/multimedia/qml/qdeclarativevideo.cpp
Diffstat (limited to 'src/multimedia')
16 files changed, 332 insertions, 349 deletions
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 45cafc1..fd892dd 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -190,18 +190,18 @@ QAudioInput::~QAudioInput() Passing a QIODevice allows the data to be transfered without any extra code. All that is required is to open the QIODevice. + If able to successfully get audio data from the systems audio device the + state() is set to either QAudio::ActiveState or QAudio::IdleState, + error() is set to QAudio::NoError and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + \sa QIODevice */ void QAudioInput::start(QIODevice* device) { - /* - -If currently not StoppedState, stop - -If previous start was push mode, delete internal QIODevice. - -open audio input. - If ok, NoError and ActiveState, else OpenError and StoppedState. - -emit stateChanged() - */ d->start(device); } @@ -210,19 +210,18 @@ void QAudioInput::start(QIODevice* device) transfer. This QIODevice can be used to read() audio data directly. + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + \sa QIODevice */ QIODevice* QAudioInput::start() { - /* - -If currently not StoppedState, stop - -If no internal QIODevice, create one. - -open audio input. - -If ok, NoError and IdleState, else OpenError and StoppedState - -emit stateChanged() - -return internal QIODevice - */ return d->start(0); } @@ -236,17 +235,14 @@ QAudioFormat QAudioInput::format() const } /*! - Stops the audio input. + Stops the audio input, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. */ void QAudioInput::stop() { - /* - -If StoppedState, return - -set to StoppedState - -detach from audio device - -emit stateChanged() - */ d->stop(); } @@ -256,42 +252,32 @@ void QAudioInput::stop() void QAudioInput::reset() { - /* - -drop all buffered audio, set buffers to zero. - -call stop() - */ d->reset(); } /*! Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emit stateChanged() signal. */ void QAudioInput::suspend() { - /* - -If not ActiveState|IdleState, return - -stop processing audio, saving all buffered audio data - -set NoError and SuspendedState - -emit stateChanged() - */ d->suspend(); } /*! Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. */ void QAudioInput::resume() { - /* - -If SuspendedState, return - -resume audio - -(PULL MODE): set ActiveState, NoError - -(PUSH MODE): set IdleState, NoError - -kick start audio if needed - -emit stateChanged() - */ d->resume(); } @@ -327,6 +313,9 @@ int QAudioInput::bufferSize() const /*! Returns the amount of audio data available to read in bytes. + + NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. */ int QAudioInput::bytesReady() const @@ -352,7 +341,10 @@ int QAudioInput::periodSize() const /*! Sets the interval for notify() signal to be emitted. This is based on the \a ms of audio data processed - not on actual real-time. The resolution of the timer is platform specific. + not on actual real-time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm actual value + being used. */ void QAudioInput::setNotifyInterval(int ms) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 26e46b3..6010f3c 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -217,9 +217,11 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) //set to pull mode pullMode = true; audioSource = device; + deviceState = QAudio::ActiveState; } else { //set to push mode pullMode = false; + deviceState = QAudio::IdleState; audioSource = new InputPrivate(this); audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); } @@ -413,7 +415,6 @@ bool QAudioInputPrivate::open() timer->start(period_time*chunks/2000); errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; totalTimeValue = 0; @@ -439,7 +440,7 @@ int QAudioInputPrivate::bytesReady() const if(resuming) return period_size; - if(deviceState != QAudio::ActiveState) + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) return 0; int frames = snd_pcm_avail_update(handle); if((int)frames > (int)buffer_frames) @@ -450,8 +451,8 @@ int QAudioInputPrivate::bytesReady() const qint64 QAudioInputPrivate::read(char* data, qint64 len) { - Q_UNUSED(data) Q_UNUSED(len) + // Read in some audio data and write it to QIODevice, pull mode if ( !handle ) return 0; @@ -468,7 +469,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if (readFrames >= 0) { err = snd_pcm_frames_to_bytes(handle, readFrames); #ifdef DEBUG_AUDIO - qDebug()<<QString::fromLatin1("PULL: read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData(); + qDebug()<<QString::fromLatin1("read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData(); #endif break; } else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) { @@ -489,28 +490,46 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(err > 0) { // got some send it onward #ifdef DEBUG_AUDIO - qDebug()<<"PULL: frames to write to QIODevice = "<< + qDebug()<<"frames to write to QIODevice = "<< snd_pcm_bytes_to_frames( handle, (int)err )<<" ("<<err<<") bytes"; #endif - if(deviceState != QAudio::ActiveState) + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) return 0; + if (pullMode) { + qint64 l = audioSource->write(audioBuffer,err); + if(l < 0) { + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + } else if(l == 0) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::NoError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } else { + totalTimeValue += err; + resuming = false; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + return l; - qint64 l = audioSource->write(audioBuffer,err); - if(l < 0) { - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - } else if(l == 0) { - errorState = QAudio::NoError; - deviceState = QAudio::IdleState; } else { - totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency(); + memcpy(data,audioBuffer,err); + totalTimeValue += err; resuming = false; - errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + return err; } - return l; } return 0; } @@ -569,7 +588,7 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::processedUSecs() const { - return totalTimeValue; + return qint64(1000000) * totalTimeValue / settings.frequency(); } void QAudioInputPrivate::suspend() @@ -617,34 +636,10 @@ bool QAudioInputPrivate::deviceReady() qint64 QAudioInputPrivate::elapsedUSecs() const { - if(!handle) - return 0; - if (deviceState == QAudio::StoppedState) return 0; -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - snd_pcm_status_t* status; - snd_pcm_status_alloca(&status); - - snd_timestamp_t t1,t2; - if( snd_pcm_status(handle, status) >= 0) { - snd_pcm_status_get_tstamp(status,&t1); - snd_pcm_status_get_trigger_tstamp(status,&t2); - t1.tv_sec-=t2.tv_sec; - - signed long l = (signed long)t1.tv_usec - (signed long)t2.tv_usec; - if(l < 0) { - t1.tv_sec--; - l = -l; - l %= 1000000; - } - return ((t1.tv_sec * 1000000)+l); - } else - return 0; -#else return clockStamp.elapsed()*1000; -#endif } void QAudioInputPrivate::reset() @@ -670,43 +665,7 @@ InputPrivate::~InputPrivate() qint64 InputPrivate::readData( char* data, qint64 len) { - // push mode, user read() called - if((audioDevice->state() != QAudio::ActiveState) && !audioDevice->resuming) - return 0; - - int readFrames; - int count=0, err = 0; - - while(count < 5) { - int frames = snd_pcm_bytes_to_frames(audioDevice->handle, len); - readFrames = snd_pcm_readi(audioDevice->handle, data, frames); - if (readFrames >= 0) { - err = snd_pcm_frames_to_bytes(audioDevice->handle, readFrames); -#ifdef DEBUG_AUDIO - qDebug()<<QString::fromLatin1("PUSH: read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData(); -#endif - break; - } else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) { - audioDevice->errorState = QAudio::IOError; - err = 0; - break; - } else { - if(readFrames == -EPIPE) { - audioDevice->errorState = QAudio::UnderrunError; - err = snd_pcm_prepare(audioDevice->handle); - } else if(readFrames == -ESTRPIPE) { - err = snd_pcm_prepare(audioDevice->handle); - } - if(err != 0) break; - } - count++; - } - if(err > 0 && readFrames > 0) { - audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000; - audioDevice->deviceState = QAudio::ActiveState; - return err; - } - return 0; + return audioDevice->read(data,len); } qint64 InputPrivate::writeData(const char* data, qint64 len) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index cc4fdee..594f6ca 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -192,9 +192,11 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) //set to pull mode pullMode = true; audioSource = device; + deviceState = QAudio::ActiveState; } else { //set to push mode pullMode = false; + deviceState = QAudio::IdleState; audioSource = new InputPrivate(this); audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); } @@ -311,7 +313,6 @@ bool QAudioInputPrivate::open() elapsedTimeOffset = 0; totalTimeValue = 0; errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; return true; } @@ -320,9 +321,9 @@ void QAudioInputPrivate::close() if(deviceState == QAudio::StoppedState) return; + deviceState = QAudio::StoppedState; waveInReset(hWaveIn); waveInClose(hWaveIn); - deviceState = QAudio::StoppedState; int count = 0; while(!finished && count < 500) { @@ -357,7 +358,6 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) char* p = data; qint64 l = 0; qint64 written = 0; - while(!done) { // Read in some audio data if(waveBlocks[header].dwBytesRecorded > 0 && waveBlocks[header].dwFlags & WHDR_DONE) { @@ -378,11 +378,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) errorState = QAudio::IOError; } else { - totalTimeValue += waveBlocks[header].dwBytesRecorded - /((settings.channels()*settings.sampleSize()/8)) - *10000/settings.frequency()*100; + totalTimeValue += waveBlocks[header].dwBytesRecorded; errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } resuming = false; } } else { @@ -392,16 +393,17 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) #ifdef DEBUG_AUDIO qDebug()<<"IN: "<<waveBlocks[header].dwBytesRecorded<<", OUT: "<<l; #endif - totalTimeValue += waveBlocks[header].dwBytesRecorded - /((settings.channels()*settings.sampleSize()/8)) - *10000/settings.frequency()*100; + totalTimeValue += waveBlocks[header].dwBytesRecorded; errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } resuming = false; } } else { //no data, not ready yet, next time - return 0; + break; } waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR)); @@ -510,7 +512,13 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::processedUSecs() const { - return totalTimeValue; + if (deviceState == QAudio::StoppedState) + return 0; + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; } void QAudioInputPrivate::suspend() @@ -540,6 +548,9 @@ bool QAudioInputPrivate::deviceReady() QTime now(QTime::currentTime()); qDebug()<<now.second()<<"s "<<now.msec()<<"ms :deviceReady() INPUT"; #endif + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return true; + if(pullMode) { // reads some audio data and writes it to QIODevice read(0,0); @@ -548,8 +559,6 @@ bool QAudioInputPrivate::deviceReady() InputPrivate* a = qobject_cast<InputPrivate*>(audioSource); a->trigger(); } - if(deviceState != QAudio::ActiveState) - return true; if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); @@ -582,7 +591,8 @@ InputPrivate::~InputPrivate() {} qint64 InputPrivate::readData( char* data, qint64 len) { // push mode, user read() called - if(audioDevice->deviceState != QAudio::ActiveState) + if(audioDevice->deviceState != QAudio::ActiveState && + audioDevice->deviceState != QAudio::IdleState) return 0; // Read in some audio data return audioDevice->read(data,len); diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index afd8a84..b0b5244 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -202,18 +202,18 @@ QAudioFormat QAudioOutput::format() const Passing a QIODevice allows the data to be transfered without any extra code. All that is required is to open the QIODevice. + If able to successfully output audio data to the systems audio device the + state() is set to QAudio::ActiveState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + \sa QIODevice */ void QAudioOutput::start(QIODevice* device) { - /* - -If currently not StoppedState, stop. - -If previous start was push mode, delete internal QIODevice. - -open audio output. - -If ok, NoError and ActiveState, else OpenError and StoppedState - -emit stateChanged() - */ d->start(device); } @@ -221,34 +221,30 @@ void QAudioOutput::start(QIODevice* device) Returns a pointer to the QIODevice being used to handle the data transfer. This QIODevice can be used to write() audio data directly. + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + \sa QIODevice */ QIODevice* QAudioOutput::start() { - /* - -If currently not StoppedState, stop. - -If no internal QIODevice, create one. - -open audio output. - -If ok, NoError and IdleState, else OpenError and StoppedState - -emit stateChanged() - -return internal QIODevice - */ return d->start(0); } /*! - Stops the audio output. + Stops the audio output, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. */ void QAudioOutput::stop() { - /* - -If StoppedState, return - -set to StoppedState - -detach from audio device - -emit stateChanged() - */ d->stop(); } @@ -258,55 +254,44 @@ void QAudioOutput::stop() void QAudioOutput::reset() { - /* - -drop all buffered audio, set buffers to zero. - -call stop() - */ d->reset(); } /*! Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emit stateChanged() signal. */ void QAudioOutput::suspend() { - /* - -If not ActiveState|IdleState, return - -stop processing audio, saving all buffered audio data - -set NoError and SuspendedState - -emit stateChanged() - */ d->suspend(); } /*! Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. */ void QAudioOutput::resume() { - /* - -If SuspendedState, return - -resume audio - -(PULL MODE): set ActiveState, NoError - -(PUSH MODE): set IdleState, NoError - -kick start audio if needed - -emit stateChanged() - */ d->resume(); } /*! Returns the free space available in bytes in the audio buffer. + + NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. */ int QAudioOutput::bytesFree() const { - /* - -If not ActiveState|IdleState, return 0 - -return space available in audio buffer in bytes - */ return d->bytesFree(); } @@ -353,7 +338,10 @@ int QAudioOutput::bufferSize() const /*! Sets the interval for notify() signal to be emitted. This is based on the \a ms of audio data processed - not on actual real-time. The resolution of the timer is platform specific. + not on actual real-time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm actual value + being used. */ void QAudioOutput::setNotifyInterval(int ms) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 7b89cef..b127103 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -259,6 +259,7 @@ void QAudioOutputPrivate::stop() { if(deviceState == QAudio::StoppedState) return; + errorState = QAudio::NoError; deviceState = QAudio::StoppedState; close(); emit stateChanged(deviceState); @@ -494,10 +495,13 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) err = snd_pcm_writei( handle, data, frames ); } if(err > 0) { - totalTimeValue += err*1000000/settings.frequency(); + totalTimeValue += err; resuming = false; errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } return snd_pcm_frames_to_bytes( handle, err ); } else err = xrun_recovery(err); @@ -542,7 +546,7 @@ int QAudioOutputPrivate::notifyInterval() const qint64 QAudioOutputPrivate::processedUSecs() const { - return totalTimeValue; + return qint64(1000000) * totalTimeValue / settings.frequency(); } void QAudioOutputPrivate::resume() @@ -562,10 +566,8 @@ void QAudioOutputPrivate::resume() bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames); } resuming = true; - if(pullMode) - deviceState = QAudio::ActiveState; - else - deviceState = QAudio::IdleState; + + deviceState = QAudio::ActiveState; errorState = QAudio::NoError; timer->start(period_time/1000); @@ -637,7 +639,9 @@ bool QAudioOutputPrivate::deviceReady() // Got some data to output if(deviceState != QAudio::ActiveState) return true; - write(audioBuffer,l); + qint64 bytesWritten = write(audioBuffer,l); + if (bytesWritten != l) + audioSource->seek(audioSource->pos()-(l-bytesWritten)); bytesAvailable = bytesFree(); } else if(l == 0) { @@ -645,9 +649,11 @@ bool QAudioOutputPrivate::deviceReady() bytesAvailable = bytesFree(); if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) { // Underrun - errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } } } else if(l < 0) { @@ -655,8 +661,17 @@ bool QAudioOutputPrivate::deviceReady() errorState = QAudio::IOError; emit stateChanged(deviceState); } - } else + } else { bytesAvailable = bytesFree(); + if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) { + // Underrun + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } + } if(deviceState != QAudio::ActiveState) return true; @@ -671,35 +686,10 @@ bool QAudioOutputPrivate::deviceReady() qint64 QAudioOutputPrivate::elapsedUSecs() const { - if(!handle) - return 0; - if (deviceState == QAudio::StoppedState) return 0; -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - snd_pcm_status_t* status; - snd_pcm_status_alloca(&status); - - snd_timestamp_t t1,t2; - if( snd_pcm_status(handle, status) >= 0) { - snd_pcm_status_get_tstamp(status,&t1); - snd_pcm_status_get_trigger_tstamp(status,&t2); - t1.tv_sec-=t2.tv_sec; - - signed long l = (signed long)t1.tv_usec - (signed long)t2.tv_usec; - if(l < 0) { - t1.tv_sec--; - l = -l; - l %= 1000000; - } - return ((t1.tv_sec * 1000000)+l); - } else - return 0; -#else return clockStamp.elapsed()*1000; -#endif - return 0; } void QAudioOutputPrivate::reset() diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index bce45c1..6200160 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -211,6 +211,13 @@ bool QAudioOutputPrivate::open() QTime now(QTime::currentTime()); qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()"; #endif + if (!(settings.frequency() >= 8000 && settings.frequency() <= 48000)) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error, frequency out of range."); + return false; + } if(buffer_size == 0) { // Default buffer size, 200ms, default period size is 40ms buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; @@ -289,6 +296,7 @@ void QAudioOutputPrivate::close() return; deviceState = QAudio::StoppedState; + errorState = QAudio::NoError; int delay = (buffer_size-bytesFree())*1000/(settings.frequency() *settings.channels()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); @@ -340,12 +348,20 @@ int QAudioOutputPrivate::notifyInterval() const qint64 QAudioOutputPrivate::processedUSecs() const { - return totalTimeValue; + if (deviceState == QAudio::StoppedState) + return 0; + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; } qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) { // Write out some audio data + if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; char* p = (char*)data; int l = (int)len; @@ -385,13 +401,16 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) current->dwBufferLength,waveFreeBlockCount); LeaveCriticalSection(&waveOutCriticalSection); #endif - totalTimeValue += current->dwBufferLength - /(settings.channels()*(settings.sampleSize()/8)) - *1000000/settings.frequency();; + totalTimeValue += current->dwBufferLength; waveCurrentBlock++; waveCurrentBlock %= buffer_size/period_size; current = &waveBlocks[waveCurrentBlock]; current->dwUser = 0; + errorState = QAudio::NoError; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } } return (len-l); } @@ -409,8 +428,11 @@ void QAudioOutputPrivate::resume() void QAudioOutputPrivate::suspend() { - if(deviceState == QAudio::ActiveState) { + if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { + int delay = (buffer_size-bytesFree())*1000/(settings.frequency() + *settings.channels()*(settings.sampleSize()/8)); waveOutPause(hWaveOut); + Sleep(delay+10); deviceState = QAudio::SuspendedState; errorState = QAudio::NoError; emit stateChanged(deviceState); @@ -465,8 +487,16 @@ bool QAudioOutputPrivate::deviceReady() int l = audioSource->read(audioBuffer,input); if(l > 0) { int out= write(audioBuffer,l); - if(out > 0) - deviceState = QAudio::ActiveState; + if(out > 0) { + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + if ( out < l) { + // Didnt write all data + audioSource->seek(audioSource->pos()-(l-out)); + } if(startup) waveOutRestart(hWaveOut); } else if(l == 0) { @@ -478,16 +508,28 @@ bool QAudioOutputPrivate::deviceReady() LeaveCriticalSection(&waveOutCriticalSection); if(check == buffer_size/period_size) { errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); + if (deviceState != QAudio::IdleState) { + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } } } else if(l < 0) { bytesAvailable = bytesFree(); errorState = QAudio::IOError; } + } else { + int buffered; + EnterCriticalSection(&waveOutCriticalSection); + buffered = waveFreeBlockCount; + LeaveCriticalSection(&waveOutCriticalSection); + errorState = QAudio::UnderrunError; + if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } } - if(deviceState != QAudio::ActiveState) + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) return true; if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { diff --git a/src/multimedia/qml/multimediaqml.cpp b/src/multimedia/qml/multimediadeclarative.cpp index be49915..7f5298f 100644 --- a/src/multimedia/qml/multimediaqml.cpp +++ b/src/multimedia/qml/multimediadeclarative.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#include <QtMultimedia/multimediaqml.h> +#include <QtMultimedia/multimediadeclarative.h> #include <QtMultimedia/private/qsoundeffect_p.h> -#include <QtMultimedia/private/qmlaudio_p.h> -#include <QtMultimedia/private/qmlgraphicsvideo_p.h> +#include <QtMultimedia/private/qdeclarativeaudio_p.h> +#include <QtMultimedia/private/qdeclarativevideo_p.h> QT_BEGIN_NAMESPACE @@ -55,11 +55,13 @@ namespace QtMultimedia \internal */ -void qRegisterQmlElements() +void qRegisterDeclarativeElements(const char *uri) { - qmlRegisterType<QSoundEffect>("Qt.multimedia", 4, 7, "SoundEffect", "SoundEffect"); - qmlRegisterType<QmlAudio>("Qt.multimedia", 4, 7, "Audio", "Audio"); - qmlRegisterType<QmlGraphicsVideo>("Qt.multimedia", 4, 7, "Video", "Video"); + Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimedia")); + + qmlRegisterType<QSoundEffect>(uri, 4, 7, "SoundEffect"); + qmlRegisterType<QDeclarativeAudio>(uri, 4, 7, "Audio"); + qmlRegisterType<QDeclarativeVideo>(uri, 4, 7, "Video"); } } diff --git a/src/multimedia/qml/multimediaqml.h b/src/multimedia/qml/multimediadeclarative.h index 41274c8..29af65a 100644 --- a/src/multimedia/qml/multimediaqml.h +++ b/src/multimedia/qml/multimediadeclarative.h @@ -51,7 +51,7 @@ QT_MODULE(Multimedia) namespace QtMultimedia { -extern void Q_MULTIMEDIA_EXPORT qRegisterQmlElements(); +extern void Q_MULTIMEDIA_EXPORT qRegisterDeclarativeElements(const char *uri); } QT_END_NAMESPACE diff --git a/src/multimedia/qml/qmlaudio.cpp b/src/multimedia/qml/qdeclarativeaudio.cpp index 80f5678..1cbf594 100644 --- a/src/multimedia/qml/qmlaudio.cpp +++ b/src/multimedia/qml/qdeclarativeaudio.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmlaudio_p.h" +#include "qdeclarativeaudio_p.h" #include <QtMultimedia/qmediaplayercontrol.h> @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE /*! - \qmlclass Audio QmlAudio + \qmlclass Audio QDeclarativeAudio \since 4.7 \brief The Audio element allows you to add audio playback to a scene. @@ -60,11 +60,11 @@ QT_BEGIN_NAMESPACE /*! \internal - \class QmlAudio - \brief The QmlAudio class provides an audio item that you can add to a QmlView. + \class QDeclarativeAudio + \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView. */ -void QmlAudio::_q_error(int errorCode, const QString &errorString) +void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString) { m_error = QMediaPlayer::Error(errorCode); m_errorString = errorString; @@ -74,13 +74,13 @@ void QmlAudio::_q_error(int errorCode, const QString &errorString) } -QmlAudio::QmlAudio(QObject *parent) +QDeclarativeAudio::QDeclarativeAudio(QObject *parent) : QObject(parent) { setObject(this); } -QmlAudio::~QmlAudio() +QDeclarativeAudio::~QDeclarativeAudio() { shutdown(); } @@ -93,7 +93,7 @@ QmlAudio::~QmlAudio() Sets the \l playing property to true, and the \l paused property to false. */ -void QmlAudio::play() +void QDeclarativeAudio::play() { m_playerControl->play(); @@ -111,7 +111,7 @@ void QmlAudio::play() Sets the \l playing and \l paused properties to true. */ -void QmlAudio::pause() +void QDeclarativeAudio::pause() { m_playerControl->pause(); @@ -129,7 +129,7 @@ void QmlAudio::pause() Sets the \l playing and \l paused properties to false. */ -void QmlAudio::stop() +void QDeclarativeAudio::stop() { m_playerControl->stop(); @@ -203,7 +203,7 @@ void QmlAudio::stop() \endlist */ -QmlAudio::Status QmlAudio::status() const +QDeclarativeAudio::Status QDeclarativeAudio::status() const { return Status(m_status); } @@ -302,7 +302,7 @@ QmlAudio::Status QmlAudio::status() const \endlist */ -QmlAudio::Error QmlAudio::error() const +QDeclarativeAudio::Error QDeclarativeAudio::error() const { return Error(m_error); } @@ -322,6 +322,6 @@ QmlAudio::Error QmlAudio::error() const QT_END_NAMESPACE -#include "moc_qmlaudio_p.cpp" +#include "moc_qdeclarativeaudio_p.cpp" diff --git a/src/multimedia/qml/qmlaudio_p.h b/src/multimedia/qml/qdeclarativeaudio_p.h index bb0d301..d1fb275 100644 --- a/src/multimedia/qml/qmlaudio_p.h +++ b/src/multimedia/qml/qdeclarativeaudio_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLAUDIO_P_H -#define QMLAUDIO_P_H +#ifndef QDECLARATIVEAUDIO_P_H +#define QDECLARATIVEAUDIO_P_H // // W A R N I N G @@ -53,10 +53,10 @@ // We mean it. // -#include <QtMultimedia/private/qmlmediabase_p.h> +#include <QtMultimedia/private/qdeclarativemediabase_p.h> #include <QtCore/qbasictimer.h> -#include <QtDeclarative/qmlgraphicsitem.h> +#include <QtDeclarative/qdeclarativeitem.h> QT_BEGIN_HEADER @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class QTimerEvent; -class Q_AUTOTEST_EXPORT QmlAudio : public QObject, public QmlMediaBase, public QmlParserStatus +class Q_AUTOTEST_EXPORT QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) @@ -83,7 +83,7 @@ class Q_AUTOTEST_EXPORT QmlAudio : public QObject, public QmlMediaBase, public Q Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) Q_ENUMS(Status) Q_ENUMS(Error) - Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QDeclarativeParserStatus) public: enum Status { @@ -108,8 +108,8 @@ public: ServiceMissing = QMediaPlayer::ServiceMissingError }; - QmlAudio(QObject *parent = 0); - ~QmlAudio(); + QDeclarativeAudio(QObject *parent = 0); + ~QDeclarativeAudio(); Status status() const; Error error() const; @@ -150,23 +150,23 @@ Q_SIGNALS: void playbackRateChanged(); void errorChanged(); - void error(QmlAudio::Error error, const QString &errorString); + void error(QDeclarativeAudio::Error error, const QString &errorString); private Q_SLOTS: void _q_error(int, const QString &); private: - Q_DISABLE_COPY(QmlAudio) + Q_DISABLE_COPY(QDeclarativeAudio) Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State)) Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - inline QmlMediaBase *mediaBase() { return this; } + inline QDeclarativeMediaBase *mediaBase() { return this; } }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QmlAudio)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio)) QT_END_HEADER diff --git a/src/multimedia/qml/qmlmediabase.cpp b/src/multimedia/qml/qdeclarativemediabase.cpp index 11b4337..e054cb2 100644 --- a/src/multimedia/qml/qmlmediabase.cpp +++ b/src/multimedia/qml/qdeclarativemediabase.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "QtMultimedia/private/qmlmediabase_p.h" +#include "QtMultimedia/private/qdeclarativemediabase_p.h" #include <QtCore/qcoreevent.h> #include <QtCore/qurl.h> @@ -55,19 +55,19 @@ QT_BEGIN_NAMESPACE -class QmlMediaBaseObject : public QMediaObject +class QDeclarativeMediaBaseObject : public QMediaObject { public: - QmlMediaBaseObject(QMediaService *service) + QDeclarativeMediaBaseObject(QMediaService *service) : QMediaObject(0, service) { } }; -class QmlMediaBasePlayerControl : public QMediaPlayerControl +class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl { public: - QmlMediaBasePlayerControl(QObject *parent) + QDeclarativeMediaBasePlayerControl(QObject *parent) : QMediaPlayerControl(parent) { } @@ -98,10 +98,10 @@ public: void stop() {} }; -class QmlMediaBaseAnimation : public QObject +class QDeclarativeMediaBaseAnimation : public QObject { public: - QmlMediaBaseAnimation(QmlMediaBase *media) + QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media) : m_media(media) { } @@ -125,11 +125,11 @@ protected: } private: - QmlMediaBase *m_media; + QDeclarativeMediaBase *m_media; QBasicTimer m_timer; }; -void QmlMediaBase::_q_stateChanged(QMediaPlayer::State state) +void QDeclarativeMediaBase::_q_stateChanged(QMediaPlayer::State state) { if (state != m_state) { QMediaPlayer::State oldState = m_state; @@ -170,7 +170,7 @@ void QmlMediaBase::_q_stateChanged(QMediaPlayer::State state) } } -void QmlMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) +void QDeclarativeMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) { if (status != m_status) { m_status = status; @@ -207,12 +207,12 @@ void QmlMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) } } -void QmlMediaBase::_q_metaDataChanged() +void QDeclarativeMediaBase::_q_metaDataChanged() { m_metaObject->metaDataChanged(); } -QmlMediaBase::QmlMediaBase() +QDeclarativeMediaBase::QDeclarativeMediaBase() : m_mediaService(0) , m_playerControl(0) , m_mediaObject(0) @@ -227,11 +227,11 @@ QmlMediaBase::QmlMediaBase() { } -QmlMediaBase::~QmlMediaBase() +QDeclarativeMediaBase::~QDeclarativeMediaBase() { } -void QmlMediaBase::shutdown() +void QDeclarativeMediaBase::shutdown() { delete m_metaObject; delete m_mediaObject; @@ -243,7 +243,7 @@ void QmlMediaBase::shutdown() } -void QmlMediaBase::setObject(QObject *object) +void QDeclarativeMediaBase::setObject(QObject *object) { if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) { if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) { @@ -251,7 +251,7 @@ void QmlMediaBase::setObject(QObject *object) m_mediaService->control(QMediaPlayerControl_iid)); m_metaDataControl = qobject_cast<QMetaDataControl *>( m_mediaService->control(QMetaDataControl_iid)); - m_mediaObject = new QmlMediaBaseObject(m_mediaService); + m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService); } } @@ -279,11 +279,11 @@ void QmlMediaBase::setObject(QObject *object) QObject::connect(m_playerControl, SIGNAL(error(int,QString)), object, SLOT(_q_error(int,QString))); - m_animation = new QmlMediaBaseAnimation(this); + m_animation = new QDeclarativeMediaBaseAnimation(this); } else { m_error = QMediaPlayer::ServiceMissingError; - m_playerControl = new QmlMediaBasePlayerControl(object); + m_playerControl = new QDeclarativeMediaBasePlayerControl(object); } if (m_metaDataControl) { @@ -294,12 +294,12 @@ void QmlMediaBase::setObject(QObject *object) } } -QUrl QmlMediaBase::source() const +QUrl QDeclarativeMediaBase::source() const { return m_playerControl->media().canonicalUrl(); } -void QmlMediaBase::setSource(const QUrl &url) +void QDeclarativeMediaBase::setSource(const QUrl &url) { if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) { m_error = QMediaPlayer::NoError; @@ -311,12 +311,12 @@ void QmlMediaBase::setSource(const QUrl &url) m_playerControl->setMedia(QMediaContent(url), 0); } -bool QmlMediaBase::isPlaying() const +bool QDeclarativeMediaBase::isPlaying() const { return m_state != QMediaPlayer::StoppedState; } -void QmlMediaBase::setPlaying(bool playing) +void QDeclarativeMediaBase::setPlaying(bool playing) { if (playing && m_state == QMediaPlayer::StoppedState) { if (m_paused) @@ -328,12 +328,12 @@ void QmlMediaBase::setPlaying(bool playing) } } -bool QmlMediaBase::isPaused() const +bool QDeclarativeMediaBase::isPaused() const { return m_paused; } -void QmlMediaBase::setPaused(bool paused) +void QDeclarativeMediaBase::setPaused(bool paused) { if (m_paused != paused) { if (paused && m_state == QMediaPlayer::PlayingState) { @@ -348,63 +348,63 @@ void QmlMediaBase::setPaused(bool paused) } } -int QmlMediaBase::duration() const +int QDeclarativeMediaBase::duration() const { return m_playerControl->duration(); } -int QmlMediaBase::position() const +int QDeclarativeMediaBase::position() const { return m_playerControl->position(); } -void QmlMediaBase::setPosition(int position) +void QDeclarativeMediaBase::setPosition(int position) { m_playerControl->setPosition(position); } -qreal QmlMediaBase::volume() const +qreal QDeclarativeMediaBase::volume() const { return qreal(m_playerControl->volume()) / 100; } -void QmlMediaBase::setVolume(qreal volume) +void QDeclarativeMediaBase::setVolume(qreal volume) { m_playerControl->setVolume(qRound(volume * 100)); } -bool QmlMediaBase::isMuted() const +bool QDeclarativeMediaBase::isMuted() const { return m_playerControl->isMuted(); } -void QmlMediaBase::setMuted(bool muted) +void QDeclarativeMediaBase::setMuted(bool muted) { m_playerControl->setMuted(muted); } -qreal QmlMediaBase::bufferProgress() const +qreal QDeclarativeMediaBase::bufferProgress() const { return qreal(m_playerControl->bufferStatus()) / 100; } -bool QmlMediaBase::isSeekable() const +bool QDeclarativeMediaBase::isSeekable() const { return m_playerControl->isSeekable(); } -qreal QmlMediaBase::playbackRate() const +qreal QDeclarativeMediaBase::playbackRate() const { return m_playerControl->playbackRate(); } -void QmlMediaBase::setPlaybackRate(qreal rate) +void QDeclarativeMediaBase::setPlaybackRate(qreal rate) { m_playerControl->setPlaybackRate(rate); } -QString QmlMediaBase::errorString() const +QString QDeclarativeMediaBase::errorString() const { return m_errorString; } diff --git a/src/multimedia/qml/qmlmediabase_p.h b/src/multimedia/qml/qdeclarativemediabase_p.h index d6ad9b3..2fc48db 100644 --- a/src/multimedia/qml/qmlmediabase_p.h +++ b/src/multimedia/qml/qdeclarativemediabase_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLMEDIABASE_P_H -#define QMLMEDIABASE_P_H +#ifndef QDECLARATIVEMEDIABASE_P_H +#define QDECLARATIVEMEDIABASE_P_H // // W A R N I N G @@ -65,13 +65,13 @@ class QMediaService; class QMediaServiceProvider; class QMetaDataControl; class QMetaDataControlMetaObject; -class QmlMediaBaseAnimation; +class QDeclarativeMediaBaseAnimation; -class Q_AUTOTEST_EXPORT QmlMediaBase +class Q_AUTOTEST_EXPORT QDeclarativeMediaBase { public: - QmlMediaBase(); - virtual ~QmlMediaBase(); + QDeclarativeMediaBase(); + virtual ~QDeclarativeMediaBase(); QUrl source() const; void setSource(const QUrl &url); @@ -150,7 +150,7 @@ protected: QMediaServiceProvider *m_mediaProvider; QMetaDataControl *m_metaDataControl; QMetaDataControlMetaObject *m_metaObject; - QmlMediaBaseAnimation *m_animation; + QDeclarativeMediaBaseAnimation *m_animation; QMediaPlayer::State m_state; QMediaPlayer::MediaStatus m_status; @@ -158,7 +158,7 @@ protected: bool m_paused; QString m_errorString; - friend class QmlMediaBaseAnimation; + friend class QDeclarativeMediaBaseAnimation; }; QT_END_NAMESPACE diff --git a/src/multimedia/qml/qmlgraphicsvideo.cpp b/src/multimedia/qml/qdeclarativevideo.cpp index baf96ba..7f62075 100644 --- a/src/multimedia/qml/qmlgraphicsvideo.cpp +++ b/src/multimedia/qml/qdeclarativevideo.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmlgraphicsvideo_p.h" +#include "qdeclarativevideo_p.h" #include <QtMultimedia/qmediaplayercontrol.h> #include <QtMultimedia/qmediaservice.h> @@ -51,13 +51,13 @@ QT_BEGIN_NAMESPACE -void QmlGraphicsVideo::_q_nativeSizeChanged(const QSizeF &size) +void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size) { setImplicitWidth(size.width()); setImplicitHeight(size.height()); } -void QmlGraphicsVideo::_q_error(int errorCode, const QString &errorString) +void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) { m_error = QMediaPlayer::Error(errorCode); m_errorString = errorString; @@ -68,7 +68,7 @@ void QmlGraphicsVideo::_q_error(int errorCode, const QString &errorString) /*! - \qmlclass Video QmlGraphicsVideo + \qmlclass Video QDeclarativeVideo \since 4.7 \brief The Video element allows you to add videos to a scene. \inherits Item @@ -88,12 +88,12 @@ void QmlGraphicsVideo::_q_error(int errorCode, const QString &errorString) /*! \internal - \class QmlGraphicsVideo - \brief The QmlGraphicsVideo class provides a video item that you can add to a QmlView. + \class QDeclarativeVideo + \brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView. */ -QmlGraphicsVideo::QmlGraphicsVideo(QmlGraphicsItem *parent) - : QmlGraphicsItem(parent) +QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent) + : QDeclarativeItem(parent) , m_graphicsItem(0) { @@ -113,7 +113,7 @@ QmlGraphicsVideo::QmlGraphicsVideo(QmlGraphicsItem *parent) } } -QmlGraphicsVideo::~QmlGraphicsVideo() +QDeclarativeVideo::~QDeclarativeVideo() { shutdown(); @@ -184,7 +184,7 @@ QmlGraphicsVideo::~QmlGraphicsVideo() \endlist */ -QmlGraphicsVideo::Status QmlGraphicsVideo::status() const +QDeclarativeVideo::Status QDeclarativeVideo::status() const { return Status(m_status); } @@ -251,7 +251,7 @@ QmlGraphicsVideo::Status QmlGraphicsVideo::status() const This property holds whether the media contains audio. */ -bool QmlGraphicsVideo::hasAudio() const +bool QDeclarativeVideo::hasAudio() const { return m_playerControl->isAudioAvailable(); } @@ -262,7 +262,7 @@ bool QmlGraphicsVideo::hasAudio() const This property holds whether the media contains video. */ -bool QmlGraphicsVideo::hasVideo() const +bool QDeclarativeVideo::hasVideo() const { return m_playerControl->isVideoAvailable(); } @@ -303,7 +303,7 @@ bool QmlGraphicsVideo::hasVideo() const */ -QmlGraphicsVideo::Error QmlGraphicsVideo::error() const +QDeclarativeVideo::Error QDeclarativeVideo::error() const { return Error(m_error); } @@ -335,12 +335,12 @@ QmlGraphicsVideo::Error QmlGraphicsVideo::error() const The default fill mode is PreserveAspectFit. */ -QmlGraphicsVideo::FillMode QmlGraphicsVideo::fillMode() const +QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const { return FillMode(m_graphicsItem->aspectRatioMode()); } -void QmlGraphicsVideo::setFillMode(FillMode mode) +void QDeclarativeVideo::setFillMode(FillMode mode) { m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode)); } @@ -353,7 +353,7 @@ void QmlGraphicsVideo::setFillMode(FillMode mode) Sets the \l playing property to true, and the \l paused property to false. */ -void QmlGraphicsVideo::play() +void QDeclarativeVideo::play() { m_playerControl->play(); @@ -371,7 +371,7 @@ void QmlGraphicsVideo::play() Sets the \l playing and \l paused properties to true. */ -void QmlGraphicsVideo::pause() +void QDeclarativeVideo::pause() { m_playerControl->pause(); @@ -389,7 +389,7 @@ void QmlGraphicsVideo::pause() Sets the \l playing and \l paused properties to false. */ -void QmlGraphicsVideo::stop() +void QDeclarativeVideo::stop() { m_playerControl->stop(); @@ -399,15 +399,15 @@ void QmlGraphicsVideo::stop() } } -void QmlGraphicsVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } -void QmlGraphicsVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { m_graphicsItem->setSize(newGeometry.size()); - QmlGraphicsItem::geometryChanged(newGeometry, oldGeometry); + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } QT_END_NAMESPACE @@ -942,4 +942,4 @@ QT_END_NAMESPACE #endif -#include "moc_qmlgraphicsvideo_p.cpp" +#include "moc_qdeclarativevideo_p.cpp" diff --git a/src/multimedia/qml/qmlgraphicsvideo_p.h b/src/multimedia/qml/qdeclarativevideo_p.h index 26252e0..d5ebde1 100644 --- a/src/multimedia/qml/qmlgraphicsvideo_p.h +++ b/src/multimedia/qml/qdeclarativevideo_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLGRAPHICSVIDEO_H -#define QMLGRAPHICSVIDEO_H +#ifndef QDECLARATIVEVIDEO_H +#define QDECLARATIVEVIDEO_H // // W A R N I N G @@ -53,12 +53,12 @@ // We mean it. // -#include <QtMultimedia/private/qmlmediabase_p.h> +#include <QtMultimedia/private/qdeclarativemediabase_p.h> #include <QtMultimedia/qgraphicsvideoitem.h> #include <QtCore/qbasictimer.h> -#include <QtDeclarative/qmlgraphicsitem.h> +#include <QtDeclarative/qdeclarativeitem.h> QT_BEGIN_HEADER @@ -69,7 +69,7 @@ class QTimerEvent; class QVideoSurfaceFormat; -class Q_AUTOTEST_EXPORT QmlGraphicsVideo : public QmlGraphicsItem, public QmlMediaBase +class Q_AUTOTEST_EXPORT QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) @@ -122,8 +122,8 @@ public: ServiceMissing = QMediaPlayer::ServiceMissingError }; - QmlGraphicsVideo(QmlGraphicsItem *parent = 0); - ~QmlGraphicsVideo(); + QDeclarativeVideo(QDeclarativeItem *parent = 0); + ~QDeclarativeVideo(); bool hasAudio() const; bool hasVideo() const; @@ -174,7 +174,7 @@ Q_SIGNALS: void playbackRateChanged(); void errorChanged(); - void error(QmlGraphicsVideo::Error error, const QString &errorString); + void error(QDeclarativeVideo::Error error, const QString &errorString); protected: void geometryChanged(const QRectF &geometry, const QRectF &); @@ -184,7 +184,7 @@ private Q_SLOTS: void _q_error(int, const QString &); private: - Q_DISABLE_COPY(QmlGraphicsVideo) + Q_DISABLE_COPY(QDeclarativeVideo) QGraphicsVideoItem *m_graphicsItem; @@ -192,12 +192,12 @@ private: Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - inline QmlMediaBase *mediaBase() { return this; } + inline QDeclarativeMediaBase *mediaBase() { return this; } }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QmlGraphicsVideo)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo)) QT_END_HEADER diff --git a/src/multimedia/qml/qml.pri b/src/multimedia/qml/qml.pri index a7ca02e..d0ff71d 100644 --- a/src/multimedia/qml/qml.pri +++ b/src/multimedia/qml/qml.pri @@ -17,20 +17,20 @@ contains(QT_CONFIG, declarative) { } HEADERS += \ - $$PWD/multimediaqml.h \ + $$PWD/multimediadeclarative.h \ $$PWD/qmetadatacontrolmetaobject_p.h \ - $$PWD/qmlaudio_p.h \ - $$PWD/qmlgraphicsvideo_p.h \ - $$PWD/qmlmediabase_p.h \ + $$PWD/qdeclarativeaudio_p.h \ + $$PWD/qdeclarativevideo_p.h \ + $$PWD/qdeclarativemediabase_p.h \ $$PWD/qsoundeffect_p.h \ $$PWD/wavedecoder_p.h SOURCES += \ - $$PWD/multimediaqml.cpp \ + $$PWD/multimediadeclarative.cpp \ $$PWD/qmetadatacontrolmetaobject.cpp \ - $$PWD/qmlaudio.cpp \ - $$PWD/qmlgraphicsvideo.cpp \ - $$PWD/qmlmediabase.cpp \ + $$PWD/qdeclarativeaudio.cpp \ + $$PWD/qdeclarativevideo.cpp \ + $$PWD/qdeclarativemediabase.cpp \ $$PWD/qsoundeffect.cpp \ $$PWD/wavedecoder_p.cpp } diff --git a/src/multimedia/qml/qsoundeffect_p.h b/src/multimedia/qml/qsoundeffect_p.h index 4b440ec..51ebe52 100644 --- a/src/multimedia/qml/qsoundeffect_p.h +++ b/src/multimedia/qml/qsoundeffect_p.h @@ -56,7 +56,7 @@ #include <QtCore/qobject.h> #include <QtCore/qurl.h> -#include <QtDeclarative/qml.h> +#include <QtDeclarative/qdeclarative.h> QT_BEGIN_HEADER |