Read returns less data than requested

OSS specific Solaris discussion (x86/SPARC)

Moderators: cesium, dev, kodachi, hannu

Read returns less data than requested

Postby TomDon » Fri Sep 07, 2007 4:39 pm

I'm creating an application that requires saving the audio in one second chunks (more or less). Instead of the read returning 8k bytes, it return between 356-1659 bytes. Running on X86 Solaris 8.

---------------------------
./ossinfo
Version info: OSS/Solaris 3.99. 3d (0x00040000)

# of audio devices 10
# of MIDI devices 1
# of mixers devices 2
Audio devices (/dev/dsp*)
0: Crystal Semiconductor CS4280 Rev B (audio port 0 of card -1)
---------------------------

Snapshot of code includes
if ( (AudioFd = open("/dev/audio", O_RDONLY, 0)) != -1)

int tmp_int = AFMT_U8; /* unsigned 8 bits audio */
if ((err = ioctl (AudioFd, SNDCTL_DSP_SETFMT, &tmp_int)) != -1)

tmp_int = 1; /* 1 channel*/
if ((err = ioctl (AudioFd, SNDCTL_DSP_CHANNELS, &tmp_int)) != -1)

int sample_rate = 8000;
if ((err = ioctl (AudioFd, SNDCTL_DSP_SPEED, &sample_rate)) == -1)

int bytes_to_read = 8000;
char *temp_audio_buffer = new char[bytes_to_read];
len = read(audio_fd, temp_audio_buffer, bytes_to_read);
(len has a return value of between 356-1659 bytes instead of 8000)
---------------------------

Was able to run the above code on a X86 Solaris 8 machine without OSS without a problem.

Any ideas?
TomDon
New Member
 
Posts: 1
Joined: Fri Sep 07, 2007 3:50 pm

Return to Solaris

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron