summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-09-04 18:35:21 +0200
committerMax Kellermann <max@musicpd.org>2020-09-04 18:35:21 +0200
commit67c7116f058666fbcc050d6d879778f41665b447 (patch)
tree5660ae62bb3d751b0a1b928b3a1c144b28aa9f4a /src/output
parent9aa432c07838256536c39b00d14c04462862b4fc (diff)
parentdb8b419b8c3aa738efb3fa7b5de7b2894ced6cde (diff)
Merge branch 'v0.21.x' into master
Diffstat (limited to 'src/output')
-rw-r--r--src/output/plugins/OSXOutputPlugin.cxx14
-rw-r--r--src/output/plugins/sles/SlesOutputPlugin.cxx37
2 files changed, 43 insertions, 8 deletions
diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx
index f4c7f25a0..2d489c474 100644
--- a/src/output/plugins/OSXOutputPlugin.cxx
+++ b/src/output/plugins/OSXOutputPlugin.cxx
@@ -477,7 +477,7 @@ osx_output_set_buffer_size(AudioUnit au, AudioStreamBasicDescription desc)
}
static void
-osx_output_hog_device(AudioDeviceID dev_id, bool hog)
+osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
{
static constexpr AudioObjectPropertyAddress aopa = {
kAudioDevicePropertyHogMode,
@@ -485,8 +485,16 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog)
kAudioObjectPropertyElementMaster
};
- pid_t hog_pid = AudioObjectGetPropertyDataT<pid_t>(dev_id,
- aopa);
+ pid_t hog_pid;
+
+ try {
+ hog_pid = AudioObjectGetPropertyDataT<pid_t>(dev_id, aopa);
+ } catch (...) {
+ Log(LogLevel::DEBUG, std::current_exception(),
+ "Failed to query HogMode");
+ return;
+ }
+
if (hog) {
if (hog_pid != -1) {
FormatDebug(osx_output_domain,
diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx
index 3b345e2e0..5a4c22a53 100644
--- a/src/output/plugins/sles/SlesOutputPlugin.cxx
+++ b/src/output/plugins/sles/SlesOutputPlugin.cxx
@@ -173,12 +173,12 @@ SlesOutput::Open(AudioFormat &audio_format)
if (audio_format.channels > 2)
audio_format.channels = 1;
- SLDataFormat_PCM format_pcm;
+ SLAndroidDataFormat_PCM_EX format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM;
format_pcm.numChannels = audio_format.channels;
/* from the Android NDK docs: "Note that the field samplesPerSec is
actually in units of milliHz, despite the misleading name." */
- format_pcm.samplesPerSec = audio_format.sample_rate * 1000u;
+ format_pcm.sampleRate = audio_format.sample_rate * 1000u;
format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
format_pcm.channelMask = audio_format.channels == 1
@@ -187,6 +187,36 @@ SlesOutput::Open(AudioFormat &audio_format)
format_pcm.endianness = IsLittleEndian()
? SL_BYTEORDER_LITTLEENDIAN
: SL_BYTEORDER_BIGENDIAN;
+ format_pcm.representation = SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT;
+
+ switch (audio_format.format) {
+ /* note: Android doesn't support
+ SL_PCMSAMPLEFORMAT_FIXED_24 and
+ SL_PCMSAMPLEFORMAT_FIXED_32, so let's not bother
+ implement it here; SL_PCMSAMPLEFORMAT_FIXED_8
+ appears to be unsigned, so not usable for us (and
+ converting S8 to U8 is not worth the trouble) */
+
+ case SampleFormat::S16:
+ /* bitsPerSample and containerSize already set for 16
+ bit */
+ break;
+
+ case SampleFormat::FLOAT:
+ /* Android has an OpenSLES extension for floating
+ point samples:
+ https://developer.android.com/ndk/guides/audio/opensl/android-extensions */
+ format_pcm.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
+ format_pcm.bitsPerSample = format_pcm.containerSize =
+ SL_PCMSAMPLEFORMAT_FIXED_32;
+ format_pcm.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
+ break;
+
+ default:
+ /* fall back to 16 bit */
+ audio_format.format = SampleFormat::S16;
+ break;
+ }
SLDataSource audioSrc = { &loc_bufq, &format_pcm };
@@ -291,9 +321,6 @@ SlesOutput::Open(AudioFormat &audio_format)
n_queued = 0;
next = 0;
filled = 0;
-
- // TODO: support other sample formats
- audio_format.format = SampleFormat::S16;
}
void