Hi everyone, and thanks in advamce for your help
I have discovered one tricky issue with audio in my application, targeted on iOS.
On the start, my app used QMediaPlayer for playing audio files - it worked fine, the music played loudly and joyfully for everyone. After that, I needed to implement QAudioRecorder to make audio records, and that's when my sad story story begins... After adding a new feature, I discovered, that music started to play very quetly, even if I set the phone on the max volume and add mediaPlayer->setVolume(100) in my code. By a complete accident I figured out that the sound plays not from the main speaker, but from the one which is used in phone conversations. That gave me a necessary hint and helped to track down a source of the issue:
audioRecorder = new QAudioRecorder();
After commenting this line and all references to it, output came back to normal. But when I try to add it somewhere else - anywhere in my code - it swithes the output device once more, and I can no longer change it back.
What I have tried:
- Deleting instance of QAudioRecorder after recording was finished - no help
- 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::AudioOu tput) returns only "default" - and QAudioDeviceInfo::availableDevices(QAudio::AudioIn put) 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:)
P. S. Android version of my app doesn't have this issue
Bookmarks