Skip to content

Commit

Permalink
gh-547 Make PcmFormat enum instead of struct
Browse files Browse the repository at this point in the history
Instead of a struct with code + endian, use one enum with
all combinations, to simplify the user code.
  • Loading branch information
gavv committed Dec 2, 2023
1 parent 865f0c4 commit f48f65e
Show file tree
Hide file tree
Showing 46 changed files with 2,186 additions and 1,482 deletions.
2 changes: 1 addition & 1 deletion .fmtignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src/internal_modules/roc_audio/pcm_funcs.h
src/internal_modules/roc_audio/pcm_format.cpp
src/internal_modules/roc_core/target_libatomic_ops/roc_core/atomic_ops.h
src/tests/roc_audio/test_samples/*.h
src/tests/roc_rtp/test_packets/*.h
2 changes: 2 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ if meta.compiler == 'gcc':
'-Wno-shadow',
'-Wno-stringop-overflow',
'-Wno-system-headers',
'-Wno-unused-const-variable',
]})

env.Append(CXXFLAGS=[
Expand Down Expand Up @@ -1061,6 +1062,7 @@ if meta.compiler == 'clang':
'-Wno-psabi',
'-Wno-shadow',
'-Wno-system-headers',
'-Wno-unused-const-variable',
]})

env.Append(CXXFLAGS=[
Expand Down
6 changes: 3 additions & 3 deletions src/internal_modules/roc_audio/pcm_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace roc {
namespace audio {

IFrameDecoder* PcmDecoder::construct(core::IArena& arena,
const PcmFormat& pcm_format,
PcmFormat pcm_format,
const SampleSpec& sample_spec) {
return new (arena) PcmDecoder(pcm_format, sample_spec);
}

PcmDecoder::PcmDecoder(const PcmFormat& pcm_format, const SampleSpec& sample_spec)
: pcm_mapper_(pcm_format, SampleFormat)
PcmDecoder::PcmDecoder(PcmFormat pcm_format, const SampleSpec& sample_spec)
: pcm_mapper_(pcm_format, SampleFmt)
, n_chans_(sample_spec.num_channels())
, stream_pos_(0)
, stream_avail_(0)
Expand Down
7 changes: 3 additions & 4 deletions src/internal_modules/roc_audio/pcm_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ namespace audio {
class PcmDecoder : public IFrameDecoder, public core::NonCopyable<> {
public:
//! Construction function.
static IFrameDecoder* construct(core::IArena& arena,
const PcmFormat& pcm_format,
const SampleSpec& sample_spec);
static IFrameDecoder*
construct(core::IArena& arena, PcmFormat pcm_format, const SampleSpec& sample_spec);

//! Initialize.
PcmDecoder(const PcmFormat& pcm_format, const SampleSpec& sample_spec);
PcmDecoder(PcmFormat pcm_format, const SampleSpec& sample_spec);

//! Get current stream position.
virtual packet::stream_timestamp_t position() const;
Expand Down
6 changes: 3 additions & 3 deletions src/internal_modules/roc_audio/pcm_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace roc {
namespace audio {

IFrameEncoder* PcmEncoder::construct(core::IArena& arena,
const PcmFormat& pcm_format,
PcmFormat pcm_format,
const SampleSpec& sample_spec) {
return new (arena) PcmEncoder(pcm_format, sample_spec);
}

PcmEncoder::PcmEncoder(const PcmFormat& pcm_format, const SampleSpec& sample_spec)
: pcm_mapper_(SampleFormat, pcm_format)
PcmEncoder::PcmEncoder(PcmFormat pcm_format, const SampleSpec& sample_spec)
: pcm_mapper_(SampleFmt, pcm_format)
, n_chans_(sample_spec.num_channels())
, frame_data_(NULL)
, frame_byte_size_(0)
Expand Down
7 changes: 3 additions & 4 deletions src/internal_modules/roc_audio/pcm_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ namespace audio {
class PcmEncoder : public IFrameEncoder, public core::NonCopyable<> {
public:
//! Construction function.
static IFrameEncoder* construct(core::IArena& arena,
const PcmFormat& pcm_format,
const SampleSpec& sample_spec);
static IFrameEncoder*
construct(core::IArena& arena, PcmFormat pcm_format, const SampleSpec& sample_spec);

//! Initialize.
PcmEncoder(const PcmFormat& pcm_format, const SampleSpec& sample_spec);
PcmEncoder(PcmFormat pcm_format, const SampleSpec& sample_spec);

//! Get encoded frame size in bytes for given number of samples per channel.
virtual size_t encoded_byte_count(size_t num_samples) const;
Expand Down
39 changes: 0 additions & 39 deletions src/internal_modules/roc_audio/pcm_format.cpp

This file was deleted.

Loading

0 comments on commit f48f65e

Please sign in to comment.