Stereo Record

This commit is contained in:
Robin E. R. Davies
2025-02-27 14:17:24 -05:00
parent 229e85d608
commit eb7a7f3a48
6 changed files with 73 additions and 79 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ set (CMAKE_INSTALL_PREFIX "/usr/")
set (USE_PCH 1)
set (ENABLE_BACKTRACE 1)
set (ENABLE_BACKTRACE 0)
set (USE_SANITIZE OFF) # seems to be broken on Ubuntu 24.10
+1 -1
View File
@@ -2882,5 +2882,5 @@ void PiPedalModel::OnAlsaDriverTerminatedAbnormally() {
bool PiPedalModel::IsInUploadsDirectory(const std::string &path)
{
return !storage.IsInUploadsDirectory(path);
return storage.IsInUploadsDirectory(path);
}
+1 -57
View File
@@ -221,63 +221,7 @@ namespace pipedal
return readSpace_();
}
bool write_packet(size_t bytes, void *data)
{
if (MULTI_WRITER)
{
std::lock_guard writeLock{writeMutex};
if (writeSpace() < bytes + sizeof(bytes))
{
return false;
}
size_t index = this->writePosition;
for (size_t i = 0; i < sizeof(bytes); ++i)
{
buffer[(index++() & ringBufferMask] = ((uint8_t*)(&bytes))[i];
}
for (size_t i = 0; i < bytes; ++i)
{
buffer[(index++) & ringBufferMask] = data[i];
}
{
std::lock_guard lock(mutex);
this->writePosition = (index) & ringBufferMask;
}
if (SEMAPHORE_READER)
{
cvRead.notify_all();
}
return true;
}
else
{
if (writeSpace() < bytes + sizeof(bytes))
{
return false;
}
size_t index = this->writePosition;
for (size_t i = 0; i < sizeof(bytes); ++i)
{
buffer[(index++() & ringBufferMask] = ((uint8_t*)(&bytes))[i];
}
for (size_t i = 0; i < bytes; ++i)
{
buffer[(index++) & ringBufferMask] = data[i];
}
{
std::lock_guard lock(mutex);
this->writePosition = (index) & ringBufferMask;
}
if (SEMAPHORE_READER)
{
cvRead.notify_all();
}
return true;
}
}
bool write(size_t bytes, uint8_t *data)
{
if (MULTI_WRITER)
+44 -18
View File
@@ -246,6 +246,26 @@ public:
try
{
std::string segment = request_uri.segment(1);
if (segment == "downloadMediaFile") {
fs::path path = request_uri.query("path");
if (!fs::exists(path) || !this->model->IsInUploadsDirectory(path) || HasDotDot(path))
{
throw PiPedalException("File not found.");
}
auto mimeType = GetMimeType(path);
if (mimeType.empty()) {
throw PiPedalException("Can't download files of this type.");
}
res.set(HttpField::content_type, mimeType);
res.set(HttpField::cache_control, "no-cache");
std::string disposition = GetContentDispositionHeader(path.stem().string(), path.extension().string());
res.set(HttpField::content_disposition, disposition);
size_t contentLength = std::filesystem::file_size(path);
res.setContentLength(contentLength);
return;
}
if (segment == "downloadPluginPresets")
{
std::string name;
@@ -263,6 +283,7 @@ public:
res.set(HttpField::content_disposition, GetContentDispositionHeader(name, PLUGIN_PRESETS_EXTENSION));
return;
}
if (segment == "downloadPreset")
{
std::string name;
@@ -322,7 +343,29 @@ public:
{
std::string segment = request_uri.segment(1);
if (segment == "downloadPluginPresets")
if (segment == "downloadMediaFile") {
fs::path path = request_uri.query("path");
bool t = this->model->IsInUploadsDirectory(path);
std::cout << (t? "true": "false") << std::endl;
(void)t;
if (!fs::exists(path) || !this->model->IsInUploadsDirectory(path) || HasDotDot(path))
{
throw PiPedalException("File not found.");
}
auto mimeType = GetMimeType(path);
if (mimeType.empty()) {
throw PiPedalException("Can't download files of this type.");
}
res.set(HttpField::content_type, mimeType);
res.set(HttpField::cache_control, "no-cache");
std::string disposition = GetContentDispositionHeader(path.stem().string(), path.extension().string());
res.set(HttpField::content_disposition, disposition);
size_t contentLength = std::filesystem::file_size(path);
res.setContentLength(contentLength);
res.setBodyFile(path,false);
return;
} else if (segment == "downloadPluginPresets")
{
std::string name;
std::string content;
@@ -451,23 +494,6 @@ public:
{
std::string segment = request_uri.segment(1);
if (segment == "downloadMediaFile") {
fs::path path = request_uri.query("path");
if (!fs::exists(path) || !this->model->IsInUploadsDirectory(path) || HasDotDot(path))
{
throw PiPedalException("File not found.");
}
auto mimeType = GetMimeType(path);
if (mimeType.empty()) {
throw PiPedalException("Can't download files of this type.");
}
res.set(HttpField::content_type, mimeType);
res.set(HttpField::cache_control, "no-cache");
std::string disposition = GetContentDispositionHeader(path.stem().string(), path.extension().string());
res.set(HttpField::content_disposition, disposition);
res.setBodyFile(path,false);
}
if (segment == "uploadPluginPresets")
{
PluginPresets presets;
+12 -2
View File
@@ -101,6 +101,7 @@ export interface FilePropertyDialogProps extends WithStyles<typeof styles> {
instanceId: number,
selectedFile: string,
onOk: (fileProperty: UiFileProperty, selectedItem: string) => void,
onApply: (fileProperty: UiFileProperty, selectedItem: string) => void,
onCancel: () => void
};
export interface FilePropertyDialogState {
@@ -124,6 +125,7 @@ export interface FilePropertyDialogState {
newFolderDialogOpen: boolean;
renameDialogOpen: boolean;
moveDialogOpen: boolean;
initialSelection: string;
};
function pathExtension(path: string) {
@@ -218,7 +220,8 @@ export default withStyles(
menuAnchorEl: null,
newFolderDialogOpen: false,
renameDialogOpen: false,
moveDialogOpen: false
moveDialogOpen: false,
initialSelection: this.props.selectedFile
};
this.requestScroll = true;
}
@@ -380,6 +383,10 @@ export default withStyles(
onSelectValue(fileEntry: FileEntry) {
this.requestScroll = true;
if (!fileEntry.isDirectory)
{
this.props.onApply(this.props.fileProperty,fileEntry.pathname);
}
this.setState({
selectedFile: fileEntry.pathname,
selectedFileIsDirectory: fileEntry.isDirectory,
@@ -756,7 +763,10 @@ export default withStyles(
<div style={{ flex: "1 1 auto" }}>&nbsp;</div>
<Button variant="dialogSecondary" onClick={() => { this.props.onCancel(); }} aria-label="cancel">
<Button variant="dialogSecondary" onClick={() => {
this.props.onApply(this.props.fileProperty,this.state.initialSelection);
this.props.onCancel();
}} aria-label="cancel">
Cancel
</Button>
<Button variant="dialogPrimary" style={{ flex: "0 0 auto" }}
+14
View File
@@ -779,6 +779,20 @@ const PluginControlView =
onCancel={() => {
this.setState({ showFileDialog: false });
}}
onApply={(fileProperty,selectedFile) => {
this.model.setPatchProperty(
this.props.instanceId,
fileProperty.patchProperty,
JsonAtom.Path(selectedFile)
)
.then(() => {
})
.catch((error) => {
this.model.showAlert("Unable to complete the operation. " + error);
});
}}
onOk={(fileProperty, selectedFile) => {
this.model.setPatchProperty(