output/alsa: use new[] instead of g_malloc()

This commit is contained in:
Max Kellermann 2013-12-14 22:17:19 +01:00
parent 4b7a418e28
commit 65b8e52d80
1 changed files with 5 additions and 6 deletions

View File

@ -27,7 +27,6 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <glib.h>
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <string> #include <string>
@ -118,7 +117,7 @@ struct AlsaOutput {
* It contains silence samples, enough to fill one period (see * It contains silence samples, enough to fill one period (see
* #period_frames). * #period_frames).
*/ */
void *silence; uint8_t *silence;
AlsaOutput():mode(0), writei(snd_pcm_writei) { AlsaOutput():mode(0), writei(snd_pcm_writei) {
} }
@ -593,8 +592,8 @@ configure_hw:
ad->period_frames = alsa_period_size; ad->period_frames = alsa_period_size;
ad->period_position = 0; ad->period_position = 0;
ad->silence = g_malloc(snd_pcm_frames_to_bytes(ad->pcm, ad->silence = new uint8_t[snd_pcm_frames_to_bytes(ad->pcm,
alsa_period_size)); alsa_period_size)];
snd_pcm_format_set_silence(format, ad->silence, snd_pcm_format_set_silence(format, ad->silence,
alsa_period_size * channels); alsa_period_size * channels);
@ -641,7 +640,7 @@ alsa_setup_dsd(AlsaOutput *ad, const AudioFormat audio_format,
error.Format(alsa_output_domain, error.Format(alsa_output_domain,
"Failed to configure DSD-over-USB on ALSA device \"%s\"", "Failed to configure DSD-over-USB on ALSA device \"%s\"",
alsa_device(ad)); alsa_device(ad));
g_free(ad->silence); delete[] ad->silence;
return false; return false;
} }
@ -811,7 +810,7 @@ alsa_close(struct audio_output *ao)
AlsaOutput *ad = (AlsaOutput *)ao; AlsaOutput *ad = (AlsaOutput *)ao;
snd_pcm_close(ad->pcm); snd_pcm_close(ad->pcm);
g_free(ad->silence); delete[] ad->silence;
} }
static size_t static size_t