From 315bcd075816465e57e703290b0b1404af2ae7c9 Mon Sep 17 00:00:00 2001 From: Andy Nichols <andy.nichols@digia.com> Date: Thu, 11 Apr 2013 16:20:06 -0700 Subject: [PATCH] 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 <christian.stromme@digia.com> --- .../audiorecorder/audiorecorder.cpp | 21 ------------------- .../multimedia/audiorecorder/audiorecorder.h | 1 - 2 files changed, 22 deletions(-) diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp index ac8476803..5f3b0a10a 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 22cce4bbd..1a12031ec 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; -- GitLab