Skip to content

Commit

Permalink
rewrite of C lib audio and pulse module
Browse files Browse the repository at this point in the history
provide default sink and source support out of the box
  • Loading branch information
doums committed May 14, 2021
1 parent c70296a commit 141b5ed
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 137 deletions.
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "baru"
version = "0.2.7"
version = "0.2.8"
authors = ["pierre <[email protected]>"]
edition = "2018"
links = "netlink,audio"
Expand Down
14 changes: 8 additions & 6 deletions baru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,12 @@ mic:
#
placeholder: '-'

# index: u32, default: 0
# source_name: String, default: None
#
# The source index.
# If not provided, the default source will be used automatically.
# You can get it with `pactl list sources` command.
#
index: 1
source_name: "some_name"

# label: String, default: mic
#
Expand Down Expand Up @@ -421,11 +422,12 @@ sound:
#
placeholder: '-'

# index: u32, default: 0
# sink_name: String, default: None
#
# The sink index.
# If not provided, the default sink will be used automatically.
# You can get it with `pactl list sinks` command.
#
index: 1
sink_name: "some_name"

# label: String, default: sou
#
Expand Down
57 changes: 32 additions & 25 deletions lib/audio/include/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,41 @@
static bool alive = true;

typedef struct timespec
t_timespec;
t_timespec;

typedef struct volume {
uint32_t volume;
bool mute;
} t_volume;
typedef struct volume {
uint32_t volume;
bool mute;
} t_volume;

typedef void(* send_sink_cb)(void *, uint32_t, bool);
typedef void(* send_source_cb)(void *, uint32_t, bool);
typedef void(*send_cb)(void *, uint32_t, bool);

typedef struct data {
uint32_t tick;
uint32_t sink_index;
uint32_t source_index;
bool connected;
pa_context *context;
pa_mainloop *mainloop;
pa_mainloop_api *api;
t_volume sink_volume;
t_volume source_volume;
void *cb_context;
send_sink_cb sink_cb;
send_source_cb source_cb;
t_timespec start;
pa_operation *sink_op;
pa_operation *source_op;
} t_data;
typedef struct data {
const char *name;
bool use_default;
t_volume volume;
send_cb cb;
pa_operation *op;
} t_data;

void run(uint32_t tick, uint32_t sink_index, uint32_t source_index, void *, send_sink_cb, send_source_cb);
typedef struct main {
uint32_t tick;
bool connected;
pa_context *context;
pa_mainloop *mainloop;
pa_mainloop_api *api;
void *cb_context;
t_timespec start;
pa_operation *server_op;
t_data *sink;
t_data *source;
} t_main;

void run(uint32_t tick,
const char *sink_name,
const char *source_name,
void *cb_context,
send_cb,
send_cb);

#endif //AUDIO_H
Loading

0 comments on commit 141b5ed

Please sign in to comment.