Skip to content

Commit

Permalink
Minor changes, polishing a few last things
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrick87 committed Feb 29, 2024
1 parent 0f2e3d4 commit 4d8c918
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/internal_modules/roc_audio/sample_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SampleSpec {

//! Check if sample spec has non-zero rate and valid channel set.
bool is_valid() const;

//! Check if sample spec has a zero rate, empty channel set, and invalid_format.
bool is_empty() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct FileMap {
int format_id;
//! Name of driver mapped to SF_FORMAT
const char* driver_name;
//! File extension associatied with driver and SF_FORMAT if it exists.
//! File extension associated with driver and SF_FORMAT if it exists.
const char* file_extension;
};
static FileMap file_type_map[5] = { { SF_FORMAT_MAT4, "mat4", NULL },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

#define FORMAT_COUNT \
2 // Number of major formats that don't allow for subtype SF_FORMAT_PCM_32;
2 // Number of major formats that don't allow for 32 bits;
#define BUFFER_SIZE 512

#include "roc_sndio/sndfile_sink.h"
Expand Down Expand Up @@ -151,7 +151,7 @@ SndfileSink::SndfileSink(core::IArena& arena, const Config& config)
}

memset(&file_info_, 0, sizeof(file_info_));

//file_info_.format = (int)config.sample_spec.pcm_format(); this needs to be converted to corresponding enum of sndfile somehow
file_info_.format = SF_FORMAT_PCM_32;
file_info_.channels = (int)config.sample_spec.num_channels();
file_info_.samplerate = (int)config.sample_spec.sample_rate();
Expand Down Expand Up @@ -278,9 +278,10 @@ void SndfileSink::write(audio::Frame& frame) {
// Write entire float buffer in one call
sf_count_t count = sf_write_float(file_, frame_data, frame_left);

if (count != frame_left || sf_error(file_) != 0) {
int errnum = sf_error(file_);
if (count != frame_left || errnum != 0) {
// TODO(gh-183): return error instead of panic
roc_panic("sndfile source: sf_write_float() failed: %s", sf_strerror(file_));
roc_panic("sndfile source: sf_write_float() failed: %s", sf_error_number(errnum));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void SndfileSource::close_() {
}

roc_log(LogInfo, "sndfile source: closing input");

if (int err = sf_close(file_) != 0) {
int err = sf_close(file_);
if (err != 0) {
roc_panic("sndfile source: sf_close() failed. Cannot close input: %s",
sf_error_number(err));
}
Expand Down

0 comments on commit 4d8c918

Please sign in to comment.