Skip to content

Commit 3513fdf

Browse files
authored
Merge pull request #3885 from BsAtHome/fix_hal-streamer
hal: fix bugs in the hal-streamer interface and implementation
2 parents 6cb44da + aae151d commit 3513fdf

File tree

5 files changed

+453
-374
lines changed

5 files changed

+453
-374
lines changed

docs/src/man/man3/hal_stream.3.adoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ int hal_stream_maxdepth(hal_stream_t* stream);
2121
int hal_stream_num_underruns(hal_stream_t* stream);
2222
int hal_stream_num_overruns(hal_stream_t* stream);
2323
24-
int hal_stream_read(hal_stream_t* stream, union hal_stream_data* buf, unsigned* sampleno);
24+
int hal_stream_read(hal_stream_t* stream, hal_stream_data_u *buf, unsigned* sampleno);
2525
bool hal_stream_readable(hal_stream_t* stream);
2626
27-
int hal_stream_write(hal_stream_t* stream, union hal_stream_data* buf);
27+
int hal_stream_write(hal_stream_t* stream, hal_stream_data_u *buf);
2828
bool hal_stream_writable(hal_stream_t* stream);
2929
3030
#ifdef ULAPI
@@ -115,16 +115,16 @@ depth::
115115
The number of samples that can be unread before any samples are lost
116116
(overrun)
117117
typestring::
118-
A typestring is a case-insensitive string which consists of one or
119-
more of the following type characters:
118+
A typestring is limited to 20 characters. A typestring is a
119+
case-insensitive string which consists of one or more of the
120+
following type characters:
120121
+
121-
[upperalpha, start=2]
122-
. for bool / hal_bit_t
123-
. for int32_t / hal_s32_t
124-
. for uint32_t / hal_u32_t
125-
. for real_t / hal_float_t
126-
+
127-
A typestring is limited to 16 characters.
122+
* B for bool / hal_bit_t
123+
* S for rtapi_s32 / hal_s32_t
124+
* U for rtapi_u32 / hal_u32_t
125+
* F for real_t / hal_float_t
126+
* L for rtapi_s64 / hal_s64_t
127+
* K for rtapi_u64 / hal_u64_t
128128

129129
buf::
130130
A buffer big enough to hold all the data in one sample.

src/hal/hal.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -927,30 +927,32 @@ extern void hal_port_wait_writable(hal_port_t** port, unsigned count, sig_atomic
927927
#endif
928928

929929

930-
931-
932-
933-
934-
union hal_stream_data {
935-
real_t f;
936-
bool b;
937-
int32_t s;
938-
uint32_t u;
939-
};
940-
941-
struct hal_stream_shm; // Forward declaration. Only relevant in hal_lib.c.
942-
typedef struct {
943-
int comp_id, shmem_id;
944-
struct hal_stream_shm *fifo;
945-
} hal_stream_t;
946-
947930
/**
948931
* HAL streams are modeled after sampler/stream and will hopefully replace
949932
* the independent implementations there.
950933
*
951934
* There may only be one reader and one writer but this is not enforced
952935
*/
953936

937+
typedef union hal_stream_data {
938+
real_t f;
939+
bool b;
940+
rtapi_s32 s;
941+
rtapi_u32 u;
942+
rtapi_s64 l;
943+
rtapi_u64 k;
944+
} hal_stream_data_u;
945+
typedef hal_stream_data_u *hal_stream_data_ptr_u;
946+
947+
struct __hal_stream_shm_t; // Forward declaration. Only relevant in hal_lib.c.
948+
949+
typedef struct __hal_stream_t {
950+
int comp_id;
951+
int shmem_id;
952+
struct __hal_stream_shm_t *fifo;
953+
} hal_stream_t;
954+
typedef hal_stream_t *hal_stream_ptr_t;
955+
954956
#define HAL_STREAM_MAX_PINS (21)
955957
/** create and attach a stream */
956958
extern int hal_stream_create(hal_stream_t *stream, int comp, int key, unsigned depth, const char *typestring);
@@ -967,7 +969,7 @@ extern int hal_stream_element_count(hal_stream_t *stream);
967969
extern hal_type_t hal_stream_element_type(hal_stream_t *stream, int idx);
968970

969971
// only one reader and one writer is allowed.
970-
extern int hal_stream_read(hal_stream_t *stream, union hal_stream_data *buf, unsigned *sampleno);
972+
extern int hal_stream_read(hal_stream_t *stream, hal_stream_data_u *buf, unsigned *sampleno);
971973
extern bool hal_stream_readable(hal_stream_t *stream);
972974
extern int hal_stream_depth(hal_stream_t *stream);
973975
extern unsigned hal_stream_maxdepth(hal_stream_t *stream);
@@ -977,7 +979,7 @@ extern int hal_stream_num_overruns(hal_stream_t *stream);
977979
extern void hal_stream_wait_readable(hal_stream_t *stream, sig_atomic_t *stop);
978980
#endif
979981

980-
extern int hal_stream_write(hal_stream_t *stream, union hal_stream_data *buf);
982+
extern int hal_stream_write(hal_stream_t *stream, hal_stream_data_u *buf);
981983
extern bool hal_stream_writable(hal_stream_t *stream);
982984
#ifdef ULAPI
983985
extern void hal_stream_wait_writable(hal_stream_t *stream, sig_atomic_t *stop);

0 commit comments

Comments
 (0)