🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #1175

Re: Playbacking from thread

#1175
From: bcb
Date: Sun, 26 Aug 2001 17:11
62 lines
2631 bytes
Hello, Here is a thread example:

DWORD CALLBACK ThreadFunc(void* P)
{
 HDC DC=GetDC(Form1->Handle);

PlaySound("c:\\Key.wav",NULL,SND_FILENAME);
ReleaseDC(Form1->Handle, DC);

 return 0;
}

void __fastcall TForm1::PlaySoundInThread()    file://play sound in edit
boxes
{
  DWORD ThreadID;

HANDLE hthread = CreateThread(0,0,ThreadFunc, 0,0, &ThreadID);
}


So to play the sound in the thread on a button click just use this line
instead of playsound(),

PlaySoundInThread();

Goodluck.

Mike <someone@somewhere.com> wrote in message
news:3B8632A5.5F1864A9@somewhere.com...
> Hi!
>
> So, I read help about threads and WAVE playback and I found out
> that for me it would be the best to use "callback function". And, so,
> I have some questions about it.
>
> I have an thread which is created when I would like to playback
> WAVE file (and if I would like to use "thread callback" there would
> be yet another one, wouldn't be?), but I need very accurate playback
> (without dropping any samples and that it would be as real-time
> as it is possible (so little buffers, because WAVE files is generated
> in real time)), so "callback function" is what I need.
>
> How can I declare it (so that I can than with an argument
> (DWORD)WaveProc give waveOutOpen function's location (so that it
> would know what to call))? I tryed this
>
> void CALLBACK WaveProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
> lParam) {
> ... I left code for function the same
>
> but I get illegal operations
>
> Maybe I should make it thread-function (how?)?
>
> And what's the priority of this function (it's default or it is thread's
> priority)?
>
>
> Mike
>
>
Technical Details
Message-ID: <3b892dbd_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3B84BF57.200A3CFE@somewhere.com> <3B8632A5.5F1864A9@somewhere.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,3d92e384aaa25825
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2001-08-26 10:14:08 PST
From: "bcb" <noemail@sorry.com>
Newsgroups: borland.public.cppbuilder.multimedia
References: <3B84BF57.200A3CFE@somewhere.com> <3B8632A5.5F1864A9@somewhere.com>
Subject: Re: Playbacking from thread
Date: Sun, 26 Aug 2001 13:11:04 -0400
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Host: 206.71.125.117
Message-ID: <3b892dbd_2@dnews>
X-Trace: dnews 998845885 206.71.125.117 (26 Aug 2001 10:11:25 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews