diff options
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/AlsaOutputPlugin.cxx | 11 | ||||
-rw-r--r-- | src/output/FifoOutputPlugin.cxx | 3 | ||||
-rw-r--r-- | src/output/HttpdOutputPlugin.cxx | 14 | ||||
-rw-r--r-- | src/output/JackOutputPlugin.cxx | 4 | ||||
-rw-r--r-- | src/output/NullOutputPlugin.cxx | 2 | ||||
-rw-r--r-- | src/output/OSXOutputPlugin.cxx | 47 | ||||
-rw-r--r-- | src/output/PulseOutputPlugin.hxx | 2 |
7 files changed, 32 insertions, 51 deletions
diff --git a/src/output/AlsaOutputPlugin.cxx b/src/output/AlsaOutputPlugin.cxx index 4877d3a46..b5ca511b2 100644 --- a/src/output/AlsaOutputPlugin.cxx +++ b/src/output/AlsaOutputPlugin.cxx @@ -27,7 +27,6 @@ #include "util/Domain.hxx" #include "Log.hxx" -#include <glib.h> #include <alsa/asoundlib.h> #include <string> @@ -118,7 +117,7 @@ struct AlsaOutput { * It contains silence samples, enough to fill one period (see * #period_frames). */ - void *silence; + uint8_t *silence; AlsaOutput():mode(0), writei(snd_pcm_writei) { } @@ -593,8 +592,8 @@ configure_hw: ad->period_frames = alsa_period_size; ad->period_position = 0; - ad->silence = g_malloc(snd_pcm_frames_to_bytes(ad->pcm, - alsa_period_size)); + ad->silence = new uint8_t[snd_pcm_frames_to_bytes(ad->pcm, + alsa_period_size)]; snd_pcm_format_set_silence(format, ad->silence, alsa_period_size * channels); @@ -641,7 +640,7 @@ alsa_setup_dsd(AlsaOutput *ad, const AudioFormat audio_format, error.Format(alsa_output_domain, "Failed to configure DSD-over-USB on ALSA device \"%s\"", alsa_device(ad)); - g_free(ad->silence); + delete[] ad->silence; return false; } @@ -811,7 +810,7 @@ alsa_close(struct audio_output *ao) AlsaOutput *ad = (AlsaOutput *)ao; snd_pcm_close(ad->pcm); - g_free(ad->silence); + delete[] ad->silence; } static size_t diff --git a/src/output/FifoOutputPlugin.cxx b/src/output/FifoOutputPlugin.cxx index aeb9a6a87..7963d8c82 100644 --- a/src/output/FifoOutputPlugin.cxx +++ b/src/output/FifoOutputPlugin.cxx @@ -22,7 +22,6 @@ #include "ConfigError.hxx" #include "OutputAPI.hxx" #include "Timer.hxx" -#include "system/fd_util.h" #include "fs/AllocatedPath.hxx" #include "fs/FileSystem.hxx" #include "util/Error.hxx" @@ -30,10 +29,8 @@ #include "Log.hxx" #include "open.h" -#include <sys/types.h> #include <sys/stat.h> #include <errno.h> -#include <string.h> #include <unistd.h> #define FIFO_BUFFER_SIZE 65536 /* pipe capacity on Linux >= 2.6.11 */ diff --git a/src/output/HttpdOutputPlugin.cxx b/src/output/HttpdOutputPlugin.cxx index 369c06937..8cbc150ad 100644 --- a/src/output/HttpdOutputPlugin.cxx +++ b/src/output/HttpdOutputPlugin.cxx @@ -33,8 +33,6 @@ #include "util/Domain.hxx" #include "Log.hxx" -#include <glib.h> - #include <assert.h> #include <sys/types.h> @@ -199,9 +197,10 @@ HttpdOutput::OnAccept(int fd, const sockaddr &address, #ifdef HAVE_LIBWRAP if (address.sa_family != AF_UNIX) { - char *hostaddr = sockaddr_to_string(&address, address_length, - IgnoreError()); - const char *progname = g_get_prgname(); + const auto hostaddr = sockaddr_to_string(&address, + address_length); + // TODO: shall we obtain the program name from argv[0]? + const char *progname = "mpd"; struct request_info req; request_init(&req, RQ_FILE, fd, RQ_DAEMON, progname, 0); @@ -212,13 +211,10 @@ HttpdOutput::OnAccept(int fd, const sockaddr &address, /* tcp wrappers says no */ FormatWarning(httpd_output_domain, "libwrap refused connection (libwrap=%s) from %s", - progname, hostaddr); - g_free(hostaddr); + progname, hostaddr.c_str()); close_socket(fd); return; } - - g_free(hostaddr); } #else (void)address; diff --git a/src/output/JackOutputPlugin.cxx b/src/output/JackOutputPlugin.cxx index 7ed672f95..ef06b5abf 100644 --- a/src/output/JackOutputPlugin.cxx +++ b/src/output/JackOutputPlugin.cxx @@ -34,10 +34,6 @@ #include <stdlib.h> #include <string.h> -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> -#include <errno.h> enum { MAX_PORTS = 16, diff --git a/src/output/NullOutputPlugin.cxx b/src/output/NullOutputPlugin.cxx index e2eec9dbc..a901b7d2a 100644 --- a/src/output/NullOutputPlugin.cxx +++ b/src/output/NullOutputPlugin.cxx @@ -22,8 +22,6 @@ #include "OutputAPI.hxx" #include "Timer.hxx" -#include <assert.h> - struct NullOutput { struct audio_output base; diff --git a/src/output/OSXOutputPlugin.cxx b/src/output/OSXOutputPlugin.cxx index 97ebae056..907cb0346 100644 --- a/src/output/OSXOutputPlugin.cxx +++ b/src/output/OSXOutputPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "OSXOutputPlugin.hxx" #include "OutputAPI.hxx" -#include "util/fifo_buffer.h" +#include "util/DynamicFifoBuffer.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "thread/Mutex.hxx" @@ -44,7 +44,7 @@ struct OSXOutput { Mutex mutex; Cond condition; - struct fifo_buffer *buffer; + DynamicFifoBuffer<uint8_t> *buffer; }; static constexpr Domain osx_output_domain("osx_output"); @@ -207,22 +207,19 @@ osx_render(void *vdata, od->mutex.lock(); - size_t nbytes; - const void *src = fifo_buffer_read(od->buffer, &nbytes); + auto src = od->buffer->Read(); + if (!src.IsEmpty()) { + if (src.size > buffer_size) + src.size = buffer_size; - if (src != NULL) { - if (nbytes > buffer_size) - nbytes = buffer_size; - - memcpy(buffer->mData, src, nbytes); - fifo_buffer_consume(od->buffer, nbytes); - } else - nbytes = 0; + memcpy(buffer->mData, src.data, src.size); + od->buffer->Consume(src.size); + } od->condition.signal(); od->mutex.unlock(); - buffer->mDataByteSize = nbytes; + buffer->mDataByteSize = src.size; unsigned i; for (i = 1; i < buffer_list->mNumberBuffers; ++i) { @@ -298,7 +295,7 @@ osx_output_cancel(struct audio_output *ao) OSXOutput *od = (OSXOutput *)ao; const ScopeLock protect(od->mutex); - fifo_buffer_clear(od->buffer); + od->buffer->Clear(); } static void @@ -309,7 +306,7 @@ osx_output_close(struct audio_output *ao) AudioOutputUnitStop(od->au); AudioUnitUninitialize(od->au); - fifo_buffer_free(od->buffer); + delete od->buffer; } static bool @@ -370,8 +367,8 @@ osx_output_open(struct audio_output *ao, AudioFormat &audio_format, } /* create a buffer of 1s */ - od->buffer = fifo_buffer_new(audio_format.sample_rate * - audio_format.GetFrameSize()); + od->buffer = new DynamicFifoBuffer<uint8_t>(audio_format.sample_rate * + audio_format.GetFrameSize()); status = AudioOutputUnitStart(od->au); if (status != 0) { @@ -393,23 +390,21 @@ osx_output_play(struct audio_output *ao, const void *chunk, size_t size, const ScopeLock protect(od->mutex); - void *dest; - size_t max_length; - + DynamicFifoBuffer<uint8_t>::Range dest; while (true) { - dest = fifo_buffer_write(od->buffer, &max_length); - if (dest != NULL) + dest = od->buffer->Write(); + if (!dest.IsEmpty()) break; /* wait for some free space in the buffer */ od->condition.wait(od->mutex); } - if (size > max_length) - size = max_length; + if (size > dest.size) + size = dest.size; - memcpy(dest, chunk, size); - fifo_buffer_append(od->buffer, size); + memcpy(dest.data, chunk, size); + od->buffer->Append(size); return size; } diff --git a/src/output/PulseOutputPlugin.hxx b/src/output/PulseOutputPlugin.hxx index 0ed8404bc..69d6c5f99 100644 --- a/src/output/PulseOutputPlugin.hxx +++ b/src/output/PulseOutputPlugin.hxx @@ -41,6 +41,6 @@ pulse_output_clear_mixer(PulseOutput *po, PulseMixer *pm); bool pulse_output_set_volume(PulseOutput *po, - const struct pa_cvolume *volume, Error &error); + const pa_cvolume *volume, Error &error); #endif |