Pulling AudioPlayHead::CurrentPositionInfo out of the olden times

Even if it’s not an ideally set up structure, the goal is to make it go through a better initialisation by defaulting its members, and maybe even considering deprecating resetToDefault (let alone the gross use of zerostruct to zero out members, which doesn’t bode well by today’s standards).

I’m thinking something along these lines, minus the minor tidying in the framework to remove the calls to resetToDefault:

    /** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
    */
    struct JUCE_API  CurrentPositionInfo  final
    {
        /** */
        CurrentPositionInfo() noexcept = default;
        /** */
        CurrentPositionInfo (const CurrentPositionInfo&) noexcept = default;
        /** */
        CurrentPositionInfo (CurrentPositionInfo&&) noexcept = default;
        /** */
        ~CurrentPositionInfo() noexcept = default;
        /** */
        CurrentPositionInfo& operator= (const CurrentPositionInfo&) = default;
        /** */
        CurrentPositionInfo& operator= (CurrentPositionInfo&&) = default;

        //==============================================================================
        /** The tempo in BPM */
        double bpm = 120.0;

        /** Time signature numerator, e.g. the 3 of a 3/4 time sig */
        int timeSigNumerator = 4;
        /** Time signature denominator, e.g. the 4 of a 3/4 time sig */
        int timeSigDenominator = 4;

        /** The current play position, in samples from the start of the timeline. */
        int64 timeInSamples = 0;
        /** The current play position, in seconds from the start of the timeline. */
        double timeInSeconds = 0.0;

        /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */
        double editOriginTime = 0.0;

        /** The current play position, in units of quarter-notes. */
        double ppqPosition = 0.0;

        /** The position of the start of the last bar, in units of quarter-notes.

            This is the time from the start of the timeline to the start of the current
            bar, in ppq units.

            Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
            it's not available, the value will be 0.
        */
        double ppqPositionOfLastBarStart = 0.0;

        /** The video frame rate, if applicable. */
        FrameRateType frameRate = fps60;

        /** True if the transport is currently playing. */
        bool isPlaying = false;

        /** True if the transport is currently recording.

            (When isRecording is true, then isPlaying will also be true).
        */
        bool isRecording = false;

        /** The current cycle start position in units of quarter-notes.
            Note that not all hosts or plugin formats may provide this value.
            @see isLooping
        */
        double ppqLoopStart = 0.0;

        /** The current cycle end position in units of quarter-notes.
            Note that not all hosts or plugin formats may provide this value.
            @see isLooping
        */
        double ppqLoopEnd = 0.0;

        /** True if the transport is currently looping. */
        bool isLooping = false;

        //==============================================================================
        /** Returns true if the two CurrentPositionInfo are equal. */
        bool operator== (const CurrentPositionInfo& other) const noexcept
        {
            return timeInSamples == other.timeInSamples
                && ppqPosition == other.ppqPosition
                && editOriginTime == other.editOriginTime
                && ppqPositionOfLastBarStart == other.ppqPositionOfLastBarStart
                && frameRate == other.frameRate
                && isPlaying == other.isPlaying
                && isRecording == other.isRecording
                && bpm == other.bpm
                && timeSigNumerator == other.timeSigNumerator
                && timeSigDenominator == other.timeSigDenominator
                && ppqLoopStart == other.ppqLoopStart
                && ppqLoopEnd == other.ppqLoopEnd
                && isLooping == other.isLooping;
        }

        /** Returns true if the two CurrentPositionInfo are not equal. */
        bool operator!= (const CurrentPositionInfo& other) const noexcept
        {
            return ! operator== (other);
        }

        JUCE_DEPRECATED_WITH_BODY (void resetToDefault(), { *this = CurrentPositionInfo(); })
    };
3 Likes