SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
dsp_buffer.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "dll_export.h"
8#include <cstddef>
9#include <cstdint>
10#include <volk/volk.h>
11
12namespace satdump
13{
14 namespace ndsp
15 {
29 {
30 DSP_BUFFER_TYPE_TERMINATOR_PROPAGATING = 0,
31 DSP_BUFFER_TYPE_TERMINATOR_NON_PROPAGATING = 1,
32 DSP_BUFFER_TYPE_SAMPLES = 2,
33 DSP_BUFFER_TYPE_INVALID = 255,
34 };
35
36 SATDUMP_DLL extern const size_t volk_alignment;
37
52 {
53 private:
54 void *ptr = nullptr;
55 size_t ptr_size = 0;
56
57 public:
58 dsp_buffer_type_t type = DSP_BUFFER_TYPE_INVALID;
59 uint8_t typesize = 0;
60 uint32_t max_size = 0;
61 uint32_t size = 0;
62
63 public:
64 friend class DSPStream;
65
66 public:
71 template <typename T>
72 inline T *getSamples()
73 {
74 return (T *)ptr;
75 }
76
82 inline bool isTerminator() { return type == DSP_BUFFER_TYPE_TERMINATOR_PROPAGATING || type == DSP_BUFFER_TYPE_TERMINATOR_NON_PROPAGATING; }
83
90 inline bool terminatorShouldPropagate() { return type == DSP_BUFFER_TYPE_TERMINATOR_PROPAGATING; }
91
92 // /**
93 // * @brief Frees the pointer. This MUST be called once you're
94 // * done doing your DSP with this buffer! Otherwise things will
95 // * leak. BADLY leak!
96 // *
97 // * NOTE TODOREWORK : probably only needed for SAMPLES buffers?
98 // */
99 // inline void free() { volk_free(ptr); }
100
101 // public:
102 // /**
103 // * @brief Create a terminator buffer
104 // * @param prop Whether this terminator should be propagating
105 // * @return the new DSP buffer
106 // */
107 // static DSPBuffer newBufferTerminator(bool prop = true)
108 // {
109 // DSPBuffer b;
110 // b.type = prop ? DSP_BUFFER_TYPE_TERMINATOR_PROPAGATING : DSP_BUFFER_TYPE_TERMINATOR_NON_PROPAGATING;
111 // return b;
112 // }
113
114 // /**
115 // * @brief Create a sample buffer
116 // * @param size size of the new buffer (max_size,
117 // * size is left at 0)
118 // * @return the new DSP buffer
119 // */
120 // template <typename T>
121 // static DSPBuffer newBufferSamples(uint32_t size)
122 // {
123 // DSPBuffer b;
124 // b.type = DSP_BUFFER_TYPE_SAMPLES;
125 // b.max_size = size;
126 // b.ptr_size = size * sizeof(T);
127 // b.ptr = volk_malloc(b.ptr_size, volk_alignment);
128 // return b;
129 // }
130 };
131 } // namespace ndsp
132} // namespace satdump
DSP Buffer class.
Definition dsp_buffer.h:52
bool terminatorShouldPropagate()
Checks if this buffer is a propagating terminator. If it is, a propagating terminator should be sent ...
Definition dsp_buffer.h:90
bool isTerminator()
Checks if this buffer is a terminator. This covers BOTH propagating and normal terminator markers.
Definition dsp_buffer.h:82
T * getSamples()
Get sample pointer.
Definition dsp_buffer.h:72
dsp_buffer_type_t
DSP Buffer content type.
Definition dsp_buffer.h:29