Skip to content

Commit

Permalink
Added auto header to write, detect bit_depth of format in source
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrick87 committed Dec 14, 2023
1 parent 379de21 commit 47516c4
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 280 deletions.
4 changes: 2 additions & 2 deletions src/internal_modules/roc_sndio/backend_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ISource* BackendDispatcher::open_default_source(const Config& config) {
roc_panic_if_msg(device->type() != DeviceType_Source,
"backend dispatcher: unexpected non-source device");
}

return static_cast<ISource*>(device);
}

Expand All @@ -99,7 +99,7 @@ ISink* BackendDispatcher::open_sink(const address::IoUri& uri,
roc_panic_if_msg(device->type() != DeviceType_Sink,
"backend dispatcher: unexpected non-sink device");
}

return static_cast<ISink*>(device);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (c) 2023 Roc Streaming authors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include <stdio.h>

#include "roc_core/log.h"
Expand All @@ -11,29 +19,30 @@
namespace roc {
namespace sndio {

SndfileBackend::SndfileBackend() : first_created_(false) {

SndfileBackend::SndfileBackend()
: first_created_(false) {
roc_log(LogDebug, "sndfile backend: initializing");
}

void SndfileBackend::discover_drivers(core::Array<DriverInfo, MaxDrivers>& driver_list){

void SndfileBackend::discover_drivers(core::Array<DriverInfo, MaxDrivers>& driver_list) {
int total_number_of_drivers;

if(int errnum = sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &total_number_of_drivers, sizeof(int))){

if (int errnum = sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT,
&total_number_of_drivers, sizeof(int))) {
roc_panic("sndfile backend: %s", sf_error_number(errnum));
}

SF_FORMAT_INFO format_info;

for (int n = 0; n < total_number_of_drivers; n++) {
format_info.format = n;
if(int errnum = sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info))){
if (int errnum = sf_command(NULL, SFC_GET_FORMAT_MAJOR, &format_info,
sizeof(format_info))) {
roc_panic("sndfile backend: %s", sf_error_number(errnum));
}

const char* driver = format_info.extension;

if (!driver_list.push_back(DriverInfo(driver, DriverType_File,
DriverFlag_IsDefault
| DriverFlag_SupportsSource
Expand All @@ -44,17 +53,16 @@ void SndfileBackend::discover_drivers(core::Array<DriverInfo, MaxDrivers>& drive
}
}

IDevice * SndfileBackend::open_device(DeviceType device_type,
DriverType driver_type,
const char* driver,
const char* path,
const Config& config,
core::IArena& arena){

if(driver_type != DriverType_File){
IDevice* SndfileBackend::open_device(DeviceType device_type,
DriverType driver_type,
const char* driver,
const char* path,
const Config& config,
core::IArena& arena) {
if (driver_type != DriverType_File) {
roc_log(LogDebug, "sndfile backend: driver=%s is not a file type", driver);
return NULL;
}
return NULL;
}

first_created_ = true;

Expand All @@ -77,10 +85,12 @@ IDevice * SndfileBackend::open_device(DeviceType device_type,
} break;

case DeviceType_Source: {
core::ScopedPtr<SndfileSource> source(new (arena) SndfileSource(arena, config), arena);
core::ScopedPtr<SndfileSource> source(new (arena) SndfileSource(arena, config),
arena);
if (!source || !source->is_valid()) {
roc_log(LogDebug, "sndfile backend: can't construct source: driver=%s path=%s",
driver, path);
roc_log(LogDebug,
"sndfile backend: can't construct source: driver=%s path=%s", driver,
path);
return NULL;
}

Expand All @@ -100,7 +110,6 @@ IDevice * SndfileBackend::open_device(DeviceType device_type,
roc_panic("sndfile backend: invalid device type");
}

}

}
} // namespace sndio

} // namespace roc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SndfileBackend : public IBackend, core::NonCopyable<> {
public:
SndfileBackend();

//! Append supported drivers to the list.
//! Append supported drivers to the list.
virtual void discover_drivers(core::Array<DriverInfo, MaxDrivers>& driver_list);

//! Create and open a sink or source.
Expand Down
Loading

0 comments on commit 47516c4

Please sign in to comment.