input/cdio_paranoia: add setting "default_byte_order"
Allows big-endian users to configure the fallback byte order to little-endian. Without this setting, MPD assumes native byte order if the CD drive can't decide.
This commit is contained in:
		
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							@@ -2,6 +2,7 @@ ver 0.18.2 (2013/??/??)
 | 
			
		||||
* protocol:
 | 
			
		||||
  - "close" flushes the output buffer
 | 
			
		||||
* input:
 | 
			
		||||
  - cdio_paranoia: add setting "default_byte_order"
 | 
			
		||||
  - curl: fix bug with redirected streams
 | 
			
		||||
* playlist:
 | 
			
		||||
  - pls: fix reversed song order
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								doc/user.xml
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								doc/user.xml
									
									
									
									
									
								
							@@ -814,6 +814,30 @@ systemctl start mpd.socket</programlisting>
 | 
			
		||||
          simplest form <filename>cdda://</filename> plays the whole
 | 
			
		||||
          disc in the default drive.
 | 
			
		||||
        </para>
 | 
			
		||||
 | 
			
		||||
        <informaltable>
 | 
			
		||||
          <tgroup cols="2">
 | 
			
		||||
            <thead>
 | 
			
		||||
              <row>
 | 
			
		||||
                <entry>Setting</entry>
 | 
			
		||||
                <entry>Description</entry>
 | 
			
		||||
              </row>
 | 
			
		||||
            </thead>
 | 
			
		||||
            <tbody>
 | 
			
		||||
              <row>
 | 
			
		||||
                <entry>
 | 
			
		||||
                  <varname>default_bute_order</varname>
 | 
			
		||||
                <parameter>little_endian|big_endian</parameter>
 | 
			
		||||
                </entry>
 | 
			
		||||
                <entry>
 | 
			
		||||
                  If the CD drive does not specify a byte order, MPD
 | 
			
		||||
                  assumes it is the CPU's native byte order.  This
 | 
			
		||||
                  setting allows overriding this.
 | 
			
		||||
                </entry>
 | 
			
		||||
              </row>
 | 
			
		||||
            </tbody>
 | 
			
		||||
          </tgroup>
 | 
			
		||||
        </informaltable>
 | 
			
		||||
      </section>
 | 
			
		||||
 | 
			
		||||
      <section>
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,8 @@
 | 
			
		||||
#include "system/ByteOrder.hxx"
 | 
			
		||||
#include "fs/AllocatedPath.hxx"
 | 
			
		||||
#include "Log.hxx"
 | 
			
		||||
#include "ConfigData.hxx"
 | 
			
		||||
#include "ConfigError.hxx"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
@@ -77,6 +79,28 @@ struct CdioParanoiaInputStream {
 | 
			
		||||
 | 
			
		||||
static constexpr Domain cdio_domain("cdio");
 | 
			
		||||
 | 
			
		||||
static bool default_reverse_endian;
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
input_cdio_init(const config_param ¶m, Error &error)
 | 
			
		||||
{
 | 
			
		||||
	const char *value = param.GetBlockValue("default_byte_order");
 | 
			
		||||
	if (value != nullptr) {
 | 
			
		||||
		if (strcmp(value, "little_endian") == 0)
 | 
			
		||||
			default_reverse_endian = IsBigEndian();
 | 
			
		||||
		else if (strcmp(value, "big_endian") == 0)
 | 
			
		||||
			default_reverse_endian = IsLittleEndian();
 | 
			
		||||
		else {
 | 
			
		||||
			error.Format(config_domain, 0,
 | 
			
		||||
				     "Unrecognized 'default_byte_order' setting: %s",
 | 
			
		||||
				     value);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
input_cdio_close(InputStream *is)
 | 
			
		||||
{
 | 
			
		||||
@@ -196,7 +220,7 @@ input_cdio_open(const char *uri,
 | 
			
		||||
	switch (data_bigendianp(i->drv)) {
 | 
			
		||||
	case -1:
 | 
			
		||||
		LogDebug(cdio_domain, "drive returns unknown audio data");
 | 
			
		||||
		reverse_endian = false;
 | 
			
		||||
		reverse_endian = default_reverse_endian;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	case 0:
 | 
			
		||||
@@ -363,7 +387,7 @@ input_cdio_eof(InputStream *is)
 | 
			
		||||
 | 
			
		||||
const InputPlugin input_plugin_cdio_paranoia = {
 | 
			
		||||
	"cdio_paranoia",
 | 
			
		||||
	nullptr,
 | 
			
		||||
	input_cdio_init,
 | 
			
		||||
	nullptr,
 | 
			
		||||
	input_cdio_open,
 | 
			
		||||
	input_cdio_close,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user