Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Log File...

Log File...

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mpallavi
    wrote on last edited by
    #1

    Hi.. I need to maintain a log file which will contain the time i started a playback.. and the time it ended.. What i have done is: -> Get the current time and write it to log.. -> The code that takes care of sound playback.. -> Get the current time and write it to log.. The problem is .. both these times are same.. (the playback goes on for more than 10 secs..) Can anyone help me out.. regards pallavi

    C 1 Reply Last reply
    0
    • M mpallavi

      Hi.. I need to maintain a log file which will contain the time i started a playback.. and the time it ended.. What i have done is: -> Get the current time and write it to log.. -> The code that takes care of sound playback.. -> Get the current time and write it to log.. The problem is .. both these times are same.. (the playback goes on for more than 10 secs..) Can anyone help me out.. regards pallavi

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      If you don't post the code, we won't be able to help you... Or at least the code that write the times in the log file.

      M 1 Reply Last reply
      0
      • C Cedric Moonen

        If you don't post the code, we won't be able to help you... Or at least the code that write the times in the log file.

        M Offline
        M Offline
        mpallavi
        wrote on last edited by
        #3

        Ya.. here it is.. CTime theTime=CTime::GetCurrentTime(); CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(startTime); m_pMyDS->Play(); CTime getTime=CTime::GetCurrentTime(); CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(endTime); ....................... Play() is a memeber function of class MyDirSound.. which plays the wave file.. The same code for writing time works fine with the recording of sound module .. pallavi

        C 1 Reply Last reply
        0
        • M mpallavi

          Ya.. here it is.. CTime theTime=CTime::GetCurrentTime(); CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(startTime); m_pMyDS->Play(); CTime getTime=CTime::GetCurrentTime(); CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(endTime); ....................... Play() is a memeber function of class MyDirSound.. which plays the wave file.. The same code for writing time works fine with the recording of sound module .. pallavi

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          I don't see any problems with this code... Are you sure your Play function lasts for 10 seconds ? Maybe the sound is played in another thread and thus the Play function returns immediately even if the sound lasts for 10 seconds [EDIT] A way to check this: just after the Play() function, display a MessageBox. If it is prompted when the sound is playing, that means it is played in a separate thread, thus that's logical you have the same time before and after the function. If it is displayed when the sound is finished, the problem must be elsewhere [\EDIT]

          M 2 Replies Last reply
          0
          • C Cedric Moonen

            I don't see any problems with this code... Are you sure your Play function lasts for 10 seconds ? Maybe the sound is played in another thread and thus the Play function returns immediately even if the sound lasts for 10 seconds [EDIT] A way to check this: just after the Play() function, display a MessageBox. If it is prompted when the sound is playing, that means it is played in a separate thread, thus that's logical you have the same time before and after the function. If it is displayed when the sound is finished, the problem must be elsewhere [\EDIT]

            M Offline
            M Offline
            mpallavi
            wrote on last edited by
            #5

            hi .. Thank you.. You are right.. The the message is prompted when the sound is playing.. I am using Directx's DirectSound to play the wave files.. I tried defining and calling the WriteLogFile(..) function in the MyDirSound class itself.. What must be wrong?.. pallavi :(

            C 1 Reply Last reply
            0
            • M mpallavi

              hi .. Thank you.. You are right.. The the message is prompted when the sound is playing.. I am using Directx's DirectSound to play the wave files.. I tried defining and calling the WriteLogFile(..) function in the MyDirSound class itself.. What must be wrong?.. pallavi :(

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              But what do you want to achieve exactly ?? Measure the time of the sound sample ? You won't be able to do it like that. Because as I said, if it is run in another thread, you won't be able to access it (even in your MyDirSound class). The thread is ran directly inside the DirectX layers so you don't have access to it. But (fortunately :) ) there is probably another solution: normally there is something you can find in DirectSound (I suppose, because I don't know DirectSound) that will let you know when the sample is finished. Something like a callback function you can set or something like that. But in this field I have no knowledge so you will need to look in the doc of DirectSound. But I suppose they provided a way to do it...

              M 1 Reply Last reply
              0
              • C Cedric Moonen

                I don't see any problems with this code... Are you sure your Play function lasts for 10 seconds ? Maybe the sound is played in another thread and thus the Play function returns immediately even if the sound lasts for 10 seconds [EDIT] A way to check this: just after the Play() function, display a MessageBox. If it is prompted when the sound is playing, that means it is played in a separate thread, thus that's logical you have the same time before and after the function. If it is displayed when the sound is finished, the problem must be elsewhere [\EDIT]

                M Offline
                M Offline
                mpallavi
                wrote on last edited by
                #7

                In CMyDirSound::Play() .. there is a call .. m_lpDSB->Play(0, 0, DSBPLAY_LOOPING);// Play(..) member of IDirectSounBuffer ............ I tried saving times before and after this function call.. but both times are same.. all wave files which i am playing are more than 10 secs.. ..pal

                C 1 Reply Last reply
                0
                • C Cedric Moonen

                  But what do you want to achieve exactly ?? Measure the time of the sound sample ? You won't be able to do it like that. Because as I said, if it is run in another thread, you won't be able to access it (even in your MyDirSound class). The thread is ran directly inside the DirectX layers so you don't have access to it. But (fortunately :) ) there is probably another solution: normally there is something you can find in DirectSound (I suppose, because I don't know DirectSound) that will let you know when the sample is finished. Something like a callback function you can set or something like that. But in this field I have no knowledge so you will need to look in the doc of DirectSound. But I suppose they provided a way to do it...

                  M Offline
                  M Offline
                  mpallavi
                  wrote on last edited by
                  #8

                  Ya.. Thanx cedric.. There is a function called setcallback(..).. I will try it out.. thank you regards pallavi

                  C 1 Reply Last reply
                  0
                  • M mpallavi

                    In CMyDirSound::Play() .. there is a call .. m_lpDSB->Play(0, 0, DSBPLAY_LOOPING);// Play(..) member of IDirectSounBuffer ............ I tried saving times before and after this function call.. but both times are same.. all wave files which i am playing are more than 10 secs.. ..pal

                    C Offline
                    C Offline
                    Cedric Moonen
                    wrote on last edited by
                    #9

                    See my previous post. Your function CMyDirSound::Play() is called in the same thread so there is absolutely no reasons AT ALL (I'm not shouting, just insisting on that point ;) ) that it will be ran in a separate thread... You know what a thread is at least ? (I mean, for understanding this, it will be easier for you). The thread is started inside the function of DirectSound and that's perfectly logical: imagine that all your application will freeze during ten second just because you play a sound :doh:

                    1 Reply Last reply
                    0
                    • M mpallavi

                      Ya.. Thanx cedric.. There is a function called setcallback(..).. I will try it out.. thank you regards pallavi

                      C Offline
                      C Offline
                      Cedric Moonen
                      wrote on last edited by
                      #10

                      Hmm, yes but before jumping on that, be sure that this is used to provided a call-back function that will be called when the sample is finished. It could be also a call-back that is called for some other reasons :). Maybe also this will be called for several different events and passing an argument that describe which kind of event occurs... So, before starting writing code, look at the doc to see if it fits what you are seeking for (just to avoid you losing time on things won't work ;)) Also, if you have time, try to document a little bit about the threads (at least the basics: what it is and how they work, not be able to use them but at least understand what it is).

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups