summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2013-01-11 14:16:04 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2013-01-11 14:16:49 +0800
commitbac0b2d546db5ef1cdd474d6bb42029fdcd1e205 (patch)
treee5e2d7a00f0662a17872798bc8fcfc6d4a0be692 /src
parent06abde77b6ad7f586a7c799c95fcba55ef8f2c7a (diff)
Add a mutex to protect the renderer in mod source
Diffstat (limited to 'src')
-rw-r--r--src/input_mod.cpp27
-rw-r--r--src/input_mod.h3
2 files changed, 29 insertions, 1 deletions
diff --git a/src/input_mod.cpp b/src/input_mod.cpp
index 6347535..0c41262 100644
--- a/src/input_mod.cpp
+++ b/src/input_mod.cpp
@@ -84,6 +84,9 @@ namespace audiere {
void
MODInputStream::reset() {
ADR_GUARD("MOD_Reset");
+
+ SYNCHRONIZED(this);
+
DUH_SIGRENDERER* renderer = duh_start_sigrenderer(m_duh, 0, 2, 0);
if (renderer) {
if (m_renderer) {
@@ -101,6 +104,9 @@ namespace audiere {
MODInputStream::getOrder()
{
ADR_GUARD("MOD_getOrder");
+
+ SYNCHRONIZED(this);
+
if (m_renderer) {
DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
return dumb_it_sr_get_current_order(itrenderer);
@@ -113,6 +119,9 @@ namespace audiere {
MODInputStream::setOrder(int order)
{
ADR_GUARD("MOD_setOrder");
+
+ SYNCHRONIZED(this);
+
DUH_SIGRENDERER* renderer = dumb_it_start_at_order(m_duh, 2, order);
if (!renderer)
return false;
@@ -131,6 +140,9 @@ namespace audiere {
MODInputStream::getRow()
{
ADR_GUARD("MOD_getRow");
+
+ SYNCHRONIZED(this);
+
if (m_renderer) {
DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
return dumb_it_sr_get_current_row(itrenderer);
@@ -143,6 +155,9 @@ namespace audiere {
MODInputStream::getChannelVolume(int channel)
{
ADR_GUARD("MOD_getChannelVolume");
+
+ SYNCHRONIZED(this);
+
if (!m_renderer)
return 1.0f;
@@ -158,6 +173,9 @@ namespace audiere {
MODInputStream::setChannelVolume(int channel, float volume)
{
ADR_GUARD("MOD_getChannelVolume");
+
+ SYNCHRONIZED(this);
+
if (!m_renderer)
return false;
@@ -175,6 +193,9 @@ namespace audiere {
MODInputStream::getTempo()
{
ADR_GUARD("MOD_getTempo");
+
+ SYNCHRONIZED(this);
+
if (m_renderer) {
DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
return dumb_it_sr_get_tempo(itrenderer);
@@ -187,6 +208,9 @@ namespace audiere {
MODInputStream::setTempo(int tempo)
{
ADR_GUARD("MOD_setTempo");
+
+ SYNCHRONIZED(this);
+
if (m_renderer) {
DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
dumb_it_sr_set_tempo(itrenderer, tempo);
@@ -200,6 +224,9 @@ namespace audiere {
int
MODInputStream::doRead(int frame_count, void* buffer) {
ADR_GUARD("MOD_doRead");
+
+ SYNCHRONIZED(this);
+
return duh_render(m_renderer, 16, 0, 1.0f, 65536.0f / 44100,
frame_count, buffer);
}
diff --git a/src/input_mod.h b/src/input_mod.h
index 0a58e43..94257db 100644
--- a/src/input_mod.h
+++ b/src/input_mod.h
@@ -5,12 +5,13 @@
#include <dumb.h>
#include "audiere.h"
#include "basic_source.h"
+#include "threads.h"
#include "types.h"
namespace audiere {
- class MODInputStream : public BasicSource {
+ class MODInputStream : public BasicSource, public Mutex {
public:
MODInputStream();
~MODInputStream();