[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11173: Small changes to the audio/v
From: |
Andrea Palmatè |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11173: Small changes to the audio/video part of AmigaOS4. Now the audio task is killed by the GUI. TODO: a mixing function |
Date: |
Sun, 28 Jun 2009 17:49:26 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11173
committer: Andrea Palmatè <address@hidden>
branch nick: gnash
timestamp: Sun 2009-06-28 17:49:26 +0200
message:
Small changes to the audio/video part of AmigaOS4. Now the audio task is
killed by the GUI. TODO: a mixing function
modified:
gui/aos4.cpp
gui/aos4sup.h
libsound/aos4/sound_handler_ahi.cpp
libsound/aos4/sound_handler_ahi.h
=== modified file 'gui/aos4.cpp'
--- a/gui/aos4.cpp 2009-06-27 15:26:16 +0000
+++ b/gui/aos4.cpp 2009-06-28 15:49:26 +0000
@@ -38,6 +38,7 @@
#include "aos4_gnash_prefs.h"
#include <getopt.h>
+#include <signal.h>
#include "GnashSleep.h" // for gnashSleep
@@ -50,6 +51,7 @@
extern Object *win;
extern struct MsgPort *AppPort;
extern Object *Objects[OBJ_NUM];
+extern int audioTaskID;
#define GAD(x) (struct Gadget *)Objects[x]
@@ -152,7 +154,15 @@
IExec->SendIO((struct IORequest *)_timerio);
}
-
+void
+AOS4Gui::killAudioTask()
+{
+ if (audioTaskID) // This is a Global variable defined in
sound_handler_ahi that point to the audioTask
+ {
+ IExec->Signal((struct Task*)audioTaskID,SIGBREAKF_CTRL_C);
+ IDOS->Delay(50); //Wait to be sure that audio task has finished
its work..
+ }
+}
bool
AOS4Gui::run()
@@ -261,6 +271,7 @@
log_error (_("Cannot open File Requester!\n"));
break;
case 6: /* Quit */
+ killAudioTask();
return true;
break;
}
@@ -487,6 +498,7 @@
case IDCMP_CLOSEWINDOW:
if (imsg->IDCMPWindow ==
_window)
IExec->ReplyMsg
((struct Message *)imsg);
+ killAudioTask();
return true;
break;
case IDCMP_MOUSEMOVE:
@@ -520,10 +532,6 @@
case IDCMP_RAWKEY:
if (imsg->IDCMPWindow ==
_window)
{
- IExec->ReplyMsg
((struct Message *)imsg);
- if ( (imsg->Code &
~IECODE_UP_PREFIX) == RAWKEY_ESC) //ESC
- return true;
-
if (!(imsg->Code &
IECODE_UP_PREFIX))
{
code =
os4_to_gnash_key(imsg);
@@ -596,6 +604,7 @@
log_error (_("error creating RenderHandler!\n"));
return false;
}
+ signal(SIGINT, SIG_IGN);
return true;
}
=== modified file 'gui/aos4sup.h'
--- a/gui/aos4sup.h 2009-06-06 19:29:06 +0000
+++ b/gui/aos4sup.h 2009-06-28 15:49:26 +0000
@@ -107,6 +107,7 @@
void TimerExit(void);
bool TimerInit(void);
void TimerReset(uint32 microDelay);
+ void killAudioTask();
int _orig_width;
int _orig_height;
=== modified file 'libsound/aos4/sound_handler_ahi.cpp'
--- a/libsound/aos4/sound_handler_ahi.cpp 2009-06-27 16:32:26 +0000
+++ b/libsound/aos4/sound_handler_ahi.cpp 2009-06-28 15:49:26 +0000
@@ -47,10 +47,10 @@
#include <exec/memory.h>
#define PLAYERTASK_NAME "Gnash audio task"
-#define PLAYERTASK_PRIORITY 2
-#define RESET_TIME 30 * 1000
+#define PLAYERTASK_PRIORITY 20
+#define RESET_TIME 10 * 1000
-#define BUFSIZE 7056 * 2
+#define BUFSIZE 7056 * 1
#define AHI_BUF_SIZE 7056u
// Define this to get debugging call about pausing/unpausing audio
@@ -59,6 +59,8 @@
// Mixing and decoding debugging
//#define GNASH_DEBUG_MIXING
+int audioTaskID;
+
static int
audioTaskWrapper()
{
@@ -99,9 +101,7 @@
AOS4_sound_handler::AOS4_sound_handler(const std::string& wavefile)
:
_audioOpened(false),
- _closing(false),
- _paused(true),
- _started(false)
+ _closing(false)
{
initAudio();
@@ -123,10 +123,7 @@
AOS4_sound_handler::AOS4_sound_handler()
:
_audioOpened(false),
- _closing(false),
- _paused(true),
- _started(false),
- _fetching(false)
+ _closing(false)
{
initAudio();
}
@@ -137,8 +134,10 @@
// on class destruction we must kill the Audio thread
_closing = true;
- _paused = true;
- IDOS->Delay(30);
+ sound_handler::pause();
+
+ log_debug("Killing Audio Task..");
+
IExec->Signal((struct Task*)AudioPump,SIGBREAKF_CTRL_C);
IExec->WaitPort(_DMreplyport);
@@ -146,11 +145,6 @@
if (_dmsg) IExec->FreeSysObject(ASOT_MESSAGE,
_dmsg); _dmsg = 0;
if (_DMreplyport) IExec->FreeSysObject(ASOT_PORT, _DMreplyport);
_DMreplyport = 0;
-
- while (_fetching)
- {
- gnashSleep(100);
- }
lock.unlock();
@@ -209,6 +203,9 @@
if (AudioPump)
{
+ //Get audio task pointer to kill it from the GUI.. it actually
use a global variable.. better than nothing
+ audioTaskID = (int)AudioPump;
+
_audioOpened = true;
log_debug(_("AOS4: Audio Process spawned.."));
}
@@ -371,13 +368,10 @@
boost::mutex::scoped_lock lock(_mutex);
if (!_closing)
{
- _fetching = true;
- if (to)
sound_handler::fetchSamples(to, nSamples);
- _fetching = false;
}
-
- if (!_closing) return;
+ else
+ return;
// TODO: move this to base class !
if (file_stream)
@@ -398,7 +392,7 @@
#ifdef GNASH_DEBUG_AOS4_AUDIO_PAUSING
log_debug("Pausing AOS4 Audio...");
#endif
- _paused = true;
+ sound_handler::pause();
}
}
}
@@ -407,6 +401,7 @@
AOS4_sound_handler::mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
unsigned int nSamples, float volume)
{
unsigned int nBytes = nSamples*2;
+
if (!_closing)
{
memcpy(BufferPointer, inSamples, nBytes);
@@ -470,7 +465,7 @@
#ifdef GNASH_DEBUG_AOS4_AUDIO_PAUSING
log_debug("Unpausing AOS4 Audio on inpust stream plug...");
#endif
- _paused = false;
+ sound_handler::unpause();
}
}
@@ -500,7 +495,7 @@
{
//closeAudio();
log_debug(_("AOS4: AOS4_sound_handler::pause"));
- _paused = true;
+ sound_handler::pause();
log_debug(_("AOS4: paused"));
sound_handler::pause();
@@ -512,7 +507,7 @@
if ( hasInputStreams() )
{
log_debug(_("AOS4: AOS4_sound_handler::unpause"));
- _paused = false;
+ sound_handler::unpause();
log_debug(_("AOS4: unpaused"));
}
@@ -594,7 +589,6 @@
unsigned int nSamples = (441*clockAdvance) / 10;
unsigned int toFetch = nSamples*2;
boost::int16_t samples[AHI_BUF_SIZE];
- struct Process *_audioTask = ( struct Process *)IExec->FindTask(0);
_closing = false;
@@ -680,10 +674,16 @@
uint32 sigGot = IExec->Wait(sigMask);
+ if (sigGot & SIGBREAKF_CTRL_C)
+ {
+ _closing = true;
+ log_debug(_("AOS4: Closing Audio Thread.."));
+ break;
+ }
if (sigGot & _timerSig)
{
IExec->GetMsg(_port);
- if (_paused == false)
+ if (!sound_handler::isPaused())
{
while (toFetch && !_closing)
{
@@ -695,12 +695,6 @@
}
if (!_closing) TimerReset(RESET_TIME);
}
- if (sigGot & SIGBREAKF_CTRL_C)
- {
- _closing = true;
- log_debug(_("AOS4: Closing Audio Thread.."));
- break;
- }
}
log_debug(_("AOS4: Cleaning Audio Stuff.."));
@@ -741,7 +735,6 @@
log_debug(_("AOS4: audioTask:Close timer.."));
TimerExit();
- IDOS->SetIoErr((int32)_audioTask->pr_ProcessID);
return(RETURN_OK);
}
=== modified file 'libsound/aos4/sound_handler_ahi.h'
--- a/libsound/aos4/sound_handler_ahi.h 2009-06-27 16:32:26 +0000
+++ b/libsound/aos4/sound_handler_ahi.h 2009-06-28 15:49:26 +0000
@@ -84,9 +84,6 @@
bool _audioOpened;
bool _closing;
- bool _paused;
- bool _started;
- bool _fetching;
struct DeathMessage *_dmsg; // the child Death Message
struct MsgPort *_DMreplyport; // and its port
@@ -182,9 +179,11 @@
// See dox in sound_handler.h
void fetchSamples(boost::int16_t* to, unsigned int nSamples);
- int audioTask();
+ int audioTask();
};
+
+
} // gnash.sound namespace
} // namespace gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11173: Small changes to the audio/video part of AmigaOS4. Now the audio task is killed by the GUI. TODO: a mixing function,
Andrea Palmatè <=