mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-08-21 16:31:33 +00:00
awacs: pausing sound output DMA channel.
This commit is contained in:
@@ -34,8 +34,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
AwacsBase::AwacsBase(std::string name)
|
AwacsBase::AwacsBase(std::string name) {
|
||||||
{
|
|
||||||
supports_types(HWCompType::SND_CODEC);
|
supports_types(HWCompType::SND_CODEC);
|
||||||
|
|
||||||
this->name = name;
|
this->name = name;
|
||||||
@@ -46,8 +45,7 @@ AwacsBase::AwacsBase(std::string name)
|
|||||||
this->out_stream_ready = false;
|
this->out_stream_ready = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwacsBase::set_sample_rate(int sr_id)
|
void AwacsBase::set_sample_rate(int sr_id) {
|
||||||
{
|
|
||||||
if (sr_id > this->max_sr_id) {
|
if (sr_id > this->max_sr_id) {
|
||||||
LOG_F(ERROR, "%s: invalid sample rate ID %d!", this->name.c_str(), sr_id);
|
LOG_F(ERROR, "%s: invalid sample rate ID %d!", this->name.c_str(), sr_id);
|
||||||
} else {
|
} else {
|
||||||
@@ -55,8 +53,7 @@ void AwacsBase::set_sample_rate(int sr_id)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AwacsBase::dma_out_start()
|
void AwacsBase::dma_out_start() {
|
||||||
{
|
|
||||||
int err;
|
int err;
|
||||||
bool reopen = false;
|
bool reopen = false;
|
||||||
|
|
||||||
@@ -66,9 +63,10 @@ void AwacsBase::dma_out_start()
|
|||||||
if (reopen) {
|
if (reopen) {
|
||||||
snd_server->close_out_stream();
|
snd_server->close_out_stream();
|
||||||
this->out_stream_ready = false;
|
this->out_stream_ready = false;
|
||||||
|
this->out_stream_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->out_stream_ready || reopen) {
|
if (!this->out_stream_ready) {
|
||||||
if ((err = this->snd_server->open_out_stream(this->cur_sample_rate,
|
if ((err = this->snd_server->open_out_stream(this->cur_sample_rate,
|
||||||
(void *)this->dma_out_ch))) {
|
(void *)this->dma_out_ch))) {
|
||||||
LOG_F(ERROR, "%s: unable to open sound output stream: %d",
|
LOG_F(ERROR, "%s: unable to open sound output stream: %d",
|
||||||
@@ -76,26 +74,31 @@ void AwacsBase::dma_out_start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = snd_server->start_out_stream())) {
|
|
||||||
LOG_F(ERROR, "%s: could not start sound output stream", this->name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
this->out_sample_rate = this->cur_sample_rate;
|
this->out_sample_rate = this->cur_sample_rate;
|
||||||
this->out_stream_ready = true;
|
this->out_stream_ready = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void AwacsBase::dma_out_stop()
|
if (!this->out_stream_running) {
|
||||||
{
|
if ((err = snd_server->start_out_stream())) {
|
||||||
if (this->out_stream_ready) {
|
LOG_F(ERROR, "%s: could not start sound output stream", this->name.c_str());
|
||||||
snd_server->close_out_stream();
|
}
|
||||||
this->out_stream_ready = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AwacsBase::dma_out_stop() {
|
||||||
|
if (this->out_stream_ready) {
|
||||||
|
snd_server->close_out_stream();
|
||||||
|
this->out_stream_ready = false;
|
||||||
|
this->out_stream_running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AwacsBase::dma_out_pause() {
|
||||||
|
this->out_stream_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
//=========================== PDM-style AWACs =================================
|
//=========================== PDM-style AWACs =================================
|
||||||
AwacDevicePdm::AwacDevicePdm() : AwacsBase("AWAC-PDM")
|
AwacDevicePdm::AwacDevicePdm() : AwacsBase("AWAC-PDM") {
|
||||||
{
|
|
||||||
static int pdm_awac_freqs[3] = {22050, 29400, 44100};
|
static int pdm_awac_freqs[3] = {22050, 29400, 44100};
|
||||||
|
|
||||||
// PDM-style AWACs only supports three sample rates
|
// PDM-style AWACs only supports three sample rates
|
||||||
@@ -103,14 +106,12 @@ AwacDevicePdm::AwacDevicePdm() : AwacsBase("AWAC-PDM")
|
|||||||
this->max_sr_id = 2;
|
this->max_sr_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AwacDevicePdm::read_stat()
|
uint32_t AwacDevicePdm::read_stat() {
|
||||||
{
|
|
||||||
// TODO: implement all other status bits
|
// TODO: implement all other status bits
|
||||||
return (AWAC_REV_AWACS << 12) | (AWAC_MAKER_CRYSTAL << 8);
|
return (AWAC_REV_AWACS << 12) | (AWAC_MAKER_CRYSTAL << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwacDevicePdm::write_ctrl(uint32_t addr, uint16_t value)
|
void AwacDevicePdm::write_ctrl(uint32_t addr, uint16_t value) {
|
||||||
{
|
|
||||||
if (addr <= 4) {
|
if (addr <= 4) {
|
||||||
this->ctrl_regs[addr] = value;
|
this->ctrl_regs[addr] = value;
|
||||||
} else {
|
} else {
|
||||||
@@ -120,8 +121,7 @@ void AwacDevicePdm::write_ctrl(uint32_t addr, uint16_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================= Screamer AWACs ================================
|
//============================= Screamer AWACs ================================
|
||||||
AwacsScreamer::AwacsScreamer(std::string name) : MacioSndCodec(name)
|
AwacsScreamer::AwacsScreamer(std::string name) : MacioSndCodec(name) {
|
||||||
{
|
|
||||||
static int screamer_freqs[8] = {
|
static int screamer_freqs[8] = {
|
||||||
44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
|
44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
|
||||||
};
|
};
|
||||||
@@ -140,8 +140,7 @@ int AwacsScreamer::device_postinit() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AwacsScreamer::snd_ctrl_read(uint32_t offset, int size)
|
uint32_t AwacsScreamer::snd_ctrl_read(uint32_t offset, int size) {
|
||||||
{
|
|
||||||
switch (offset) {
|
switch (offset) {
|
||||||
case AWAC_SOUND_CTRL_REG:
|
case AWAC_SOUND_CTRL_REG:
|
||||||
return this->snd_ctrl_reg;
|
return this->snd_ctrl_reg;
|
||||||
@@ -156,8 +155,7 @@ uint32_t AwacsScreamer::snd_ctrl_read(uint32_t offset, int size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwacsScreamer::snd_ctrl_write(uint32_t offset, uint32_t value, int size)
|
void AwacsScreamer::snd_ctrl_write(uint32_t offset, uint32_t value, int size) {
|
||||||
{
|
|
||||||
int subframe, reg_num;
|
int subframe, reg_num;
|
||||||
uint16_t data;
|
uint16_t data;
|
||||||
|
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
void set_sample_rate(int sr_id);
|
void set_sample_rate(int sr_id);
|
||||||
void dma_out_start();
|
void dma_out_start();
|
||||||
void dma_out_stop();
|
void dma_out_stop();
|
||||||
|
void dma_out_pause();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SoundServer *snd_server; // SoundServer instance pointer
|
SoundServer *snd_server; // SoundServer instance pointer
|
||||||
@@ -60,6 +61,7 @@ protected:
|
|||||||
int max_sr_id; // maximum value for sample rate ID
|
int max_sr_id; // maximum value for sample rate ID
|
||||||
|
|
||||||
bool out_stream_ready = false;
|
bool out_stream_ready = false;
|
||||||
|
bool out_stream_running = false;
|
||||||
int cur_sample_rate = -1;
|
int cur_sample_rate = -1;
|
||||||
int out_sample_rate = -1;
|
int out_sample_rate = -1;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user