Skip to content

Commit 1512270

Browse files
authored
feat: add GetModuleList method (#111)
add GetModuleList method Log: pms: BUG-323877
1 parent ea6cf27 commit 1512270

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

pulse/pulse.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,24 @@ func (c *Context) MoveSourceOutputsByIndex(sourceOutputs []uint32, sourceIdx uin
341341
})
342342
}
343343

344+
// GetModuleList retrieves the list of loaded modules
345+
func (c *Context) GetModuleList() (r []*Module) {
346+
ck := newCookie()
347+
348+
c.safeDo(func() {
349+
C._get_module_info_list(c.loop, c.ctx, C.int64_t(ck.id))
350+
})
351+
352+
for _, info := range ck.ReplyList() {
353+
module := info.data.(*Module)
354+
if module == nil {
355+
continue
356+
}
357+
r = append(r, module)
358+
}
359+
return
360+
}
361+
344362
var (
345363
__context *Context
346364
__ctxLocker sync.Mutex

pulse/sync.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func NewPaInfo(data unsafe.Pointer, Type int) *paInfo {
3838
info.data = toServerInfo((*C.pa_server_info)(data))
3939
case C.PA_SUBSCRIPTION_EVENT_CARD:
4040
info.data = toCardInfo((*C.pa_card_info)(data))
41+
case C.PA_SUBSCRIPTION_EVENT_MODULE:
42+
info.data = toModuleInfo((*C.pa_module_info)(data))
4143
default:
4244
// current didn't support this type
4345
return nil

pulse/wrap.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,26 @@ type SampleSpec struct {
154154
Rate uint32
155155
Channels uint8
156156
}
157+
158+
type Module struct {
159+
Index uint32
160+
Name string
161+
Argument string
162+
NUsed uint32
163+
AutoUnload int // deprecated, but keep for completeness
164+
PropList map[string]string
165+
}
166+
167+
func toModuleInfo(info *C.pa_module_info) *Module {
168+
if info == nil {
169+
return nil
170+
}
171+
return &Module{
172+
Index: uint32(info.index),
173+
Name: C.GoString(info.name),
174+
Argument: C.GoString(info.argument),
175+
NUsed: uint32(info.n_used),
176+
AutoUnload: int(info.auto_unload),
177+
PropList: toProplist(info.proplist),
178+
}
179+
}

0 commit comments

Comments
 (0)