Skip to content

Audio types / stream properties / cue import#2601

Merged
Holzhaus merged 32 commits into
mixxxdj:masterfrom
uklotzde:audio_types
Apr 9, 2020
Merged

Audio types / stream properties / cue import#2601
Holzhaus merged 32 commits into
mixxxdj:masterfrom
uklotzde:audio_types

Conversation

@uklotzde
Copy link
Copy Markdown
Contributor

@uklotzde uklotzde commented Mar 26, 2020

  • Introduced new basic types for PCM audio signals and streams
  • Simplified inheritance hierarchy of AudioSource, i.e. remove the ugly, Janus-headed AudioSignal base class
  • Added deferred import of CueInfo into Track objects, needed for Read Cues from Serato MP3 Tags #2526. I have added this here as a proof of concept that the refactoring achieves the intended goal. Needs to be tested when used!
  • Known issue: Incompatible with GCC 5 (Xenial)

@Holzhaus
Copy link
Copy Markdown
Member

This is necessary for #2526, so I guess this is a beta-blocker for 2.3.0 as well?

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Mar 30, 2020

Is this still a work-in-progress? If so, what remains to be done?

@uklotzde
Copy link
Copy Markdown
Contributor Author

@Be-ing WiP because doesn't compile on Xenial and CI is red. Otherwise ready.

I don't plan to downgrade the code and won't accept any PRs to do so.

@uklotzde
Copy link
Copy Markdown
Contributor Author

@Holzhaus needs to test if the deferred cue point import enabled by this PR works as expected or if we need to make adjustments. This feature is just an untested bonus of this PR on top of the actual changes.

@uklotzde uklotzde changed the title [WiP] Audio types / stream properties / cue import Audio types / stream properties / cue import Mar 30, 2020
Copy link
Copy Markdown
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the idea of this PR to decouple the SignalInfo class from the classes which represent actual audio signals. Clearly it is helpful to work with that information without requiring access to the actual audio signals.

Comment thread src/audio/types.h
Comment thread src/audio/types.h Outdated
Comment thread src/audio/signalinfo.h
Comment thread src/audio/types.h
Comment thread src/audio/streaminfo.cpp
@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Mar 30, 2020

Nice work! I think we should gradually migrate all code that calculates times from samples/frames to use this new SignalInfo class, both in the audio code and GUI code. There are lots of places in the GUI code that relies on ControlProxies to get that info. It would be better to get the SignalInfo from the Track/Cue/whatever object. Then we could get away from using samples as units of time.

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Apr 2, 2020

@mixxxdj/developers needs review

@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Apr 3, 2020

I'm hitting a DEBUG_ASSERT when I load a track into a deck:

─── Output/messages ──────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning [Controller]: ControlDoublePrivate::getControl returning NULL for ( "[EffectRack1_EffectUnit1_Effectundefined]" , "meta" )
Warning [Controller]: ControlDoublePrivate::getControl returning NULL for ( "[EffectRack1_EffectUnit2_Effectundefined]" , "meta" )
DEBUG ASSERT: "m_signalInfo.isValid()" in function const mixxx::audio::SignalInfo& mixxx::AudioSource::getSignalInfo() const at /home/jan/Projects/mixxx/src/sources/audiosource.h:236

Thread 35 "CachingReaderWo" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffeeafec700 (LWP 254934)]
0x00007ffff2b54ce5 in raise () from /usr/lib/libc.so.6
─── Assembly ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0x00007ffff2b54cd9 raise-1706087 mov    $0x2,%edi
0x00007ffff2b54cde raise-1706082 mov    $0xe,%eax
0x00007ffff2b54ce3 raise-1706077 syscall
0x00007ffff2b54ce5 raise-1706075 mov    0x108(%rsp),%rax
0x00007ffff2b54ced raise-1706067 xor    %fs:0x28,%rax
0x00007ffff2b54cf6 raise-1706058 jne    0x7ffff2b54d1c <raise+380>
0x00007ffff2b54cf8 raise-1706056 mov    %r8d,%eax
─── Expressions ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── History ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Memory ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Registers ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   rax 0x0000000000000000         rbx 0x00007ffeeafec700         rcx 0x00007ffff2b54ce5         rdx 0x0000000000000000
   rsi 0x00007ffeeafead60         rdi 0x0000000000000002         rbp 0x00007ffeeafeafb8         rsp 0x00007ffeeafead60
    r8 0x0000000000000000          r9 0x00007ffeeafead60         r10 0x0000000000000008         r11 0x0000000000000246
   r12 0x00007ffeeafeb0c8         r13 0x0000008c00000002         r14 0x0000000000000018         r15 0x00005555561c7751
   rip 0x00007ffff2b54ce5      eflags [ PF ZF IF ]                cs 0x00000033                  ss 0x0000002b
    ds 0x00000000                  es 0x00000000                  fs 0x00000000                  gs 0x00000000
─── Source ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Stack ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x00007ffff2b54ce5 in raise+-1706075
(no arguments)
[1] from 0x00007ffff2b3e857 in abort+299
(no arguments)
[+]
─── Threads ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[84] id 254985 name mixxx from 0x00007ffff2c0dabf in poll+79
[83] id 254984 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[82] id 254983 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[81] id 254982 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[80] id 254981 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[79] id 254980 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[78] id 254979 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[77] id 254978 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[76] id 254977 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[75] id 254974 name gdbus from 0x00007ffff2c0dabf in poll+79
[74] id 254973 name gmain from 0x00007ffff2c0dabf in poll+79
[73] id 254972 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[72] id 254971 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[71] id 254970 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[70] id 254969 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[69] id 254968 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[68] id 254967 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[67] id 254966 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[66] id 254965 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[65] id 254964 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[64] id 254963 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[63] id 254962 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[62] id 254961 name Controller from 0x00007ffff2c0dabf in poll+79
[61] id 254960 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[60] id 254959 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[59] id 254958 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[58] id 254957 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[57] id 254956 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[56] id 254955 name VSyncThread from 0x00007ffff2be02d1 in clock_nanosleep@GLIBC_2.2.5
[55] id 254954 name mixxx:gdrv0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[54] id 254953 name Controller from 0x00007ffff2c0dabf in poll+79
[53] id 254952 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[52] id 254951 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[51] id 254950 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[50] id 254949 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[49] id 254948 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[48] id 254947 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[47] id 254946 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[46] id 254945 name AnalyzerThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[45] id 254944 name BrowseThread from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[44] id 254943 name LibraryScanner  from 0x00007ffff2c0dabf in poll+79
[43] id 254942 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[42] id 254941 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[41] id 254940 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[40] id 254939 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[39] id 254938 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[38] id 254937 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[37] id 254936 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[36] id 254935 name CachingReaderWo from 0x00007ffff2c12f8d in syscall+29
[35] id 254934 name CachingReaderWo from 0x00007ffff2b54ce5 in raise+-1706075
[34] id 254933 name VinylControlPro from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[28] id 254926 name EngineSideChain from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[27] id 254925 name EngineWorkerSch from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[26] id 254922 name mixxx:shlo4 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[25] id 254921 name mixxx:shlo3 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[24] id 254920 name mixxx:shlo2 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[23] id 254919 name mixxx:shlo1 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[22] id 254918 name mixxx:shlo0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[21] id 254917 name mixxx:sh11 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[20] id 254916 name mixxx:sh10 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[19] id 254915 name mixxx:sh9 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[18] id 254914 name mixxx:sh8 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[17] id 254913 name mixxx:sh7 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[16] id 254912 name mixxx:sh6 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[15] id 254911 name mixxx:sh5 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[14] id 254910 name mixxx:sh4 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[13] id 254909 name mixxx:sh3 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[12] id 254908 name mixxx:sh2 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[11] id 254907 name mixxx:sh1 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[10] id 254906 name mixxx:sh0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[9] id 254905 name mixxx:disk$3 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[8] id 254904 name mixxx:disk$2 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[7] id 254903 name mixxx:disk$1 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[6] id 254902 name mixxx:disk$0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[5] id 254901 name mixxx:cs0 from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[4] id 254900 name mixxx from 0x00007ffff2cf0cf5 in pthread_cond_wait@@GLIBC_2.3.2
[3] id 254899 name QDBusConnection from 0x00007ffff2c0dabf in poll+79
[2] id 254898 name QXcbEventQueue from 0x00007ffff2c0dabf in poll+79
[1] id 254894 name mixxx from 0x00007ffff239893c in hb_segment_properties_equal+44
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>>> bt
#0  0x00007ffff2b54ce5 in raise () at /usr/lib/libc.so.6
#1  0x00007ffff2b3e857 in abort () at /usr/lib/libc.so.6
#2  0x00007ffff551596c in  () at /usr/lib/libQt5Core.so.5
#3  0x000055555564ab9f in mixxx::(anonymous namespace)::MessageHandler(QtMsgType, QMessageLogContext const&, QString const&) (type=<optimized out>, input=...) at /usr/include/qt/QtCore/qarraydata.h:61
#4  0x00007ffff5548ad8 in  () at /usr/lib/libQt5Core.so.5
#5  0x00007ffff5548bea in  () at /usr/lib/libQt5Core.so.5
#6  0x00007ffff5515594 in QMessageLogger::critical(char const*, ...) const () at /usr/lib/libQt5Core.so.5
#7  0x00005555556374ef in mixxx_debug_assert(char const*, char const*, int, char const*) (assertion=assertion@entry=0x5555561c3abf "m_signalInfo.isValid()", file=file@entry=0x5555561c38d8 "/home/jan/Projects/mixxx/src/sources/audiosource.h", line=line@entry=236, function=function@entry=0x5555561c3888 "const mixxx::audio::SignalInfo& mixxx::AudioSource::getSignalInfo() const") at /usr/include/qt/QtCore/qlogging.h:90
#8  0x000055555566162c in mixxx::AudioSource::getSignalInfo() const (this=0x7ffed8004f20) at /usr/include/c++/9.3.0/ext/new_allocator.h:89
#9  mixxx::SoundSourceMp3::tryOpen(mixxx::AudioSource::OpenMode, mixxx::AudioSource::OpenParams const&) (this=0x7ffed8004f20) at /home/jan/Projects/mixxx/src/sources/soundsourcemp3.cpp:195
#10 0x0000555555d54cab in mixxx::AudioSource::open(mixxx::AudioSource::OpenMode, mixxx::AudioSource::OpenParams const&) (this=0x7ffed8004f20, mode=mode@entry=mixxx::AudioSource::OpenMode::Strict, params=...) at /home/jan/Projects/mixxx/src/sources/audiosource.cpp:34
#11 0x00005555557c89c4 in SoundSourceProxy::openAudioSource(mixxx::AudioSource::OpenParams const&) (this=this@entry=0x7ffeeafeb980, params=...) at /usr/include/c++/9.3.0/bits/shared_ptr_base.h:1020
#12 0x0000555555ade1e5 in CachingReaderWorker::loadTrack(std::shared_ptr<Track> const&) (this=0x555557772a58, pTrack=std::shared_ptr<Track> (use count 8, weak count 1) = {...}) at /usr/include/c++/9.3.0/ext/atomicity.h:96
#13 0x0000555555adf4c3 in CachingReaderWorker::run() (this=0x555557772a58) at /home/jan/Projects/mixxx/src/engine/cachingreader/cachingreaderworker.cpp:103
#14 0x00007ffff5550fd6 in  () at /usr/lib/libQt5Core.so.5
#15 0x00007ffff2cea46f in start_thread () at /usr/lib/libpthread.so.0
#16 0x00007ffff2c183d3 in clone () at /usr/lib/libc.so.6

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 3, 2020

@Holzhaus An invalid debug assertion was only triggered by SoundSourceMP3. I have removed the wrong debug assertion and pulled the other one up into the base class. It is now checked for all SoundSources, independent of the format.

Copy link
Copy Markdown
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some first comments

Comment thread src/util/macros.h Outdated
Comment thread src/util/macros.h
public: TYPE const& get##CAP_NAME() const { return m_##NAME; } \
public: TYPE& ref##CAP_NAME() { return m_##NAME; } \
public: constexpr TYPE const& get##CAP_NAME() const { return m_##NAME; } \
public: constexpr TYPE& ref##CAP_NAME() { return m_##NAME; } \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows to modify the m_##NAME via a non-const reference which we like to avoid in Mixxx.
Is this actually used? Can we remove this, or replace with
public: constexpr TYPE* get##CAP_NAME() { return m_##NAME; }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a by-ref parameter. Yes, the mutable access is needed for efficient move-assignement at some places. The function name allows to find all occurrences in contrast to accessing a public member directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A getter with mutable access? No. And I am not going to rewrite many other parts of the code.

Btw, the code documentation explicitly states why the mutable reference is needed ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we gen call it getPtr##NAME or similar. I think this has slipped through in earlier PRs, so I think this is not necessary to fix it.
Maybe we can add the pointer version and use it for new code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the mutable reference part by the way.
It is finally a sytax issue only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise you need to forbid implementing indexing operators with their common syntax.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For deeply nested structures as documented. I refuse to do a mass-rewrite of all existing code.

I have already acknowledged the a mass re-write is not necessary.

But if I look to the using code I find cases where the non-const reference is used as local variable or where it is converted into a pointer. At least for those cases a pointer returning function is necessary to write code without non-const references. This allows to avoid the same confusing cases we avoid by the non-const reference parameter rule, writing external memory via the local variable syntax.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These accessor functions are not intended for storing the returned reference. Only to assign a new value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or to modify the existing value in-place.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it is used for storing. I would like to fix at least these places because this is a source of confusion. I don't mind about this, where the refrence is not stored:

m_record.refMetadata().refTrackInfo().setBpm(mixxx::Bpm(bpmValue));
vs:
m_record.ptrMetadata()->ptrTrackInfo()->setBpm(mixxx::Bpm(bpmValue));

@daschuer No agreement about if returning a mutable reference is permitted or not. Returning a pointer is "pointless" and may only tempt the caller to store somewhere that my outlive the current scope. We don't need to write C code for this special use case. I won't.

Looking from the machine code, storing a reference or a pointer is the same, so that's not the point. It is a code style issue and readability issue.

Except for STL compatibility of container classes QT never returns non canst references.
Since this is a common macro, we should at least allow users to do the same.

Qt Example:
controlsTable->verticalHeader()->setVisible(false);

IMHO we should at least add a ptr##NAME function or just a ##NAME and using it at all places where we currently store a non-const deference.

What do you think?

If you like I can issue a PR against your branch.

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 8, 2020

A restrictive implementation could be extended when needed, but not now! We seem to have different opinions on how to develop safe and maintainable software.

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Apr 8, 2020

I think we could benefit from a larger discussion of a plan to move away from using stereo samples as units of time. That's a big task that this PR won't solve. I'm okay with merging this without those conversion functions, but the problem remains that we're already doing those conversions all over the code. See WOverview::samplePositionToSeconds and how much it used throughout WOverview because cue point positions are exposed to the GUI as stereo samples.

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Apr 8, 2020

No, I refuse to return pointers. The Qt use case is different, because the QObjects are usually allocated dynamically and managed by the object tree whereas those property objects could also live on the stack.

If the object lives on the stack or In the heap is a not relevant implementation detail. We are discussing here an universal macro. It should be usable independent from how the object is allocated.

The main issue I like to solve is to get rid of the non-const references in the code.

Would it be OK for you if I do a PR to fix this?

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 8, 2020

Any other opinions?

Comment thread src/util/macros.h Outdated
@daschuer
Copy link
Copy Markdown
Member

daschuer commented Apr 8, 2020

There is no reason to hold this PR back because of this non-const reference issue.
So LGTM.
I have only just not understand what stands against the pointer returning function. It is IMHO just a handy addition.

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 8, 2020

There is no reason to hold this PR back because of this non-const reference issue.
So LGTM.
I have only just not understand what stands against the pointer returning function. It is IMHO just a handy addition.

I understood the you wanted to replace all ref with the ptr functions? Adding a ptr function is valid, just one line of code.

@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Apr 8, 2020

I don't really care if we use pointer or references, but I often feel uncomfortable when using pointers without checking if they are null first, which would make the code less straightforward here.

@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Apr 8, 2020

I have addressed all comments that except

  • @Holzhaus No idea how to consistently and distinguishably name functions that accept either CuePointer or CueInfo.

I'd suggest to use function names with Cuefor all functions the work on Cue/CuePointer objects, and CueInfo for functions that work on CueInfo objects. But I guess that would be more work and isn't that important right now.

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 8, 2020

I have addressed all comments that except

  • @Holzhaus No idea how to consistently and distinguishably name functions that accept either CuePointer or CueInfo.

I'd suggest to use function names with Cuefor all functions the work on Cue/CuePointer objects, and CueInfo for functions that work on CueInfo objects. But I guess that would be more work and isn't that important right now.

I guess it is only a single function right now. It is a good idea, because there are already many existing ...Cues(...) functions in other classes that deal with CuePointer.

Copy link
Copy Markdown
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@Holzhaus Holzhaus merged commit 9d86357 into mixxxdj:master Apr 9, 2020
@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Apr 9, 2020

macOS builds on the build server are failing:

In file included from src/audio/streaminfo.h:3:
src/audio/signalinfo.h:21:24: error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
    constexpr explicit SignalInfo(
                       ^
src/audio/signalinfo.h:23:15: note: non-constexpr constructor 'optional' cannot be used in a constant expression
            : m_sampleLayout(sampleLayout) {
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/experimental/optional:319:31: note: declared here
    _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
                              ^
In file included from src/main.cpp:26:
In file included from src/mixxx.h:28:
In file included from src/track/track.h:8:
src/audio/streaminfo.h:22:24: error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
    constexpr explicit StreamInfo(
                       ^
src/audio/streaminfo.h:24:15: note: non-constexpr constructor 'SignalInfo' cannot be used in a constant expression
            : m_signalInfo(signalInfo) {
              ^
src/audio/signalinfo.h:34:5: note: declared here
    SignalInfo(const SignalInfo&) = default;
    ^
In file included from src/main.cpp:26:
In file included from src/mixxx.h:28:
In file included from src/track/track.h:8:
src/audio/streaminfo.h:26:15: error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
    constexpr StreamInfo(
              ^
src/audio/streaminfo.h:30:15: note: non-constexpr constructor 'SignalInfo' cannot be used in a constant expression
            : m_signalInfo(signalInfo),
              ^
src/audio/signalinfo.h:34:5: note: declared here
    SignalInfo(const SignalInfo&) = default;
    ^

Do we need to update the compiler on the macOS build server? We may need to anyway to fix https://bugs.launchpad.net/mixxx/+bug/1871238

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 9, 2020

These constexpr are used on various levels and would require substantial changes.

It is an inconvenient situation if the version on the build server is different than the CI. As a developer I have to rely on the outcomes of the CI builds. This is the only feedback loop that is available.

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Apr 9, 2020

Am I correct in thinking that error is probably because of an outdated compiler?

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 9, 2020

Yes. A similar situation as with Xenial. The compiler seems to only partially support C++17 features.

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 9, 2020

I'm even unsure which minimum version would be required:
https://clang.llvm.org/cxx_status.html

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Apr 9, 2020

If we go through the trouble to update, we should update to the latest version.

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Apr 9, 2020

I have already a solution that is not too hacky. I used it during the review here.
If I find time I can make a PR from it.

The issue is that it is required for a constexpr class to have all functions constantexpr as well.

From c++ 17 returning a pointer and reference from a class is also considered as contstexpr.

This is relevant vor QString(), be cause class with a QString() can not be a constexpr because if the non constexpr destructor.

A constexpr function as IMHO no value. If it is in the header the Compiler will inline them anyway. It can only be missleading for the developer.

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 9, 2020

I am not sure if the conditional include directives in util/optional.h include <experimental/optional> instead of on macOS and why? On macOS should be available since at least Clang 5!

@uklotzde
Copy link
Copy Markdown
Contributor Author

uklotzde commented Apr 9, 2020

Clang 5 has full C++17 support. The experimental headers are only provided for backwards compatibility. We should first try to remove the experimental hack from util/optional.h before introducing the next workaround.

@rryan
Copy link
Copy Markdown
Member

rryan commented Apr 12, 2020

We're using Xcode 9.4.1 which has clang 9.1.0. I can update us to Xcode 10.1 (clang 10.0.0 / llvm 6.0.1) without upgrading the OS. Though I'm confused because as @uklotzde says, c++17 should be somewhat solid on this compiler. Are we sure it's isn't a bug in our workarounds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants