diff options
author | IOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at> | 2018-04-30 21:45:07 +0200 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at> | 2018-04-30 21:45:07 +0200 |
commit | be4b008536f3c28b5f025c8618ac3acb1cd065ad (patch) | |
tree | d58751a8750d39e167289b357c96e6da3e5fe67a /audio.c | |
parent | 0f71f6cd817b5747663b516d620059680789fbc1 (diff) |
New upstream version 18.3
Diffstat (limited to 'audio.c')
-rw-r--r-- | audio.c | 137 |
1 files changed, 71 insertions, 66 deletions
@@ -489,17 +489,17 @@ static int to_oss_sample_type(mus_sample_t snd_format) { switch (snd_format) { - case MUS_BYTE: return(AFMT_S8); break; - case MUS_BSHORT: return(AFMT_S16_BE); break; - case MUS_UBYTE: return(AFMT_U8); break; - case MUS_MULAW: return(AFMT_MU_LAW); break; - case MUS_ALAW: return(AFMT_A_LAW); break; - case MUS_LSHORT: return(AFMT_S16_LE); break; - case MUS_UBSHORT: return(AFMT_U16_BE); break; - case MUS_ULSHORT: return(AFMT_U16_LE); break; + case MUS_BYTE: return(AFMT_S8); + case MUS_BSHORT: return(AFMT_S16_BE); + case MUS_UBYTE: return(AFMT_U8); + case MUS_MULAW: return(AFMT_MU_LAW); + case MUS_ALAW: return(AFMT_A_LAW); + case MUS_LSHORT: return(AFMT_S16_LE); + case MUS_UBSHORT: return(AFMT_U16_BE); + case MUS_ULSHORT: return(AFMT_U16_LE); #ifdef NEW_OSS - case MUS_LINT: return(AFMT_S32_LE); break; - case MUS_BINT: return(AFMT_S32_BE); break; + case MUS_LINT: return(AFMT_S32_LE); + case MUS_BINT: return(AFMT_S32_BE); #endif default: break; } @@ -1433,7 +1433,7 @@ static char *alsa_capture_device_name = NULL; static int alsa_get_max_buffers(void) { - unsigned int max_periods = 0, max_rec_periods = 0; + uint32_t max_periods = 0, max_rec_periods = 0; int dir = 0; if (alsa_hw_params[SND_PCM_STREAM_PLAYBACK]) @@ -1451,7 +1451,7 @@ static int alsa_get_max_buffers(void) static int alsa_get_min_buffers(void) { - unsigned int min_periods = 0, min_rec_periods = 0; + uint32_t min_periods = 0, min_rec_periods = 0; int dir = 0; if (alsa_hw_params[SND_PCM_STREAM_PLAYBACK]) snd_pcm_hw_params_get_periods_min(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &min_periods, &dir); @@ -1900,7 +1900,7 @@ static int alsa_audio_open(int ur_dev, int srate, int chans, mus_sample_t samp_t err = snd_pcm_hw_params_set_periods(handle, hw_params, periods, 0); if (err < 0) { - unsigned int minp, maxp; + uint32_t minp, maxp; int dir; snd_pcm_hw_params_get_periods_min(hw_params, &minp, &dir); snd_pcm_hw_params_get_periods_max(hw_params, &maxp, &dir); @@ -1952,11 +1952,11 @@ total requested buffer size is %d frames, minimum allowed is %d, maximum is %d", } { - unsigned int new_rate; + uint32_t new_rate; new_rate = srate; - /* r is unsigned int so it can't be negative */ + /* r is uint32_t so it can't be negative */ err = snd_pcm_hw_params_set_rate_near(handle, hw_params, &new_rate, 0); - if ((new_rate != (unsigned int)srate) && (!alsa_squelch_warning)) + if ((new_rate != (uint32_t)srate) && (!alsa_squelch_warning)) { mus_print("%s: could not set rate to exactly %d, set to %d instead", alsa_name, srate, new_rate); @@ -2150,11 +2150,11 @@ static int alsa_chans(int ur_dev, int *info) } { - unsigned int max_channels = 0; + uint32_t max_channels = 0; snd_pcm_hw_params_get_channels_max(alsa_hw_params[alsa_stream], &max_channels); if ((alsa_stream == SND_PCM_STREAM_CAPTURE) && - (max_channels > (unsigned int)alsa_max_capture_channels)) + (max_channels > (uint32_t)alsa_max_capture_channels)) { /* limit number of capture channels to a reasonable maximum, if the user specifies a plug pcm as the capture pcm then the returned number of channels @@ -2169,7 +2169,7 @@ static int alsa_chans(int ur_dev, int *info) if (info) { - unsigned int tmp = 0; + uint32_t tmp = 0; info[0] = max_channels; snd_pcm_hw_params_get_channels_min(alsa_hw_params[alsa_stream], &tmp); info[1] = tmp; @@ -2486,11 +2486,11 @@ int mus_audio_open_input(int ur_dev, int srate, int chans, mus_sample_t samp_typ srate, chans, dev_name)); ioctl(audio_fd, AUDIO_GETINFO, &info); - if (info.record.sample_rate != (unsigned int)srate) + if (info.record.sample_rate != (uint32_t)srate) mus_print("%s[%d]: sampling rate: %d != %d\n", __FILE__, __LINE__, info.record.sample_rate, srate); - if (info.record.channels != (unsigned int)chans) + if (info.record.channels != (uint32_t)chans) mus_print("%s[%d]: channels: %d != %d\n", __FILE__, __LINE__, info.record.channels, chans); @@ -3086,7 +3086,6 @@ int mus_audio_read(int line, char *buf, int bytes) #define AUDIO_OK 1 #include <AvailabilityMacros.h> -#define HAVE_AUDIODEVICEDESTROYIOPROCID (defined(MAC_OS_X_VERSION_10_5)) /* #include <CoreServices/CoreServices.h> @@ -3099,23 +3098,23 @@ static const char* osx_error(OSStatus err) if (err == noErr) return("no error"); switch (err) { - case kAudioHardwareNoError: return("no error"); break; - case kAudioHardwareUnspecifiedError: return("unspecified audio hardware error"); break; - case kAudioHardwareNotRunningError: return("audio hardware not running"); break; - case kAudioHardwareUnknownPropertyError: return("unknown property"); break; - case kAudioHardwareBadPropertySizeError: return("bad property"); break; - case kAudioHardwareBadDeviceError: return("bad device"); break; - case kAudioHardwareBadStreamError: return("bad stream"); break; - case kAudioHardwareIllegalOperationError: return("illegal operation"); break; - case kAudioDeviceUnsupportedFormatError: return("unsupported sample type"); break; - case kAudioDevicePermissionsError: return("device permissions error"); break; + case kAudioHardwareNoError: return("no error"); + case kAudioHardwareUnspecifiedError: return("unspecified audio hardware error"); + case kAudioHardwareNotRunningError: return("audio hardware not running"); + case kAudioHardwareUnknownPropertyError: return("unknown property"); + case kAudioHardwareBadPropertySizeError: return("bad property"); + case kAudioHardwareBadDeviceError: return("bad device"); + case kAudioHardwareBadStreamError: return("bad stream"); + case kAudioHardwareIllegalOperationError: return("illegal operation"); + case kAudioDeviceUnsupportedFormatError: return("unsupported sample type"); + case kAudioDevicePermissionsError: return("device permissions error"); } return("unknown error"); } #define MAX_BUFS 4 static char **bufs = NULL; -static unsigned int in_buf = 0, out_buf = 0; +static uint32_t in_buf = 0, out_buf = 0; static OSStatus writer(AudioDeviceID inDevice, const AudioTimeStamp *inNow, @@ -3155,7 +3154,13 @@ static OSStatus reader(AudioDeviceID inDevice, static AudioDeviceID device = kAudioDeviceUnknown; static bool writing = false, open_for_input = false; -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#ifdef MAC_OS_X_VERSION_10_5 + #define HAVE_OSX_10_5 1 +#else + #define HAVE_OSX_10_5 0 +#endif + +#if HAVE_OSX_10_5 static AudioDeviceIOProcID read_procId, write_procId; #endif @@ -3169,7 +3174,7 @@ int mus_audio_close(int line) in_buf = 0; err = AudioDeviceStop(device, (AudioDeviceIOProc)reader); if (err == noErr) -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#if HAVE_OSX_10_5 err = AudioDeviceDestroyIOProcID(device, read_procId); #else err = AudioDeviceRemoveIOProc(device, (AudioDeviceIOProc)reader); @@ -3180,7 +3185,7 @@ int mus_audio_close(int line) if ((in_buf > 0) && (!writing)) { /* short enough sound that we never got started? */ -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#if HAVE_OSX_10_5 err = AudioDeviceCreateIOProcID(device, (AudioDeviceIOProc)writer, NULL, &write_procId); #else err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)writer, NULL); @@ -3217,7 +3222,7 @@ int mus_audio_close(int line) in_buf = 0; err = AudioDeviceStop(device, (AudioDeviceIOProc)writer); if (err == noErr) -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#if HAVE_OSX_10_5 err = AudioDeviceDestroyIOProcID(device, write_procId); #else err = AudioDeviceRemoveIOProc(device, (AudioDeviceIOProc)writer); @@ -3236,8 +3241,8 @@ static audio_convert_t conversion_choice = CONVERT_NOT; static float conversion_multiplier = 1.0; static int dac_out_chans, dac_out_srate; static int incoming_out_chans = 1, incoming_out_srate = 44100; -static unsigned int fill_point = 0; -static unsigned int bufsize = 0, current_bufsize = 0; +static uint32_t fill_point = 0; +static uint32_t bufsize = 0, current_bufsize = 0; static bool match_dac_to_sound = true; @@ -3262,7 +3267,7 @@ int mus_audio_open_output(int dev, int srate, int chans, mus_sample_t samp_type, device = 0; sizeof_device = sizeof(AudioDeviceID); - sizeof_bufsize = sizeof(unsigned int); + sizeof_bufsize = sizeof(uint32_t); /* err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &sizeof_device, (void *)(&device)); */ { @@ -3568,16 +3573,16 @@ static void convert_incoming(char *to_buf, int fill_point, int lim, char *buf) int mus_audio_write(int line, char *buf, int bytes) { OSStatus err = noErr; - unsigned int lim, out_bytes; + uint32_t lim, out_bytes; UInt32 sizeof_running; UInt32 running; char *to_buf; to_buf = bufs[in_buf]; - out_bytes = (unsigned int)(bytes * conversion_multiplier); + out_bytes = (uint32_t)(bytes * conversion_multiplier); if ((fill_point + out_bytes) > bufsize) out_bytes = bufsize - fill_point; - lim = (unsigned int)(out_bytes / conversion_multiplier); + lim = (uint32_t)(out_bytes / conversion_multiplier); if (!writing) { @@ -3590,7 +3595,7 @@ int mus_audio_write(int line, char *buf, int bytes) if (in_buf == MAX_BUFS) { in_buf = 0; -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#if HAVE_OSX_10_5 err = AudioDeviceCreateIOProcID(device, (AudioDeviceIOProc)writer, NULL, &write_procId); #else err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)writer, NULL); @@ -3609,7 +3614,7 @@ int mus_audio_write(int line, char *buf, int bytes) } if ((fill_point == 0) && (in_buf == out_buf)) { - unsigned int bp; + uint32_t bp; bp = out_buf; sizeof_running = sizeof(UInt32); while (bp == out_buf) @@ -3645,7 +3650,7 @@ int mus_audio_open_input(int dev, int srate, int chans, mus_sample_t samp_type, UInt32 sizeof_bufsize; sizeof_device = sizeof(AudioDeviceID); - sizeof_bufsize = sizeof(unsigned int); + sizeof_bufsize = sizeof(uint32_t); device = 0; /* err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &sizeof_device, (void *)(&device)); */ @@ -3693,7 +3698,7 @@ int mus_audio_open_input(int dev, int srate, int chans, mus_sample_t samp_type, incoming_out_srate = srate; incoming_out_chans = chans; -#if HAVE_AUDIODEVICEDESTROYIOPROCID +#if HAVE_OSX_10_5 err = AudioDeviceCreateIOProcID(device, (AudioDeviceIOProc)reader, NULL, &read_procId); #else err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)reader, NULL); @@ -3718,7 +3723,7 @@ int mus_audio_read(int line, char *buf, int bytes) if (in_buf == out_buf) { - unsigned int bp; + uint32_t bp; bp = out_buf; sizeof_running = sizeof(UInt32); while (bp == out_buf) @@ -4821,19 +4826,19 @@ static mus_sample_t bsd_format_to_sndlib(int encoding) { switch (encoding) { - case AUDIO_ENCODING_ULAW: return(MUS_MULAW); break; - case AUDIO_ENCODING_ALAW: return(MUS_ALAW); break; - case AUDIO_ENCODING_LINEAR: return(MUS_BSHORT); break; /* "sun compatible" so probably big-endian? */ + case AUDIO_ENCODING_ULAW: return(MUS_MULAW); + case AUDIO_ENCODING_ALAW: return(MUS_ALAW); + case AUDIO_ENCODING_LINEAR: return(MUS_BSHORT); /* "sun compatible" so probably big-endian? */ case AUDIO_ENCODING_SLINEAR: - case AUDIO_ENCODING_LINEAR8: return(MUS_BYTE); break; - case AUDIO_ENCODING_SLINEAR_LE: return(MUS_LSHORT); break; - case AUDIO_ENCODING_SLINEAR_BE: return(MUS_BSHORT); break; - case AUDIO_ENCODING_ULINEAR_LE: return(MUS_ULSHORT); break; - case AUDIO_ENCODING_ULINEAR_BE: return(MUS_UBSHORT); break; - case AUDIO_ENCODING_ULINEAR: return(MUS_UBYTE); break; + case AUDIO_ENCODING_LINEAR8: return(MUS_BYTE); + case AUDIO_ENCODING_SLINEAR_LE: return(MUS_LSHORT); + case AUDIO_ENCODING_SLINEAR_BE: return(MUS_BSHORT); + case AUDIO_ENCODING_ULINEAR_LE: return(MUS_ULSHORT); + case AUDIO_ENCODING_ULINEAR_BE: return(MUS_UBSHORT); + case AUDIO_ENCODING_ULINEAR: return(MUS_UBYTE); case AUDIO_ENCODING_NONE: case AUDIO_ENCODING_ADPCM: - default: return(MUS_UNKNOWN_SAMPLE); break; + default: return(MUS_UNKNOWN_SAMPLE); } return(MUS_UNKNOWN_SAMPLE); } @@ -4843,14 +4848,14 @@ static int sndlib_format_to_bsd(mus_sample_t encoding) { switch (encoding) { - case MUS_MULAW: return(AUDIO_ENCODING_ULAW); break; - case MUS_ALAW: return(AUDIO_ENCODING_ALAW); break; - case MUS_BYTE: return(AUDIO_ENCODING_SLINEAR); break; - case MUS_LSHORT: return(AUDIO_ENCODING_SLINEAR_LE); break; - case MUS_BSHORT: return(AUDIO_ENCODING_SLINEAR_BE); break; - case MUS_ULSHORT: return(AUDIO_ENCODING_ULINEAR_LE); break; - case MUS_UBSHORT: return(AUDIO_ENCODING_ULINEAR_BE); break; - case MUS_UBYTE: return(AUDIO_ENCODING_ULINEAR); break; + case MUS_MULAW: return(AUDIO_ENCODING_ULAW); + case MUS_ALAW: return(AUDIO_ENCODING_ALAW); + case MUS_BYTE: return(AUDIO_ENCODING_SLINEAR); + case MUS_LSHORT: return(AUDIO_ENCODING_SLINEAR_LE); + case MUS_BSHORT: return(AUDIO_ENCODING_SLINEAR_BE); + case MUS_ULSHORT: return(AUDIO_ENCODING_ULINEAR_LE); + case MUS_UBSHORT: return(AUDIO_ENCODING_ULINEAR_BE); + case MUS_UBYTE: return(AUDIO_ENCODING_ULINEAR); default: break; } return(AUDIO_ENCODING_NONE); |