Skip to content

Commit

Permalink
FEAT: attach a widget to camera device
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin committed Jul 2, 2020
1 parent f51c298 commit baadf0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
14 changes: 12 additions & 2 deletions modules/view/backends/gtk3/camera.reds
Expand Up @@ -45,14 +45,24 @@ camera: context [
free as byte-ptr! cfg
]

start: func [
attach: func [
cfg [integer!]
widget [int-ptr!]
cb [int-ptr!]
/local
config [v4l2-config!]
][
config: as v4l2-config! cfg
v4l2/start config cb
v4l2/attach config widget cb
]

start: func [
cfg [integer!]
/local
config [v4l2-config!]
][
config: as v4l2-config! cfg
v4l2/start config
]

get-data: func [
Expand Down
12 changes: 10 additions & 2 deletions modules/view/backends/gtk3/v4l2.reds
Expand Up @@ -50,6 +50,7 @@ v4l2-config!: alias struct! [
mutex [pthread_mutex_t value]
cond [pthread_cond_t value]
cb [int-ptr!]
widget [int-ptr!]
]

v4l2: context [
Expand Down Expand Up @@ -485,9 +486,17 @@ v4l2: context [
pthread_mutex_unlock :config/mutex
]

start: func [
attach: func [
config [v4l2-config!]
widget [int-ptr!]
cb [int-ptr!]
][
config/widget: widget
config/cb: cb
]

start: func [
config [v4l2-config!]
return: [logic!]
/local
hr [integer!]
Expand All @@ -502,7 +511,6 @@ v4l2: context [
pthread_mutex_destroy :config/mutex
return false
]
config/cb: cb
hr: pthread_create :config/thread null as int-ptr! :thread-cb as int-ptr! config
if hr <> 0 [return false]
config/running?: yes
Expand Down

0 comments on commit baadf0a

Please sign in to comment.