From: Andy Nichols Date: Thu, 11 Apr 2013 23:20:06 +0000 (-0700) Subject: Fix file path bug in audiorecorder example X-Git-Tag: upstream/5.2.95+rc1~76^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=315bcd075816465e57e703290b0b1404af2ae7c9;p=platform%2Fupstream%2Fqtmultimedia.git Fix file path bug in audiorecorder example Default path and name of the output wave audio files were wrong. This means the files did not have the right name to be opened on Windows, and did not have the right path because they were being saved to the root folder. (C:/ on windows, and / on OSX). Now we fall back to the default filepath and name when we try to record without giving a path and filename. Task-number: QTBUG-28663 Change-Id: I8c782a31710cac65cd3c1ecd44de10b41c46e93d Reviewed-by: Christian Stromme --- diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp index ac84768..5f3b0a1 100644 --- a/examples/multimedia/audiorecorder/audiorecorder.cpp +++ b/examples/multimedia/audiorecorder/audiorecorder.cpp @@ -172,9 +172,6 @@ void AudioRecorder::toggleRecord() if (audioRecorder->state() == QMediaRecorder::StoppedState) { audioRecorder->setAudioInput(boxValue(ui->audioDeviceBox).toString()); - if (!outputLocationSet) - audioRecorder->setOutputLocation(generateAudioFilePath()); - QAudioEncoderSettings settings; settings.setCodec(boxValue(ui->audioCodecBox).toString()); settings.setSampleRate(boxValue(ui->sampleRateBox).toInt()); @@ -214,24 +211,6 @@ void AudioRecorder::displayErrorMessage() ui->statusbar->showMessage(audioRecorder->errorString()); } -QUrl AudioRecorder::generateAudioFilePath() -{ - QDir outputDir(QDir::rootPath()); - - int lastImage = 0; - int fileCount = 0; - foreach (const QString &fileName, outputDir.entryList(QStringList(QString("testclip_*")))) { - int imgNumber = fileName.mid(5, fileName.size() - 9).toInt(); - lastImage = qMax(lastImage, imgNumber); - if (outputDir.exists(fileName)) - fileCount += 1; - } - lastImage += fileCount; - QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath() - + QString("/testclip_%1").arg(lastImage + 1, 4, 10, QLatin1Char('0')))); - return location; -} - // This function returns the maximum possible sample value for a given audio format qreal getPeakValue(const QAudioFormat& format) { diff --git a/examples/multimedia/audiorecorder/audiorecorder.h b/examples/multimedia/audiorecorder/audiorecorder.h index 22cce4b..1a12031 100644 --- a/examples/multimedia/audiorecorder/audiorecorder.h +++ b/examples/multimedia/audiorecorder/audiorecorder.h @@ -71,7 +71,6 @@ private slots: void updateState(QMediaRecorder::State); void updateProgress(qint64 pos); void displayErrorMessage(); - QUrl generateAudioFilePath(); private: Ui::AudioRecorder *ui;