aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-12 00:42:33 +0200
committerMax Kellermann <max@duempel.org>2008-10-12 00:42:33 +0200
commitc297c8555f68b1795d91155b40d36f430a4556eb (patch)
treee9c7b7f892fcc571259ed5624168428a8d46bbdf
parentea25688e463cb4471b6eaa15935b94636fa6bd1b (diff)
downloadmpd-c297c8555f68b1795d91155b40d36f430a4556eb.tar.gz
mpd-c297c8555f68b1795d91155b40d36f430a4556eb.tar.xz
mpd-c297c8555f68b1795d91155b40d36f430a4556eb.zip
audio: removed audio_buffer.buffer
audio.c maintained one of MPD's many layers of audio buffers. It was without any benefit, since playAudio() can simply send the source buffer directly to the audio output plugin.
Diffstat (limited to '')
-rw-r--r--src/audio.c71
1 files changed, 2 insertions, 69 deletions
diff --git a/src/audio.c b/src/audio.c
index 353f8b8d2..6be976208 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -48,9 +48,6 @@ static uint8_t audioOpened;
static struct {
struct audio_format format;
-
- size_t size, position;
- char *buffer;
} audio_buffer;
static unsigned int audio_output_count(void)
@@ -262,21 +259,17 @@ static void syncAudioDeviceStates(void)
}
}
-static int flushAudioBuffer(void)
+int playAudio(const char *buffer, size_t length)
{
int ret = -1, err;
unsigned int i;
- if (audio_buffer.position == 0)
- return 0;
-
syncAudioDeviceStates();
for (i = 0; i < audioOutputArraySize; ++i)
if (audio_output_is_open(&audioOutputArray[i]))
audio_output_play(&audioOutputArray[i],
- audio_buffer.buffer,
- audio_buffer.position);
+ buffer, length);
while (1) {
int finished = 1;
@@ -308,35 +301,9 @@ static int flushAudioBuffer(void)
notify_wait(&audio_output_client_notify);
};
- audio_buffer.position = 0;
-
return ret;
}
-static size_t audio_buffer_size(const struct audio_format *af)
-{
- return audio_format_frame_size(af) * (af->sample_rate >> 5);
-}
-
-static void audio_buffer_resize(size_t size)
-{
- assert(audio_buffer.position == 0);
- assert((audio_buffer.size == 0) == (audio_buffer.buffer == NULL));
-
- if (audio_buffer.size == size)
- return;
-
- if (audio_buffer.buffer != NULL)
- free(audio_buffer.buffer);
-
- if (size > 0)
- audio_buffer.buffer = xmalloc(size);
- else
- audio_buffer.buffer = NULL;
-
- audio_buffer.size = size;
-}
-
int openAudioDevice(const struct audio_format *audioFormat)
{
int ret = -1;
@@ -347,10 +314,8 @@ int openAudioDevice(const struct audio_format *audioFormat)
if (!audioOpened ||
(audioFormat != NULL && !isCurrentAudioFormat(audioFormat))) {
- flushAudioBuffer();
if (audioFormat != NULL)
audio_buffer.format = *audioFormat;
- audio_buffer_resize(audio_buffer_size(&audio_buffer.format));
}
syncAudioDeviceStates();
@@ -374,30 +339,6 @@ int openAudioDevice(const struct audio_format *audioFormat)
return ret;
}
-int playAudio(const char *playChunk, size_t size)
-{
- size_t send_size;
-
- while (size > 0) {
- send_size = audio_buffer.size - audio_buffer.position;
- send_size = send_size < size ? send_size : size;
-
- assert(send_size > 0);
-
- memcpy(audio_buffer.buffer + audio_buffer.position, playChunk, send_size);
- audio_buffer.position += send_size;
- size -= send_size;
- playChunk += send_size;
-
- if (audio_buffer.position == audio_buffer.size) {
- if (flushAudioBuffer() < 0)
- return -1;
- }
- }
-
- return 0;
-}
-
void audio_output_pause_all(void)
{
unsigned int i;
@@ -416,7 +357,6 @@ void dropBufferedAudio(void)
unsigned int i;
syncAudioDeviceStates();
- audio_buffer.position = 0;
for (i = 0; i < audioOutputArraySize; ++i) {
if (audio_output_is_open(&audioOutputArray[i]))
@@ -430,13 +370,6 @@ void closeAudioDevice(void)
{
unsigned int i;
- if (audio_buffer.buffer != NULL) {
- flushAudioBuffer();
- free(audio_buffer.buffer);
- audio_buffer.buffer = NULL;
- audio_buffer.size = 0;
- }
-
for (i = 0; i < audioOutputArraySize; ++i)
audio_output_close(&audioOutputArray[i]);