Skip to content

Commit 4851de2

Browse files
committed
pcm: Try to make status struct more friendly to compilers
Let's see if this helps against #135
1 parent f98f7c5 commit 4851de2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pcm.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,12 +1154,13 @@ impl<'a> fmt::Debug for SwParams<'a> {
11541154
const STATUS_SIZE: usize = 152;
11551155

11561156
/// [snd_pcm_status_t](http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m___status.html) wrapper
1157-
pub struct Status([u8; STATUS_SIZE]);
1157+
#[derive(Debug)]
1158+
pub struct Status([u64; (STATUS_SIZE+7)/8]);
11581159

11591160
impl Status {
11601161
fn new() -> Status {
11611162
assert!(unsafe { alsa::snd_pcm_status_sizeof() } as usize <= STATUS_SIZE);
1162-
Status([0; STATUS_SIZE])
1163+
Status([0; (STATUS_SIZE+7)/8])
11631164
}
11641165

11651166
fn ptr(&self) -> *mut alsa::snd_pcm_status_t { self.0.as_ptr() as *const _ as *mut alsa::snd_pcm_status_t }
@@ -1218,8 +1219,9 @@ impl StatusBuilder {
12181219
self
12191220
}
12201221

1221-
pub fn build(self, pcm: &PCM) -> Result<Status> {
1222-
acheck!(snd_pcm_status(pcm.0, self.0.ptr())).map(|_| self.0)
1222+
pub fn build(mut self, pcm: &PCM) -> Result<Status> {
1223+
let p = self.0.0.as_mut_ptr() as *mut alsa::snd_pcm_status_t;
1224+
acheck!(snd_pcm_status(pcm.0, p)).map(|_| self.0)
12231225
}
12241226
}
12251227

0 commit comments

Comments
 (0)