From 27e5fdc3ce8634d995d513894377d0c5d20975a5 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Mon, 21 Jan 2008 20:56:39 +0000 Subject: [PATCH] Remove spurious #pragma once from DSound audio player, and add a comment about it needing rewrite once again. (It's doing COM wrong.) Originally committed to SVN as r1806. --- aegisub/audio_player_dsound.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/aegisub/audio_player_dsound.cpp b/aegisub/audio_player_dsound.cpp index a9974caa1..f3c1df054 100644 --- a/aegisub/audio_player_dsound.cpp +++ b/aegisub/audio_player_dsound.cpp @@ -34,9 +34,6 @@ // -#pragma once - - /////////// // Headers #ifdef WITH_DIRECTSOUND @@ -71,6 +68,21 @@ public: wxThread::ExitCode Entry(); }; +/* +TODO: Rewrite playback thread to manage all of the buffer, and properly marshal the IDirectSound8 +object into the thread for creating the buffer there. +The thread should own the buffer and manage all of the playback. +It must be created with start and duration set, and begins playback at the given position. +New functions: +* Seek(pos) : Restart playback from the given position +* SetEnd(pos) : Set new end point +* GetPosition() : Get the current sample number being played +* Stop() : Stop playback immediately + +Instead of using a stop event, use a playback parameters changed event. When that one's fired, +detect which were actually changed and act accordingly. +All but GetPosition() set appropriate fields and then raise the parameters changed event. +*/ //////////////////// @@ -430,6 +442,8 @@ DirectSoundPlayerThread::~DirectSoundPlayerThread() { ////////////////////// // Thread entry point wxThread::ExitCode DirectSoundPlayerThread::Entry() { + CoInitialize(0); + // Wake up thread every half second to fill buffer as needed // This more or less assumes the buffer is at least one second long while (WaitForSingleObject(stopnotify, 50) == WAIT_TIMEOUT) { @@ -469,6 +483,8 @@ wxThread::ExitCode DirectSoundPlayerThread::Entry() { parent->playing = false; parent->buffer->Stop(); + + CoUninitialize(); return 0; }