diff options
author | Viliam Mateicka <viliam.mateicka@gmail.com> | 2008-12-31 16:46:41 +0100 |
---|---|---|
committer | Viliam Mateicka <viliam.mateicka@gmail.com> | 2008-12-31 16:46:41 +0100 |
commit | 9a70c4d06d51cca24dfb93847d1f82187d454e31 (patch) | |
tree | 444672f0ab76eca96692560201287d6f7a1a73b5 /src/output | |
parent | dd9af72a744d9c93966f5088931d7edbf28e1d1d (diff) | |
download | mpd-9a70c4d06d51cca24dfb93847d1f82187d454e31.tar.gz mpd-9a70c4d06d51cca24dfb93847d1f82187d454e31.tar.xz mpd-9a70c4d06d51cca24dfb93847d1f82187d454e31.zip |
Moving mixers to audio outputs
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/alsa_plugin.c | 22 | ||||
-rw-r--r-- | src/output/oss_plugin.c | 19 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c index 57d102c51..5f53729a7 100644 --- a/src/output/alsa_plugin.c +++ b/src/output/alsa_plugin.c @@ -18,6 +18,7 @@ #include "../output_api.h" #include "../utils.h" +#include "../mixer.h" #include <glib.h> #include <alsa/asoundlib.h> @@ -51,6 +52,9 @@ typedef struct _AlsaData { unsigned int period_time; int sampleSize; int useMmap; + + struct alsa_mixer *mixer; + } AlsaData; static const char * @@ -71,12 +75,15 @@ static AlsaData *newAlsaData(void) ret->buffer_time = MPD_ALSA_BUFFER_TIME_US; ret->period_time = 0; + ret->mixer = alsa_mixer_init(); + return ret; } static void freeAlsaData(AlsaData * ad) { g_free(ad->device); + alsa_mixer_finish(ad->mixer); free(ad); } @@ -125,8 +132,10 @@ static void *alsa_initDriver(mpd_unused struct audio_output *ao, free_global_registered = 1; } - if (param) + if (param) { alsa_configure(ad, param); + alsa_mixer_configure(ad->mixer, param); + } return ad; } @@ -181,6 +190,8 @@ static bool alsa_openDevice(void *data, struct audio_format *audioFormat) unsigned int period_time, period_time_ro; unsigned int buffer_time; + alsa_mixer_open(ad->mixer); + if ((bitformat = get_bitformat(audioFormat)) == SND_PCM_FORMAT_UNKNOWN) g_warning("ALSA device \"%s\" doesn't support %u bit audio\n", alsa_device(ad), audioFormat->bits); @@ -403,6 +414,7 @@ static void alsa_closeDevice(void *data) snd_pcm_close(ad->pcmHandle); ad->pcmHandle = NULL; } + alsa_mixer_close(ad->mixer); } static bool @@ -436,6 +448,13 @@ alsa_playAudio(void *data, const char *playChunk, size_t size) return true; } +static bool +alsa_control(void *data, int cmd, void *arg) +{ + AlsaData *ad = data; + return alsa_mixer_control(ad->mixer, cmd, arg); +} + const struct audio_output_plugin alsaPlugin = { .name = "alsa", .test_default_device = alsa_testDefault, @@ -445,4 +464,5 @@ const struct audio_output_plugin alsaPlugin = { .play = alsa_playAudio, .cancel = alsa_dropBufferedAudio, .close = alsa_closeDevice, + .control = alsa_control }; diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c index 4727823c3..1f582b2b4 100644 --- a/src/output/oss_plugin.c +++ b/src/output/oss_plugin.c @@ -20,6 +20,7 @@ */ #include "../output_api.h" +#include "../mixer.h" #include <glib.h> #include <sys/stat.h> @@ -53,6 +54,7 @@ typedef struct _OssData { int numSupported[3]; int *unsupported[3]; int numUnsupported[3]; + struct oss_mixer *mixer; } OssData; enum oss_support { @@ -273,6 +275,8 @@ static OssData *newOssData(void) supportParam(ret, SNDCTL_DSP_CHANNELS, 2); supportParam(ret, SNDCTL_DSP_SAMPLESIZE, 16); + ret->mixer = oss_mixer_init(); + return ret; } @@ -285,6 +289,8 @@ static void freeOssData(OssData * od) g_free(od->unsupported[OSS_CHANNELS]); g_free(od->unsupported[OSS_BITS]); + oss_mixer_finish(od->mixer); + free(od); } @@ -348,6 +354,7 @@ static void *oss_open_default(ConfigParam *param) if (ret[i] == 0) { OssData *od = newOssData(); od->device = default_devices[i]; + oss_mixer_configure(od->mixer, param); return od; } } @@ -388,6 +395,7 @@ static void *oss_initDriver(mpd_unused struct audio_output *audioOutput, if (bp) { OssData *od = newOssData(); od->device = bp->value; + oss_mixer_configure(od->mixer, param); return od; } } @@ -513,6 +521,8 @@ oss_openDevice(void *data, struct audio_format *audioFormat) od->audio_format.bits, od->audio_format.channels, od->audio_format.sample_rate); + oss_mixer_open(od->mixer); + return ret; } @@ -521,6 +531,7 @@ static void oss_closeDevice(void *data) OssData *od = data; oss_close(od); + oss_mixer_close(od->mixer); } static void oss_dropBufferedAudio(void *data) @@ -559,6 +570,13 @@ oss_playAudio(void *data, const char *playChunk, size_t size) return true; } +static bool +oss_control(void *data, int cmd, void *arg) +{ + OssData *od = data; + return oss_mixer_control(od->mixer, cmd, arg); +} + const struct audio_output_plugin ossPlugin = { .name = "oss", .test_default_device = oss_testDefault, @@ -568,4 +586,5 @@ const struct audio_output_plugin ossPlugin = { .play = oss_playAudio, .cancel = oss_dropBufferedAudio, .close = oss_closeDevice, + .control = oss_control, }; |