c++ - what is alsa library read value meaning? -


i reading sound values alsa library , return value 40239717. did not understand means. how convert value normal form.

my read code this:

if ((err = snd_pcm_open (&capture_handle, "default", snd_pcm_stream_capture, 0)) < 0) {             qdebug("cannot open audio device default\n");             exit (1);     }      if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {             qdebug ("cannot allocate hardware parameter structure\n");             exit (1);     }      if ((err = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0) {             qdebug("cannot initialize hardware parameter structure\n");             exit (1);     }      if ((err = snd_pcm_hw_params_set_access (capture_handle, hw_params, snd_pcm_access_rw_interleaved)) < 0) {             qdebug ("cannot set access type \n");             exit (1);     }      if ((err = snd_pcm_hw_params_set_format (capture_handle, hw_params, snd_pcm_format_s16_le)) < 0) {             qdebug ("cannot set sample format\n");             exit (1);     }      if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0) {             qdebug ("cannot set sample rate\n");             exit (1);     }      if ((err = snd_pcm_hw_params_set_period_size_near (capture_handle, hw_params, &frame, 0)) < 0) {             qdebug ("cannot set sample rate\n");             exit (1);     }     if ((err = snd_pcm_hw_params_set_channels (capture_handle, hw_params, 2)) < 0) {             qdebug ( "cannot set channel count\n");             exit (1);     }      if ((err = snd_pcm_hw_params (capture_handle, hw_params)) < 0) {             qdebug ("cannot set parameters\n");             exit (1);     }     if ((err = snd_pcm_prepare (capture_handle)) < 0) {             qdebug ("cannot prepare audio interface use\n");             exit (1);     }     if ((err = snd_pcm_readi(capture_handle,buffer,frame)) != frame) {                       qdebug("read audio interface failed\n");           } 

you configuring device 16-bit samples (snd_pcm_format_s16_le).

the value 40239717 not fit 16 bits, using wrong data type read buffer. ensure buffer has type int16_t or signed short int.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -