Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
check for mapped reader (#74)
Browse files Browse the repository at this point in the history
Fixes an unchecked failure in `acquire_map_read()` caused when a caller
fails to call `acquire_unmap_read()` at the right time.

For example:

```c
acquire_map_read(runtime,0,&beg,&end);
// When end>beg
acquire_map_read(runtime,0,beg,end); // Should return AcquireStatus_Error
```

whereas


```c
acquire_map_read(runtime,0,&beg,&end);
// When end>beg
acquire_unmap_read(runtime,0,&beg,&end);
acquire_map_read(runtime,0,beg,end); // Should return AcquireStatus_Ok
```

acquire-project/acquire-driver-common#34 depends on this
  • Loading branch information
nclack authored Aug 7, 2023
1 parent 5a5d981 commit a32633e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/acquire.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "device/hal/camera.h"
#include "logger.h"
#include "platform.h"
#include "runtime/channel.h"
#include "runtime/video.h"
#include "runtime/vfslice.h"

Expand Down Expand Up @@ -96,8 +97,11 @@ acquire_map_read(const struct AcquireRuntime* self_,
"Invalid parameter: `istream` was out-of-bounds (%d).",
countof(self->video));
self = containerof(self_, struct runtime, handle);
EXPECT(self->video[istream].monitor.reader.state == ChannelState_Unmapped,
"Expected an unmapped reader. See acquire_unmap_read().");
struct vfslice_mut slice = make_vfslice_mut(channel_read_map(
&self->video[istream].sink.in, &self->video[istream].monitor.reader));
CHECK(self->video[istream].monitor.reader.status == Channel_Ok);
*beg = slice.beg;
*end = slice.end;
return AcquireStatus_Ok;
Expand Down

0 comments on commit a32633e

Please sign in to comment.