From 062e947feaadd5754b33f2fc28b252ff050f038d Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 23 Feb 2013 01:03:52 +0200 Subject: channel count fix (portaudio can give more channels than specified) --- sound_detector/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound_detector/main.cpp') diff --git a/sound_detector/main.cpp b/sound_detector/main.cpp index 6caf280..67edc08 100644 --- a/sound_detector/main.cpp +++ b/sound_detector/main.cpp @@ -251,7 +251,8 @@ void handle_data() int stream_callback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) { - int16_t *buf = (int16_t*)input; + int16_t **bufs = (int16_t**)input; + int16_t *buf = bufs[0]; lock.lock(); buffer.insert(buffer.end(), buf, buf + frameCount); lock.unlock(); @@ -384,7 +385,7 @@ int main(int argc, char **argv) PaStreamParameters params; memset(¶ms, 0, sizeof(PaStreamParameters)); params.channelCount = 1; - params.sampleFormat = paInt16; + params.sampleFormat = paInt16 | paNonInterleaved; params.device = device; const PaDeviceInfo *info = Pa_GetDeviceInfo(device); params.suggestedLatency = info->defaultHighInputLatency; -- cgit v1.2.3