IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

CAST impossible


Sujet :

MFC

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 87
    Par défaut CAST impossible
    salut, je galère sur l'expression suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
     
    VOID*   pDSLockedBuffer = NULL;
    BYTE		*pCopy;
     
    DXBuf->Lock(m_dwNextWriteOffset, m_dwNotifySize,                  &pDSLockedBuffer, &dwDSLockedBufferSize, &pDSLockedBuffer2, &dwDSLockedBufferSize2, 0L ) ) )
     
    pCopy = (BYTE*)pDSLockedBuffer[i*512*4];
    pDSLockedBuffer est bien non NULL, en fait il est passé à la fonction lock d'un buffer audio DirectX, pDSLockedBuffer est un pointeur vers une zone valid pour écriture.

    mais le compilateur beugle sur cette expression :
    error C2036: 'void *' : unknown size
    error C2440: 'type cast' : cannot convert from 'void' to 'BYTE *'

    je ne comprend pas trop

  2. #2
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    salut,
    normal tu ne peux faire ça:pDSLockedBuffer[i*512*4];
    le type etant void le compilateur ne peut indicer ce qui est indefini .
    commence par caster le pointeur en byte* avec des parentheses et apres tu indices sur le pointeur obtenu .

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 87
    Par défaut
    Comme cela :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    pCopy = ((BYTE *)pDSLockedBuffer)[i*512*4];
    parce que la j'ai :

    error C2440: '=' : cannot convert from 'BYTE' to 'BYTE *'

    pb de déférence ?

  4. #4
    mat.M
    Invité(e)
    Par défaut
    Il faut faire ( c'est bien ce qu'il me semblait ) un memcpy


    Filling and Playing Static Buffers
    A secondary buffer that contains an entire self-contained sound is called a static buffer. Although it is possible to reuse the same buffer for different sounds, typically data is written to a static buffer only once.

    Static buffers are created and managed just like streaming buffers. The only difference is in the way they are used: static buffers are filled once and then played, but streaming buffers are constantly refreshed with data as they are playing.

    Note A static buffer is not necessarily one created by setting the DSBCAPS_STATIC flag in the buffer description. This flag requests allocation of memory on the sound card, which not available on most modern hardware. A static buffer can exist in system memory and can be created with either the DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE flag. For more information, see Voice Management on ISA and PCI Cards.

    Loading data into a static buffer is a three-step process:

    Lock the entire buffer by using IDirectSoundBuffer8::Lock. You specify the offset within the buffer where you intend to begin writing (normally 0), and get back the memory address of that point.
    Write the audio data to the returned address by using a standard memory-copy routine.
    Unlock the buffer using IDirectSoundBuffer8::Unlock.
    These steps are shown in the following example, where lpdsbStatic is an IDirectSoundBuffer8 interface pointer and pbData is the address of the data source:

    LPVOID lpvWrite;
    DWORD dwLength;

    if (DS_OK == lpdsbStatic->Lock(
    0, // Offset at which to start lock.
    0, // Size of lock; ignored because of flag.
    &lpvWrite, // Gets address of first part of lock.
    &dwLength, // Gets size of first part of lock.
    NULL, // Address of wraparound not needed.
    NULL, // Size of wraparound not needed.
    DSBLOCK_ENTIREBUFFER)) // Flag.
    {
    memcpy(lpvWrite, pbData, dwLength);
    lpdsbStatic->Unlock(
    lpvWrite, // Address of lock start.
    dwLength, // Size of lock.
    NULL, // No wraparound portion.
    0); // No wraparound size.
    }

    To play the buffer, call IDirectSoundBuffer8:lay, as in the following example:

    lpdsbStatic->SetCurrentPosition(0);
    HRESULT hr = lpdsbStatic->Play(
    0, // Unused.
    0, // Priority for voice management.
    0); // Flags.

  5. #5
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    si c'est [] c'est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    pCopy = &((BYTE *)pDSLockedBuffer)[i*512*4];

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 87
    Par défaut
    merci farscape, sinon oui je fais un memcpy, je n'est pas tout mis le code, juste le nécéssaire pour mon erreur précédente. merci quand même

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Cast impossible et non souhaité
    Par Théophille dans le forum ASP.NET
    Réponses: 2
    Dernier message: 26/06/2014, 09h52
  2. CAST impossible?! mot3
    Par Sergejack dans le forum Requêtes
    Réponses: 1
    Dernier message: 30/06/2010, 09h51
  3. requete oledb, cast impossible ?
    Par dudule dans le forum VB.NET
    Réponses: 7
    Dernier message: 26/09/2008, 09h15
  4. [NHibernate] NHibernate.MappingException Cast impossible
    Par Harmelyo dans le forum NHibernate
    Réponses: 1
    Dernier message: 06/08/2008, 09h16
  5. Réponses: 2
    Dernier message: 07/03/2007, 14h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo