Skip to content

Commit

Permalink
roc-streaminggh-608: Support custom PCM formats in sndfile backend
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Aug 8, 2024
1 parent dd1151f commit c9c0a85
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 167 deletions.
4 changes: 4 additions & 0 deletions src/internal_modules/roc_audio/sample_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ bool SampleSpec::is_empty() const {
&& sample_rate_ == 0 && channel_set_.num_channels() == 0;
}

bool SampleSpec::is_pcm() const {
return sample_fmt_ == SampleFormat_Pcm && pcm_fmt_ != PcmFormat_Invalid;
}

bool SampleSpec::is_raw() const {
return sample_fmt_ == SampleFormat_Pcm
&& get_pcm_portable_format(pcm_fmt_) == get_pcm_portable_format(Sample_RawFormat);
Expand Down
6 changes: 6 additions & 0 deletions src/internal_modules/roc_audio/sample_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class SampleSpec {
//! Check if sample spec has a zero rate, empty channel set, and invalid_format.
bool is_empty() const;

//! Check if samples are in PCM format.
//! @returns
//! true if sample_format() is SampleFormat_Pcm and pcm_format()
//! is anything except PcmFormat_Invalid.
bool is_pcm() const;

//! Check if samples are in raw format.
//! @returns
//! true if sample_format() is SampleFormat_Pcm and pcm_format()
Expand Down
30 changes: 18 additions & 12 deletions src/internal_modules/roc_sndio/backend_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ status::StatusCode BackendDispatcher::open_default_device_(DeviceType device_typ
return code;
}

roc_log(LogDebug,
"backend dispatcher: got error from driver:"
" driver=%s status=%s",
driver_info.name, status::code_to_str(code));
if (code != status::StatusNoDriver) {
roc_log(LogDebug,
"backend dispatcher: got error from driver:"
" driver=%s status=%s",
driver_info.name, status::code_to_str(code));
}
}

roc_log(LogError, "backend dispatcher: failed to open default %s: status=%s",
Expand Down Expand Up @@ -265,10 +267,12 @@ status::StatusCode BackendDispatcher::open_device_(DeviceType device_type,
return code;
}

roc_log(LogDebug,
"backend dispatcher: got error from driver:"
" driver=%s status=%s",
driver_info.name, status::code_to_str(code));
if (code != status::StatusNoDriver) {
roc_log(LogDebug,
"backend dispatcher: got error from driver:"
" driver=%s status=%s",
driver_info.name, status::code_to_str(code));
}
}
} else {
for (size_t n = 0; n < BackendMap::instance().num_backends(); n++) {
Expand All @@ -281,10 +285,12 @@ status::StatusCode BackendDispatcher::open_device_(DeviceType device_type,
return code;
}

roc_log(LogDebug,
"backend dispatcher: got error from backend:"
" backend=%s status=%s",
backend.name(), status::code_to_str(code));
if (code != status::StatusNoDriver) {
roc_log(LogDebug,
"backend dispatcher: got error from backend:"
" backend=%s status=%s",
backend.name(), status::code_to_str(code));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "roc_sndio/sndfile_backend.h"
#include "roc_core/log.h"
#include "roc_core/scoped_ptr.h"
#include "roc_sndio/sndfile_extension_table.h"
#include "roc_sndio/sndfile_sink.h"
#include "roc_sndio/sndfile_source.h"
#include "roc_sndio/sndfile_tables.h"
#include "roc_status/code_to_str.h"

namespace roc {
Expand Down Expand Up @@ -45,10 +45,11 @@ void SndfileBackend::discover_drivers(core::Array<DriverInfo, MaxDrivers>& drive

const char* driver = format_info.extension;

for (size_t map_index = 0; map_index < ROC_ARRAY_SIZE(file_type_map);
for (size_t map_index = 0; map_index < ROC_ARRAY_SIZE(sndfile_driver_remap);
map_index++) {
if (file_type_map[map_index].format_id == format_info.format) {
driver = file_type_map[map_index].driver_name;
if ((sndfile_driver_remap[map_index].format_mask & SF_FORMAT_TYPEMASK)
== format_info.format) {
driver = sndfile_driver_remap[map_index].driver_name;
}
}

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c9c0a85

Please sign in to comment.