Add untested preliminary audio backend for Solaris
This commit is contained in:
parent
98b2b4c64d
commit
31d16e714f
1 changed files with 88 additions and 0 deletions
88
src/Backends/Audio/SoftwareMixer/Solaris.cpp
Normal file
88
src/Backends/Audio/SoftwareMixer/Solaris.cpp
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// Released under the MIT licence.
|
||||||
|
// See LICENCE.txt for details.
|
||||||
|
|
||||||
|
#include "Backend.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/audio.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
int sndfp;
|
||||||
|
void (*parent_callback)(long *stream, size_t frames_total);
|
||||||
|
|
||||||
|
static void* soundcheckthread(void*) {
|
||||||
|
unsigned long for_as_long_as_it_seems_we_should = 0;
|
||||||
|
uint16_t out[0x400 * 2];
|
||||||
|
while(1) {
|
||||||
|
bool ready = false;
|
||||||
|
audio_prinfo_t audioInfo;
|
||||||
|
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||||
|
int oldeof = audioInfo.eof;
|
||||||
|
|
||||||
|
usleep(for_as_long_as_it_seems_we_should);
|
||||||
|
|
||||||
|
while(ready == false) {
|
||||||
|
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||||
|
if(audioInfo.eof > oldeof) {
|
||||||
|
ready = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long mix[0x400 * 2];
|
||||||
|
memset(mix, 0, 0x400 * 2);
|
||||||
|
parent_callback(mix, 0x400 * 2);
|
||||||
|
|
||||||
|
write(sndfp, mix, 0x400 * 2);
|
||||||
|
|
||||||
|
for_as_long_as_it_seems_we_should = (0x400 / 48000) * 1000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t frames_total)) {
|
||||||
|
sndfp = open("/dev/audio", 0, O_WRONLY);
|
||||||
|
|
||||||
|
audio_prinfo_t audioInfo;
|
||||||
|
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||||
|
audioInfo.sample_rate = 48000;
|
||||||
|
audioInfo.channels = 2;
|
||||||
|
audioInfo.precision = 16;
|
||||||
|
audioInfo.encoding = AUDIO_ENCODING_LINEAR;
|
||||||
|
audioInfo.port = AUDIO_SPEAKER;
|
||||||
|
ioctl(sndfp, AUDIO_SETINFO, &audioInfo);
|
||||||
|
|
||||||
|
pthread_t thread;
|
||||||
|
pthread_attr_t thread_attr;
|
||||||
|
pthread_attr_init(&thread_attr);
|
||||||
|
|
||||||
|
pthread_create(&thread, &thread_attr, soundcheckthread, (void*)NULL);
|
||||||
|
|
||||||
|
return 48000; // return the sampling rate
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareMixerBackend_Deinit(void) {
|
||||||
|
close(sndfp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SoftwareMixerBackend_Start(void) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareMixerBackend_LockMixerMutex(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareMixerBackend_UnlockMixerMutex(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareMixerBackend_LockOrganyaMutex(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareMixerBackend_UnlockOrganyaMutex(void) {
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue