0

I am developing a mobile application targeted on two platforms - iOS and Android - using Qt technology.

App is recording sounds and playing them back after a bit of processing. For doing so, I'm used two classes from QtMultimedia module: QAudioRecorder, for recording audio and storing it into QBuffer, and QMediaPlayer to play data back from processed buffer.

Code works perfectly fine on Android, but for some reason, on iOS music played very quetly, even when I set up the phone volume on max and invoke mediaPlayer->setVolume(100).

By a complete accident I figured out that the sound is playing not from the main speaker, but from the small one, which is used for phone conversations. That gave me a necessary hint and helped to track down a source of the issue:

audioRecorder = new QAudioRecorder();

After commenting initialization of audio recorder instance and all references to it, audio output came back to normal. But when I try to insert it anywhere in my code - it immediately swithes the output once more, and there is no way that I know to change it back.

What I have tried:

  • Deleting object of QAudioRecorder after recording was finished

  • Using QAudioOutput instead of QMediaPlayer and setting output device to default one: audioOutput = new QAudioOutput(QAudioDeviceInfo::defaultOutputDevice (), audioFormat, this); Here lies another problem, because QAudioDeviceInfo::availableDevices(QAudio::AudioOutput) returns only "default" - and QAudioDeviceInfo::availableDevices(QAudio::AudioInput) returns just the same

  • The same story with QAudioInput instead of QAudioRecorder

  • Get QMediaService of QMediaPlayer and getting QAudioOutputSelectorControl from it QMediaService *service = mediaPlayer->service(); QAudioOutputSelectorControl *outputSelector = qobject_cast<QAudioOutputSelectorControl *>(service->requestControl(QAudioOutputSelectorControl_iid) ); But this operation returns null

If you have faced the same issue or have any idea of resolving it, I would like to hear it. What I need is the ability to record audio without switching output device

Nimantha
  • 6,405
  • 6
  • 28
  • 69
kitany
  • 1
  • 1

1 Answers1

0

The low volume problem is a Qt bug which apparently has not been fixed: https://bugreports.qt.io/browse/QTBUG-37379.

I faced the same problem as well and fixed it by manually hacking the Qt source code for my specific use case.

Hyndrix
  • 4,282
  • 7
  • 41
  • 82