128 audioDevice =
"/dev/audio";
134 fd = open( audioDevice.toLocal8Bit(), O_WRONLY | O_NONBLOCK );
135 int arg = fcntl(
fd, F_GETFL, 0 );
137 fcntl(
fd, F_SETFL, arg & ~O_NONBLOCK );
144 if ( ioctl(
fd, SNDCTL_DSP_SYNC, NULL ) < 0 ) {
149 if ( ioctl(
fd, SNDCTL_DSP_SAMPLESIZE, &bits ) < 0 ) {
154 if ( ioctl(
fd, SNDCTL_DSP_SPEED, &speed ) < 0 ) {
159 if ( ioctl(
fd, SNDCTL_DSP_STEREO, &stereo ) < 0 ) {
165 unsigned bufferBits =
log2( speed / 60 );
166 int fragSize = 0x00200000 | bufferBits;
168 ioctl(
fd, SNDCTL_DSP_SETFRAGMENT, &fragSize );
170 if ( ioctl(
fd, SNDCTL_DSP_GETBLKSIZE, &bs ) < 0 ) {
176 INFOLOG( QString(
"Blocksize audio = %1" ).arg( bs ) );
186 int format = AFMT_S16_LE;
187 if ( ioctl(
fd, SNDCTL_DSP_SETFMT, &format ) == -1 ) {
188 ERRORLOG(
"ERROR_IOCTL unable to set format" );
196 pthread_attr_init( &attr );