aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs (follow)
Commit message (Collapse)AuthorAgeFilesLines
* use C99 struct initializersMax Kellermann2008-09-2910-90/+76
| | | | | | The old struct initializers are error prone and don't allow moving elements around. Since we are going to overhaul some of the APIs soon, it's easier to have all implementations use C99 initializers.
* removed union const_hackMax Kellermann2008-09-291-2/+4
| | | | | The union const_hack is only used at one place in the shout plugin. Remove its global type declaration.
* switch to C99 types, part IIMax Kellermann2008-09-292-2/+2
| | | | | Do full C99 integer type conversion in all modules which were not touched by Eric's merged patch.
* Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-292-3/+3
| | | | | | | | | | | | | | | Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the mind needs to retrain itself to skip over the first 4 tokens of a type to get to its meaning. So avoid having extra characters on my terminal to make it easier to follow code at 2:30 am in the morning. Please report any new issues you may come across on Free toolchains. I realize how difficult it can be to build/maintain cross-compiling toolchains and I have no intention of forcing people to upgrade their toolchains to build mpd. Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
* output: make "struct audio_output" opaque for output pluginsMax Kellermann2008-09-248-175/+184
| | | | | | | | | | | We have eliminated direct accesses to the audio_output struct from the all output plugins. Make it opaque for them, and move its real declaration to output_internal.h, similar to decoder_internal.h. Pass the opaque structure to plugin.init() only, which will return the plugin's data pointer on success, and NULL on failure. This data pointer will be passed to all other methods instead of the audio_output struct.
* output: added audio_output_closed()Max Kellermann2008-09-241-1/+1
| | | | | | The JACK output plugin needs to reset its "opened" flag when the JACK server fails. To prevent it from accessing the audio_output struct directly introduce the API function audio_output_closed().
* output: added audio_output_get_name()Max Kellermann2008-09-241-1/+1
| | | | | | Reduce direct accesses to the audio_output struct from the plugins: this time, eliminate all accesses to audio_output.name. The name is required by some plugins for log messages.
* output: set audio_output->open=1 in audio_output_task()Max Kellermann2008-09-2410-38/+1
| | | | | Since the output plugin returns a value indicating success or error, we can have the output core code assign the "open" flag.
* output: pass audio_format to plugin.init() and plugin.open()Max Kellermann2008-09-2410-30/+54
| | | | | | | Pass the globally configured audio_format as a const pointer to plugin.init(). plugin.open() gets a writable pointer which contains the audio_format requested by the plugin. Its initial value is either the configured audio_format or the input file's audio_format.
* audio_format: added audio_format_sample_size()Max Kellermann2008-09-234-4/+4
| | | | | | The inline function audio_format_sample_size() calculates how many bytes each sample consumes. This function already takes into account that 24 bit samples are 4 bytes long, not 3.
* alsa: re-enable-nonblocking, but sleep if busyEric Wong2008-09-231-7/+10
| | | | | | | Instead of letting ALSA block for us (and potentially allowing something stupid on certain hardware or drivers), we do the sleeping ourselves. We calculate the sleep to be a fraction of period_time to avoid oversleeping (and thus audible skipping).
* shout: don't write empty buffersMax Kellermann2008-09-121-2/+4
| | | | | Add a check to write_page() which checks if there is actually data. Don't bother to call shout_send() if there is not.
* shout: removed clear_shout_buffer()Max Kellermann2008-09-121-8/+2
| | | | | The function is trivial, without a benefit. Also don't initialize buf.data[0], this is not a null terminated string.
* shout: make the shout_buffer staticMax Kellermann2008-09-124-12/+4
| | | | | | | Since the buffer size is known at compile time, we can save an indirection by declaring it as a char array instead of a pointer. That saves an extra allocation, and we can calculate with the compile-time constant sizeof(data) instead of the attribute "max_len".
* shout: constant plugin declarationsMax Kellermann2008-09-124-7/+7
| | | | | Declare both shout plugins "const", since they will never change, once initialized at compile time.
* shout: static encoder plugin listMax Kellermann2008-09-121-35/+15
| | | | | | Shout encoder plugins are known at compile time. There is no reason to use a complex data structure as "List" to manage them at runtime - just put the pointers into a static array.
* shout: removed typedefs on structs and plugin methodsMax Kellermann2008-09-124-73/+65
| | | | | | | Don't typedef the structs at all. It is easier to forward-declare this way. Don't typedef methods. They are used exactly once, a few lines below.
* shout: added mp3 encoderEric Wollesen2008-09-123-0/+196
| | | | | | | | | | | | | [mk: moved this patch after "Refactor and cleanup of shout Ogg and MP3 audio outputs". The original commit message follows, although it is outdated:] Creation of shout_mp3 audio output plugin. Basically I just copied the existing shout plugin and replaced ogg with lame. Uses lame for mp3 encoding. Next step is to pull common functionality out of each shout plugin and share it between them. Configuration options for "shout_mp3" are the same as for "shout".
* shout: introduce pluggable encoder APIEric Wollesen2008-09-123-55/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've perhaps gone a bit overboard, but here's the current rundown: Both Ogg and MP3 use the "shout" audio output plugin. The shout audio output plugin itself has two new plugins, one for the Ogg encoder, and another for the MP3 (LAME) encoder. Configuration for an Ogg stream doesn't change. For an MP3 stream, configuration is the same as Ogg, with two exceptions. First, you must specify the optional "encoding" parameter, which should be set to "mp3". See mpd.conf(5) for more details. Second, the "quality" parameter is reversed for LAME, such that 1 is high quality for LAME, whereas 10 is high quality for Ogg. I've decomposed the code so that all libshout related operations are done in audioOutput_shout.c, all Ogg specific functions are in audioOutput_shout_ogg.c, and of course then all LAME specific functions are handled in audioOutput_shout_mp3.c. To develop encoder plugins for the shout audio output plugin, I basically just mimicked the plugin system used for audio outputs. This might be overkill, but hopefully if anyone ever wants to support some other sort of stream, like maybe AAC, FLAC, or WMA (hey it could happen), they will hopefully be all set. The Ogg encoder is slightly less optimal under this configuration. It used to send shout data directly out of its ogg_page structures. Now, in the interest of encapsulation, it copies the data from its ogg_page structures into a buffer provided by the shout audio output plugin (see audioOutput_shout_ogg.c, line 77.) I suspect the performance impact is negligible. As for metadata, I'm pretty sure they'll both work. I wrote up a test scaffold that would create a fake tag, and tell the plugin to send it out to the stream every few seconds. It seemed to work fine. Of course, if something does break, I'll be glad to fix it. Lastly, I've renamed lots of things into snake_case, in keeping with normalperson's wishes in that regard. [mk: moved the MP3 patch after this one. Splitted this patch into several parts; the others were already applied before this one. Fixed a bunch GCC warnings and wrong whitespace modifications. Made it compile with mpd-mk by adapting to its prototypes]
* shout: send shout metadataEric Wollesen2008-09-123-5/+19
| | | | | | | | | Support sending metadata to a shout server using shout_metadata_new() and shout_metadata_add(). The Ogg Vorbis encoder does not support this currently. [mk: this patch was separated from Eric's patch "Refactor and cleanup of shout Ogg and MP3 audio outputs", I added a description]
* shout: added struct _ogg_vorbis_dataMax Kellermann2008-09-122-56/+73
| | | | | | Preparing the merge of Eric Wollesen's patch "Refactor and cleanup of shout Ogg and MP3 audio outputs": we declare one of the struct types here, to make the merge smoother.
* shout: added shout_bufferEric Wollesen2008-09-123-46/+102
| | | | | | | | | | | | The Ogg encoder is slightly less optimal under this configuration. It used to send shout data directly out of its ogg_page structures. Now, in the interest of encapsulation, it copies the data from its ogg_page structures into a buffer provided by the shout audio output plugin (see audioOutput_shout_ogg.c, line 77.) I suspect the performance impact is negligible. [mk: this patch and its description was separated from Eric's patch "Refactor and cleanup of shout Ogg and MP3 audio outputs"]
* shout: moved code to audioOutput_shout_ogg.cMax Kellermann2008-09-123-153/+210
| | | | | | | | | | | Begin dividing audioOutput_shout.c: move everything OGG Vorbis related to audioOutput_shout_ogg.c. The header audioOutput_shout.h has to keep its dependency on vorbis/vorbisenc.h, because it needs the vorbis encoder types. For this patch, we have to export several internal functions with generic names to the ABI; these will be removed later when the encoder plugin patches are merged.
* shout: moved declarations to audioOutput_shout.hMax Kellermann2008-09-122-40/+69
| | | | | Prepare the split of the shout plugin into multiple sources: move all important declarations to audioOutput_shout.h.
* shout: removed commented codeMax Kellermann2008-09-121-4/+0
| | | | | | Remove unused code which is in comments. Remove that comment about "stolen code", since the plugin has changed much, and it isn't obvious which parts are derived.
* shout: no CamelCaseMax Kellermann2008-09-121-194/+194
|
* shout: use reqAudioFormat instead of outAudioFormatMax Kellermann2008-09-111-1/+1
| | | | | In the plugin's init() function, outAudioFormat is simply a copy of reqAudioFormat. Use reqAudioFormat instead of outAudioFormat here.
* shout: copy the audio_format, instead of taking a pointerMax Kellermann2008-09-111-13/+12
| | | | | | | Storing pointers to immutable audio_format structs isn't worth it, because the struct itself isn't much larger than the pointer. Since the shout plugin requires the user to configure a fixed audio format, we can simply copy it in myShout_initDriver().
* timer: constant pointersMax Kellermann2008-09-091-1/+1
| | | | | The audio_format argument to timer_new() should be constant, because it is not modified. The same is true for ShoutData.audioFormat.
* alsa: use blocking instead of non-blocking writeEric Wong2008-09-091-1/+6
| | | | | | | | | | | | The way we used non-blocking mode was HORRIBLE. It was non-blocking to ALSA, but we end up blocking in a busy loop that does absolutely NOTHING but retry. We don't check for playback cancellation (like we do in decoders) or anything. This is seriously broken and I can imagine it affects people on fast CPUs more because we do asynchronous output buffering and our ALSA device will always have data ready.
* alsa: snd_pcm_sw_params_set_xfer_align is deprecatedEric Wong2008-09-081-5/+0
| | | | | Lets not use deprecated functions. It's apparently possible to not care about the sw_params stuff at all!
* alsa: only run snd_config_update_free_global once atexitEric Wong2008-09-081-3/+7
| | | | | | | | | This is safer than the patch in http://www.musicpd.org/mantis/view.php?id=1542 with multiple audio outputs enabled. Sadly, I only noticed that patch/problem when I googled for "snd_config_update_free_global"
* alsa: move bitformat reading code out of the wayEric Wong2008-09-081-16/+12
|
* alsa: avoid unnecessary heap usage if we don't set a device nameEric Wong2008-09-081-11/+12
|
* alsa: get rid of the needless canPause flagEric Wong2008-09-081-3/+0
| | | | | We never use it for anything anyways as we release the device entirely on pause.
* alsa: capitalize "ALSA" consistently in messagesEric Wong2008-09-081-8/+8
| | | | That's the name of this project.
* alsa: optimistically try resuming from suspendEric Wong2008-09-081-6/+4
| | | | | | | | | | | | | | Apparently snd_pcm_hw_params_can_resume() can return false even though my hardware does in fact support resuming. So stop carrying that value in the canResume flag and just try to resume when we're in the suspended state; falling back to snd_pcm_prepare only if resuming fails. libao does something similar on resume, too. While we're at it, use the E() macro which will enable us to have better error reporting. [mk: remove the E() macro stuff]
* output: const plugin structuresMax Kellermann2008-09-0810-10/+10
| | | | | Since the plugin struct is never modified, we should store it in constant locations.
* output: renamed typedef AudioOutput to struct audio_outputMax Kellermann2008-09-0710-79/+87
| | | | | Also rename AudioOutputPlugin to struct audio_output_plugin, and use forward declarations to reduce include dependencies.
* output: added output_api.hMax Kellermann2008-09-0710-26/+18
| | | | | Just like decoder_api.h, output_api.h provides the audio output API which is used by the plugins.
* audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann2008-09-075-6/+6
| | | | | Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
* fix -Wcast-qual -Wwrite-strings warningsMax Kellermann2008-09-072-9/+10
| | | | | | | | | The previous patch enabled these warnings. In Eric's branch, they were worked around with a generic deconst_ptr() function. There are several places where we can add "const" to pointers, and in others, libraries want non-const strings. In the latter, convert string literals to "static char[]" variables - this takes the same space, and seems safer than deconsting a string literal.
* tag: fix the shout and oggflac pluginsMax Kellermann2008-08-291-8/+8
| | | | | | During the tag library refactoring, the shout plugin was disabled, and I forgot about adapting it to the new API. Apply the same fixes to the oggflac decoder plugin.
* tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_itemMax Kellermann2008-08-291-2/+2
| | | | | Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
* made "sample_size" static constMax Kellermann2008-08-261-1/+1
| | | | | sample_size is a variable which is computed at compile time. Declare it "static const", so the compiler can optimize it away.
* moved jack configuration to the JackData structMax Kellermann2008-08-261-49/+64
| | | | | | Storing local configuration in global (static) variables is obviously a bad idea. Move all those variables into the JackData struct, including the locks.
* jack: removed unused macrosMax Kellermann2008-08-261-10/+0
|
* jack: don't set audioOutput->data=NULLMax Kellermann2008-08-261-5/+5
| | | | | | | There is only one caller of freeJackData() left: jack_finishDriver(). This function is called by the mpd core, and is called exactly once for every successful jack_initDriver(). We do not need to clear audioOutput->data, since this variable is invalidated anyway.
* jack: initialize JackData in jack_initDriver()Max Kellermann2008-08-261-6/+2
| | | | | | | | Over the lifetime of the jack AudioOutput object, we want a single valid JackData object, so we can persistently store data there (configuration etc.). Allocate JackData in jack_initDriver(). After that, we can safely remove all audioOutput->data==NULL checks (and replace them with assertions).
* jack: added freeJackClient()Max Kellermann2008-08-261-13/+25
| | | | | | | No need to destroy the JackData object when an error occurs, since jack_finishDriver() already frees it. Only deinitialize the jack library, introduce freeJackClient() for that, and move code from freeJackData().