fix build on linux

This commit is contained in:
Andrew Kelley 2015-08-01 22:40:55 -07:00
parent f77663399f
commit c52e76928f
6 changed files with 227 additions and 31 deletions

View file

@ -244,7 +244,6 @@ view `coverage/index.html` in a browser.
0. implement CoreAudio (OSX) backend, get examples working
0. Add some builtin channel layouts from
https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/CoreAudioDataTypesRef/#//apple_ref/doc/constant_group/Audio_Channel_Layout_Tags
0. Add more PulseAudio channel ids
0. Make sure PulseAudio can handle refresh devices crashing before
block_until_have_devices
0. implement WASAPI (Windows) backend, get examples working

View file

@ -156,10 +156,11 @@ static int to_alsa_chmap_pos(SoundIoChannelId channel_id) {
case SoundIoChannelIdBottomCenter: return SND_CHMAP_BC;
case SoundIoChannelIdBottomLeftCenter: return SND_CHMAP_BLC;
case SoundIoChannelIdBottomRightCenter: return SND_CHMAP_BRC;
case SoundIoChannelIdInvalid: return SND_CHMAP_UNKNOWN;
}
default:
return SND_CHMAP_UNKNOWN;
}
}
static void get_channel_layout(SoundIoChannelLayout *dest, snd_pcm_chmap_t *chmap) {
int channel_count = min((unsigned int)SOUNDIO_MAX_CHANNELS, chmap->channels);
@ -717,6 +718,7 @@ static void shutdown_backend(SoundIoPrivate *si, int err) {
static void device_thread_run(void *arg) {
SoundIoPrivate *si = (SoundIoPrivate *)arg;
SoundIo *soundio = &si->pub;
SoundIoAlsa *sia = &si->backend_data.alsa;
// Some systems cannot read integer variables if they are not
@ -808,8 +810,12 @@ static void device_thread_run(void *arg) {
err = refresh_devices(si);
if (err)
shutdown_backend(si, err);
if (!sia->have_devices_flag.exchange(true))
soundio_os_cond_signal(sica->have_devices_cond, nullptr);
if (!sia->have_devices_flag.exchange(true)) {
soundio_os_mutex_lock(sia->mutex);
soundio_os_cond_signal(sia->cond, sia->mutex);
soundio->on_events_signal(soundio);
soundio_os_mutex_unlock(sia->mutex);
}
if (err)
return;
}

View file

@ -470,6 +470,11 @@ static const char *channel_names[][channel_name_alias_count] = {
nullptr,
nullptr,
},
[SoundIoChannelIdLfe2] = {
"LFE 2",
nullptr,
nullptr,
},
[SoundIoChannelIdBottomCenter] = {
"Bottom Center",
nullptr,
@ -485,6 +490,171 @@ static const char *channel_names[][channel_name_alias_count] = {
nullptr,
nullptr,
},
[SoundIoChannelIdMsMid] = {
"Mid/Side Mid",
nullptr,
nullptr,
},
[SoundIoChannelIdMsSide] = {
"Mid/Side Side",
nullptr,
nullptr,
},
[SoundIoChannelIdAmbisonicW] = {
"Ambisonic W",
nullptr,
nullptr,
},
[SoundIoChannelIdAmbisonicX] = {
"Ambisonic X",
nullptr,
nullptr,
},
[SoundIoChannelIdAmbisonicY] = {
"Ambisonic Y",
nullptr,
nullptr,
},
[SoundIoChannelIdAmbisonicZ] = {
"Ambisonic Z",
nullptr,
nullptr,
},
[SoundIoChannelIdXyX] = {
"X-Y X",
nullptr,
nullptr,
},
[SoundIoChannelIdXyY] = {
"X-Y Y",
nullptr,
nullptr,
},
[SoundIoChannelIdHeadphonesLeft] = {
"Headphones Left",
nullptr,
nullptr,
},
[SoundIoChannelIdHeadphonesRight] = {
"Headphones Right",
nullptr,
nullptr,
},
[SoundIoChannelIdClickTrack] = {
"Click Track",
nullptr,
nullptr,
},
[SoundIoChannelIdForeignLanguage] = {
"Foreign Language",
nullptr,
nullptr,
},
[SoundIoChannelIdHearingImpaired] = {
"Hearing Impaired",
nullptr,
nullptr,
},
[SoundIoChannelIdNarration] = {
"Narration",
nullptr,
nullptr,
},
[SoundIoChannelIdHaptic] = {
"Haptic",
nullptr,
nullptr,
},
[SoundIoChannelIdDialogCentricMix] = {
"Dialog Centric Mix",
nullptr,
nullptr,
},
[SoundIoChannelIdAux] = {
"Aux",
nullptr,
nullptr,
},
[SoundIoChannelIdAux0] = {
"Aux 0",
nullptr,
nullptr,
},
[SoundIoChannelIdAux1] = {
"Aux 1",
nullptr,
nullptr,
},
[SoundIoChannelIdAux2] = {
"Aux 2",
nullptr,
nullptr,
},
[SoundIoChannelIdAux3] = {
"Aux 3",
nullptr,
nullptr,
},
[SoundIoChannelIdAux4] = {
"Aux 4",
nullptr,
nullptr,
},
[SoundIoChannelIdAux5] = {
"Aux 5",
nullptr,
nullptr,
},
[SoundIoChannelIdAux6] = {
"Aux 6",
nullptr,
nullptr,
},
[SoundIoChannelIdAux7] = {
"Aux 7",
nullptr,
nullptr,
},
[SoundIoChannelIdAux8] = {
"Aux 8",
nullptr,
nullptr,
},
[SoundIoChannelIdAux9] = {
"Aux 9",
nullptr,
nullptr,
},
[SoundIoChannelIdAux10] = {
"Aux 10",
nullptr,
nullptr,
},
[SoundIoChannelIdAux11] = {
"Aux 11",
nullptr,
nullptr,
},
[SoundIoChannelIdAux12] = {
"Aux 12",
nullptr,
nullptr,
},
[SoundIoChannelIdAux13] = {
"Aux 13",
nullptr,
nullptr,
},
[SoundIoChannelIdAux14] = {
"Aux 14",
nullptr,
nullptr,
},
[SoundIoChannelIdAux15] = {
"Aux 15",
nullptr,
nullptr,
},
};
const char *soundio_get_channel_name(enum SoundIoChannelId id) {

View file

@ -151,17 +151,17 @@ static SoundIoChannelId from_channel_descr(const AudioChannelDescription *descr)
case kAudioChannelLabel_Right: return SoundIoChannelIdFrontRight;
case kAudioChannelLabel_Center: return SoundIoChannelIdFrontCenter;
case kAudioChannelLabel_LFEScreen: return SoundIoChannelIdLfe;
case kAudioChannelLabel_LeftSurround: return SoundIoChannelIdSideLeft;
case kAudioChannelLabel_RightSurround: return SoundIoChannelIdSideRight;
case kAudioChannelLabel_LeftCenter: return SoundIoChannelIdSideLeft;
case kAudioChannelLabel_RightCenter: return SoundIoChannelIdSideRight;
case kAudioChannelLabel_LeftSurround: return SoundIoChannelIdBackLeft;
case kAudioChannelLabel_RightSurround: return SoundIoChannelIdBackRight;
case kAudioChannelLabel_LeftCenter: return SoundIoChannelIdFrontLeftCenter;
case kAudioChannelLabel_RightCenter: return SoundIoChannelIdFrontRightCenter;
case kAudioChannelLabel_CenterSurround: return SoundIoChannelIdBackCenter;
case kAudioChannelLabel_LeftSurroundDirect: return SoundIoChannelIdSideLeft;
case kAudioChannelLabel_RightSurroundDirect: return SoundIoChannelIdSideRight;
case kAudioChannelLabel_TopCenterSurround: return SoundIoChannelIdTopCenter;
case kAudioChannelLabel_VerticalHeightLeft: return SoundIoChannelIdTopSideLeft;
case kAudioChannelLabel_VerticalHeightCenter: return SoundIoChannelIdTopCenter;
case kAudioChannelLabel_VerticalHeightRight: return SoundIoChannelIdTopSideRight;
case kAudioChannelLabel_VerticalHeightLeft: return SoundIoChannelIdTopFrontLeft;
case kAudioChannelLabel_VerticalHeightCenter: return SoundIoChannelIdTopFrontCenter;
case kAudioChannelLabel_VerticalHeightRight: return SoundIoChannelIdTopFrontRight;
case kAudioChannelLabel_TopBackLeft: return SoundIoChannelIdTopBackLeft;
case kAudioChannelLabel_TopBackCenter: return SoundIoChannelIdTopBackCenter;
case kAudioChannelLabel_TopBackRight: return SoundIoChannelIdTopBackRight;
@ -629,6 +629,7 @@ static void wakeup_ca(struct SoundIoPrivate *si) {
static void device_thread_run(void *arg) {
SoundIoPrivate *si = (SoundIoPrivate *)arg;
SoundIo *soundio = &si->pub;
SoundIoCoreAudio *sica = &si->backend_data.coreaudio;
int err;
@ -643,8 +644,10 @@ static void device_thread_run(void *arg) {
err = refresh_devices(si);
if (err)
shutdown_backend(si, err);
if (!sica->have_devices_flag.exchange(true))
if (!sica->have_devices_flag.exchange(true)) {
soundio_os_cond_signal(sica->have_devices_cond, nullptr);
soundio->on_events_signal(soundio);
}
if (err)
return;
soundio_os_cond_signal(sica->cond, nullptr);

View file

@ -128,6 +128,23 @@ static SoundIoChannelId from_pulseaudio_channel_pos(pa_channel_position_t pos) {
case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return SoundIoChannelIdTopBackRight;
case PA_CHANNEL_POSITION_TOP_REAR_CENTER: return SoundIoChannelIdTopBackCenter;
case PA_CHANNEL_POSITION_AUX0: return SoundIoChannelIdAux0;
case PA_CHANNEL_POSITION_AUX1: return SoundIoChannelIdAux1;
case PA_CHANNEL_POSITION_AUX2: return SoundIoChannelIdAux2;
case PA_CHANNEL_POSITION_AUX3: return SoundIoChannelIdAux3;
case PA_CHANNEL_POSITION_AUX4: return SoundIoChannelIdAux4;
case PA_CHANNEL_POSITION_AUX5: return SoundIoChannelIdAux5;
case PA_CHANNEL_POSITION_AUX6: return SoundIoChannelIdAux6;
case PA_CHANNEL_POSITION_AUX7: return SoundIoChannelIdAux7;
case PA_CHANNEL_POSITION_AUX8: return SoundIoChannelIdAux8;
case PA_CHANNEL_POSITION_AUX9: return SoundIoChannelIdAux9;
case PA_CHANNEL_POSITION_AUX10: return SoundIoChannelIdAux10;
case PA_CHANNEL_POSITION_AUX11: return SoundIoChannelIdAux11;
case PA_CHANNEL_POSITION_AUX12: return SoundIoChannelIdAux12;
case PA_CHANNEL_POSITION_AUX13: return SoundIoChannelIdAux13;
case PA_CHANNEL_POSITION_AUX14: return SoundIoChannelIdAux14;
case PA_CHANNEL_POSITION_AUX15: return SoundIoChannelIdAux15;
default: return SoundIoChannelIdInvalid;
}
}
@ -562,26 +579,26 @@ static pa_channel_position_t to_pulseaudio_channel_pos(SoundIoChannelId channel_
case SoundIoChannelIdTopBackCenter: return PA_CHANNEL_POSITION_TOP_REAR_CENTER;
case SoundIoChannelIdTopBackRight: return PA_CHANNEL_POSITION_TOP_REAR_RIGHT;
case SoundIoChannelIdInvalid:
case SoundIoChannelIdBackLeftCenter:
case SoundIoChannelIdBackRightCenter:
case SoundIoChannelIdFrontLeftWide:
case SoundIoChannelIdFrontRightWide:
case SoundIoChannelIdFrontLeftHigh:
case SoundIoChannelIdFrontCenterHigh:
case SoundIoChannelIdFrontRightHigh:
case SoundIoChannelIdTopFrontLeftCenter:
case SoundIoChannelIdTopFrontRightCenter:
case SoundIoChannelIdTopSideLeft:
case SoundIoChannelIdTopSideRight:
case SoundIoChannelIdLeftLfe:
case SoundIoChannelIdRightLfe:
case SoundIoChannelIdBottomCenter:
case SoundIoChannelIdBottomLeftCenter:
case SoundIoChannelIdBottomRightCenter:
case SoundIoChannelIdAux0: return PA_CHANNEL_POSITION_AUX0;
case SoundIoChannelIdAux1: return PA_CHANNEL_POSITION_AUX1;
case SoundIoChannelIdAux2: return PA_CHANNEL_POSITION_AUX2;
case SoundIoChannelIdAux3: return PA_CHANNEL_POSITION_AUX3;
case SoundIoChannelIdAux4: return PA_CHANNEL_POSITION_AUX4;
case SoundIoChannelIdAux5: return PA_CHANNEL_POSITION_AUX5;
case SoundIoChannelIdAux6: return PA_CHANNEL_POSITION_AUX6;
case SoundIoChannelIdAux7: return PA_CHANNEL_POSITION_AUX7;
case SoundIoChannelIdAux8: return PA_CHANNEL_POSITION_AUX8;
case SoundIoChannelIdAux9: return PA_CHANNEL_POSITION_AUX9;
case SoundIoChannelIdAux10: return PA_CHANNEL_POSITION_AUX10;
case SoundIoChannelIdAux11: return PA_CHANNEL_POSITION_AUX11;
case SoundIoChannelIdAux12: return PA_CHANNEL_POSITION_AUX12;
case SoundIoChannelIdAux13: return PA_CHANNEL_POSITION_AUX13;
case SoundIoChannelIdAux14: return PA_CHANNEL_POSITION_AUX14;
case SoundIoChannelIdAux15: return PA_CHANNEL_POSITION_AUX15;
default:
return PA_CHANNEL_POSITION_INVALID;
}
return PA_CHANNEL_POSITION_INVALID;
}
static pa_channel_map to_pulseaudio_channel_map(const SoundIoChannelLayout *channel_layout) {

View file

@ -30,6 +30,7 @@ static void test_create_outstream(void) {
struct SoundIo *soundio = soundio_create();
assert(soundio);
ok_or_panic(soundio_connect(soundio));
soundio_flush_events(soundio);
int default_out_device_index = soundio_default_output_device_index(soundio);
assert(default_out_device_index >= 0);
struct SoundIoDevice *device = soundio_get_output_device(soundio, default_out_device_index);