Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudioRecorder has illogical state / status implementation?
Forum Updated to NodeBB v4.3 + New Features

QAudioRecorder has illogical state / status implementation?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 716 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    I am using QAudioRecorder to record .wav files. After the recording finishes, I add an ID3v2 tag to it.

    To implement this, I naively relied on the stateChanged signal and connected it to my own onRecorderStateChanged() slot. In there, if the reported state is QMediaRecorder::StoppedState, I open the recorded file, add the tag to it, and update the "RIFF" chunk's size field by reading its previous size (before adding the tag) and adding the size of the "ID3 " chunk I added.

    Or so I thought.

    The RIFF size I got for the recorded file was always FF FF FF FF: this is a place holder value that is filled in when the file is finalized, and thus this meant that in the QMediaRecorder::StoppedState state, the file is not complete yet!

    The status of the recorder in the onRecorderStateChanged() slot when the reported state is QMediaRecorder::StoppedState is actually still QMediaRecorder::RecordingStatus....

    Since status clearly reflects the actual state of the device, why isn't the state property consistent with it? state is apparently changed before the actual status changes, which seems wrong to me.

    I am using Qt 5.9.1 on Windows 7.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Without diving into the bowels of the windows backend, here is an educated guess: the recorder state represent the "mechanical" state of the class, basically, it is "doing something", the status represent what's going under e.g. you push the start button of your car (state), it's not started yet -> there's electrical setup, engine ignition, IVI setup/start (status) and then your car is started (state again). Same when you stop.

      The QMediaRecorder::FinalizingStatus enum value is likely the most interesting here, especially the last part: Recording is stopped with media being finalized.

      The recorder already stopped but there are still steps to be taken in order to have a valid file: closing streams, updating container informations, updating headers etc. depending on the formats/containers used.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      DiracsbracketD 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Without diving into the bowels of the windows backend, here is an educated guess: the recorder state represent the "mechanical" state of the class, basically, it is "doing something", the status represent what's going under e.g. you push the start button of your car (state), it's not started yet -> there's electrical setup, engine ignition, IVI setup/start (status) and then your car is started (state again). Same when you stop.

        The QMediaRecorder::FinalizingStatus enum value is likely the most interesting here, especially the last part: Recording is stopped with media being finalized.

        The recorder already stopped but there are still steps to be taken in order to have a valid file: closing streams, updating container informations, updating headers etc. depending on the formats/containers used.

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by
        #3

        @SGaist
        Thanks for your input, as always! I will use status from now on. Cheers.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved