Skip to content

Commit fa3f5f6

Browse files
committed
main: make also MOD_NAME and PORT_BASE constexpr
Also remove static and const from DEFAULT_VIDEO_COMPRESSION and DEFAULT_AUDIO_CODEC: - pointer to const char -> can be turned to constexpr char array, where constexpr implies const - static unnecessary - const (implied by constexpr) objects have implicit internal linkage in C++ (differs from C)
1 parent 88e9cf2 commit fa3f5f6

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/main.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@
125125
#include "video_display.h"
126126
#include "video_rxtx.hpp"
127127

128-
#define MOD_NAME "[main] "
129-
#define PORT_BASE 5004
128+
constexpr char MOD_NAME[] = "[main] ";
130129

131-
static constexpr const char *DEFAULT_VIDEO_COMPRESSION = "none";
132-
static constexpr const char *DEFAULT_AUDIO_CODEC = "PCM";
130+
constexpr char DEFAULT_VIDEO_COMPRESSION[] = "none";
131+
constexpr char DEFAULT_AUDIO_CODEC[] = "PCM";
132+
constexpr int PORT_BASE = 5004;
133133

134134
constexpr int OPT_AUDIO_CAPTURE_CHANNELS = ('a' << 8) | 'c';
135135
constexpr int OPT_AUDIO_DELAY = ('A' << 8) | 'D';
@@ -638,7 +638,7 @@ static bool parse_protocol(int ch, char *optarg, struct ug_options *opt) {
638638
set_audio = toupper(optarg[0]) == 'A';
639639
set_video = toupper(optarg[0]) == 'V';
640640
if (!set_audio && !set_video) {
641-
LOG(LOG_LEVEL_ERROR) << MOD_NAME "Wrong protocol setting: " << optarg << "\n";
641+
MSG(ERROR, "Wrong protocol setting: %s\n", optarg);
642642
return false;
643643
}
644644
optarg += 2;
@@ -652,11 +652,13 @@ static bool parse_protocol(int ch, char *optarg, struct ug_options *opt) {
652652
}
653653
switch (ch) {
654654
case OPT_AUDIO_PROTOCOL:
655-
LOG(LOG_LEVEL_WARNING) << MOD_NAME "--audio-protocol deprecated, use '-x A:proto'\n";
655+
MSG(WARNING,
656+
"--audio-protocol deprecated, use '-x A:proto'\n");
656657
set_video = false;
657658
break;
658659
case OPT_VIDEO_PROTOCOL:
659-
LOG(LOG_LEVEL_WARNING) << MOD_NAME "--video-protocol deprecated, use '-x V:proto'\n";
660+
MSG(WARNING,
661+
"--video-protocol deprecated, use '-x V:proto'\n");
660662
set_audio = false;
661663
break;
662664
}

0 commit comments

Comments
 (0)