mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Make sure audio output is flushed before closing devices in ALSA and OSS code.
This commit is contained in:
parent
037434b062
commit
8bef0e5b32
@ -1,3 +1,11 @@
|
||||
2004-12-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/sndfile-play.c
|
||||
In the ALSA output code, added call to snd_pcm_drain() just before
|
||||
snd_pcm_close() as suggested by Thomas Kaeding.
|
||||
In the OSS output code, added two ioctls (SNDCTL_DSP_POST and
|
||||
SNDCTL_DSP_SYNC) just before the close of the audio device.
|
||||
|
||||
2004-12-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/*.c src/sndfile.h.in
|
||||
|
@ -115,6 +115,7 @@ alsa_play (int argc, char *argv [])
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
snd_pcm_drain (alsa_dev) ;
|
||||
snd_pcm_close (alsa_dev) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
@ -140,7 +141,7 @@ alsa_open (int channels, int samplerate, int realtime)
|
||||
}
|
||||
else
|
||||
{ alsa_period_size = 1024 ;
|
||||
alsa_buffer_frames = 6 * alsa_period_size ;
|
||||
alsa_buffer_frames = 4 * alsa_period_size ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
|
||||
@ -185,7 +186,6 @@ alsa_open (int channels, int samplerate, int realtime)
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ;
|
||||
return NULL ;
|
||||
@ -381,6 +381,12 @@ linux_play (int argc, char *argv [])
|
||||
write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_POST) ") ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_SYNC) ") ;
|
||||
|
||||
close (audio_device) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
|
Loading…
Reference in New Issue
Block a user